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.

Certified 80 core · 63 supporting · 6 submodules This directory provides exact-rational interval certificates for finite kernels and stationary expectations, together with certified standard-normal CDF enclosures. Birthday 20 core · 25 supporting · 12 submodules Draw labels independently and uniformly from an alphabet of size m, where the number of draws is Binomial(T, η). Distributions 3 core · 6 supporting · 1 submodule This barrel collects Mathlib-shaped probability-distribution developments used by Causalean. Gaussian­Mean­Embedding 17 core · 27 supporting · 3 submodules This module gives an explicit real Hilbert-space feature map for the Gaussian kernel and proves that its Bochner mean embedding distinguishes finite measures with a common bounded real support. Ident­Distrib 9 core · 25 supporting · 2 submodules Two bounds for sums over an i.i.d. Independence 67 core · 78 supporting · 4 submodules Basic and conditional independence together with their integral consequences. Kernel 87 core · 85 supporting · 13 submodules Probability-kernel constructions for conditional distributions, product composition, graph-based maps, Bernoulli marks, and quantile realizations. Limit­Theorems 4 core · 4 supporting · 1 submodule Approximation results used to establish probabilistic limit theorems. Poisson 98 core · 139 supporting · 5 submodules Moment, inverse-moment, finite-partition, and Poincaré tools for Poisson random variables and processes. Stein­Method 16 core · 42 supporting · 7 submodules Stein-method normal-approximation helpers: Stein equation solutions, uniform bounds, local-dependence estimates, and dependency-graph CLTs. Sub­Gaussian 9 core · 0 supporting · 9 submodules This directory provides deterministic Gaussian-tail estimates, finite-maximum tail and layer-cake bridges, and the resulting logarithmic expected-maximum envelope for finite ordered sub-Gaussian families with polynomiall
Std­Normal­CDF 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.

def stdNormalPDF reviewed
Causalean.Mathlib

For each real number xx, the standard-normal density at xx is exp⁡(−x2/2)/2π\exp(-x^2/2)/\sqrt{2\pi}.

Definition (Lean source)
x :
ℝ
stdNormalPDF x :
ℝ
def stdNormalCDF reviewed
Causalean.Mathlib

For each real number xx, the standard-normal cumulative distribution function at xx is the probability that a mean-zero, variance-one normal random variable is at most xx.

Definition (Lean source)
x :
ℝ
stdNormalCDF x :
ℝ
lemma stdNormalCDF_continuous reviewed
Causalean.Mathlib

The standard normal CDF Φ is continuous: the standard normal has no atoms.

Formal statement
Proof (Lean source)
@[fun_prop] lemma stdNormalCDF_continuous : Continuous stdNormalCDF := by haveI : NullSingletonClass (gaussianReal 0 1) := nullSingletonClass_gaussianReal (v := 1) one_ne_zero exact cdf_continuous_of_noAtoms (gaussianReal 0 1)
Causalean.Mathlib.stdNormalCDF_continuous · Causalean/Mathlib/Probability/StdNormalCDF.lean:118 · uses stdNormalCDF
def probit reviewed
Causalean.Mathlib

For each real number pp, the probit at pp is the infimum of the real numbers xx for which the standard-normal cumulative distribution function at xx is at least pp.

Definition (Lean source)
p :
ℝ
probit p :
ℝ
sInf {x : ℝ | p ≤ stdNormalCDF x}
lemma probit_stdNormalCDF reviewed
Causalean.Mathlib

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
x :
ℝ
Proof (Lean source)
lemma probit_stdNormalCDF (x : ℝ) : probit (stdNormalCDF x) = x := by rw [probit] have hset : {y : ℝ | stdNormalCDF x ≤ stdNormalCDF y} = Ici x := by ext y exact stdNormalCDF_strictMono.le_iff_le rw [hset, csInf_Ici]
14 supporting declarations (lemmas, instances)
Bernoulli­Measure 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.

def bernoulliLaw reviewed
Causalean.Mathlib.Probability

For any real number interpreted as a success parameter, the real-valued Bernoulli measure assigns mass max⁡(p,0)\max(p,0) to 11 and mass max⁡(1−p,0)\max(1-p,0) to 00.

Definition (Lean source)
p :
ℝ
bernoulliLaw p :
ofReal p • Measure.dirac (1 : ℝ) + ofReal (1 - p) • Measure.dirac (0 : ℝ)
Causalean.Mathlib.Probability.bernoulliLaw · Causalean/Mathlib/Probability/BernoulliMeasure.lean:36
lemma bernoulliLaw_klDiv_toReal reviewed
Causalean.Mathlib.Probability

Let pp be a Bernoulli success probability with 0≤p≤10 \le p \le 1, and let qq be a reference success probability with 0<q<10 < q < 1. Then the Kullback–Leibler divergence from the Bernoulli(pp) law to the Bernoulli(qq) law equals plog⁡(p/q)+(1−p)log⁡((1−p)/(1−q))p \log(p/q) + (1-p)\log((1-p)/(1-q)), the usual two-point KL formula: a success contribution plus a failure contribution.

Formal statement
p q :
ℝ
hp0 :
0 ≤ p
hp1 :
p ≤ 1
hq0 :
0 < q
hq1 :
q < 1
= p * log (p / q) + (1 - p) * log ((1 - p) / (1 - q))
Proof (Lean source)
lemma bernoulliLaw_klDiv_toReal {p q : ℝ} (hp0 : 0 ≤ p) (hp1 : p ≤ 1) (hq0 : 0 < q) (hq1 : q < 1) : (klDiv (bernoulliLaw p) (bernoulliLaw q)).toReal = p * log (p / q) + (1 - p) * log ((1 - p) / (1 - q)) := by classical haveI hp_prob : IsProbabilityMeasure (bernoulliLaw p) := bernoulliLaw_isProbabilityMeasure hp0 hp1 haveI hq_prob : IsProbabilityMeasure (bernoulliLaw q) := bernoulliLaw_isProbabilityMeasure hq0.le hq1.le let g : ℝ → ENNReal := fun x => if x = 1 then ofReal (p / q) else ofReal ((1 - p) / (1 - q)) have hg : Measurable g := by dsimp [g] exact Measurable.ite (measurableSet_singleton (1 : ℝ)) measurable_const measurable_const 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 have hwd : bernoulliLaw p = (bernoulliLaw q).withDensity g := by ext s hs rw [withDensity_apply _ hs] rw [← lintegral_indicator hs g] unfold bernoulliLaw dsimp [g] rw [lintegral_add_measure] rw [lintegral_smul_measure, lintegral_smul_measure] simp only [lintegral_dirac] by_cases h1 : (1 : ℝ) ∈ s · by_cases h0 : (0 : ℝ) ∈ s · simp [h1, h0, ENNReal.ofReal_div_of_pos hq0, ENNReal.ofReal_div_of_pos (sub_pos.mpr hq1), ENNReal.mul_div_cancel hq_ne0 ENNReal.ofReal_ne_top, ENNReal.mul_div_cancel h1q_ne0 ENNReal.ofReal_ne_top] · simp [h1, h0, ENNReal.ofReal_div_of_pos hq0, ENNReal.mul_div_cancel hq_ne0 ENNReal.ofReal_ne_top] · by_cases h0 : (0 : ℝ) ∈ s · simp [h1, h0, ENNReal.ofReal_div_of_pos (sub_pos.mpr hq1), ENNReal.mul_div_cancel h1q_ne0 ENNReal.ofReal_ne_top] · simp [h1, h0] have hac : bernoulliLaw p ≪ bernoulliLaw q := by rw [hwd] exact withDensity_absolutelyContinuous (bernoulliLaw q) g have hrn : (bernoulliLaw p).rnDeriv (bernoulliLaw q) =ᵐ[bernoulliLaw q] g := by rw [hwd] exact Measure.rnDeriv_withDensity (bernoulliLaw q) hg rw [InformationTheory.toReal_klDiv_eq_integral_klFun hac] trans ∫ x, klFun (g x).toReal ∂(bernoulliLaw q) · exact integral_congr_ae <| by filter_upwards [hrn] with x hx rw [hx] rw [bernoulliLaw_integral hq0.le hq1.le] dsimp [g] have hpq_nonneg : 0 ≤ p / q := div_nonneg hp0 hq0.le have hcp_nonneg : 0 ≤ (1 - p) / (1 - q) := div_nonneg (sub_nonneg.mpr hp1) (sub_nonneg.mpr hq1.le) simp only [↓reduceIte, zero_ne_one] rw [ENNReal.toReal_ofReal hpq_nonneg, ENNReal.toReal_ofReal hcp_nonneg] have hqne : q ≠ 0 := hq0.ne' have h1qne : 1 - q ≠ 0 := sub_ne_zero.mpr hq1.ne' have hA : q * klFun (p / q) = p * log (p / q) + q - p := by rw [InformationTheory.klFun_apply] field_simp [hqne] have hB : (1 - q) * klFun ((1 - p) / (1 - q)) = (1 - p) * log ((1 - p) / (1 - q)) + (1 - q) - (1 - p) := by rw [InformationTheory.klFun_apply] field_simp [h1qne] rw [hA, hB] ring
Causalean.Mathlib.Probability.bernoulliLaw_klDiv_toReal · Causalean/Mathlib/Probability/BernoulliMeasure.lean:157 · uses bernoulliLaw
lemma bernoulliLaw_klDiv_le_four_sq_sub reviewed
Causalean.Mathlib.Probability

If both success probabilities pp and qq lie in the middle half of the unit interval, 1/4≤p≤3/41/4 \le p \le 3/4 and 1/4≤q≤3/41/4 \le q \le 3/4, then the Kullback–Leibler divergence from the Bernoulli(pp) law to the Bernoulli(qq) law is at most four times the squared difference of the probabilities, 4(p−q)24(p-q)^2.

Formal statement
p q :
ℝ
hp_lo :
(1 : ℝ) / 4 ≤ p
hp_hi :
p ≤ 3 / 4
hq_lo :
(1 : ℝ) / 4 ≤ q
hq_hi :
q ≤ 3 / 4
≤ ofReal (4 * (p - q) ^ 2)
Proof (Lean source)
lemma bernoulliLaw_klDiv_le_four_sq_sub {p q : ℝ} (hp_lo : (1 : ℝ) / 4 ≤ p) (hp_hi : p ≤ 3 / 4) (hq_lo : (1 : ℝ) / 4 ≤ q) (hq_hi : q ≤ 3 / 4) : klDiv (bernoulliLaw p) (bernoulliLaw q) ≤ ofReal (4 * (p - q) ^ 2) := by have hp0 : 0 < p := by linarith have hp1 : p < 1 := by linarith have hq0 : 0 < q := by linarith have hq1 : q < 1 := by linarith have hac : bernoulliLaw p ≪ bernoulliLaw q := bernoulliLaw_ac_of_reference_interior hq0 hq1 have hint : Integrable (llr (bernoulliLaw p) (bernoulliLaw q)) (bernoulliLaw p) := bernoulliLaw_llr_integrable have hfinite : klDiv (bernoulliLaw p) (bernoulliLaw q) ≠ ⊤ := InformationTheory.klDiv_ne_top hac hint rw [← ENNReal.ofReal_toReal hfinite] exact ENNReal.ofReal_le_ofReal <| by rw [bernoulliLaw_klDiv_toReal hp0.le hp1.le hq0 hq1] exact bernoulli_kl_le_four_sq_sub_of_mem_quarter_band hp_lo hp_hi hq_lo hq_hi
Causalean.Mathlib.Probability.bernoulliLaw_klDiv_le_four_sq_sub · Causalean/Mathlib/Probability/BernoulliMeasure.lean:239 · uses bernoulliLaw
def bernoulliBool reviewed
Causalean.Mathlib.Probability

For any real number interpreted as a success parameter, the Boolean-valued Bernoulli measure assigns mass max⁡(p,0)\max(p,0) to true and mass max⁡(1−p,0)\max(1-p,0) to false.

Definition (Lean source)
p :
ℝ
bernoulliBool p :
ofReal p • Measure.dirac true + ofReal (1 - p) • Measure.dirac false
Causalean.Mathlib.Probability.bernoulliBool · Causalean/Mathlib/Probability/BernoulliMeasure.lean:274
def binomialWeight reviewed
Causalean.Mathlib.Probability

For a nonnegative number of trials, a real success parameter, and a nonnegative count, the binomial weight is (mj)pj(1−p)m−j\binom{m}{j}p^j(1-p)^{m-j}.

Definition (Lean source)
m :
p :
j :
binomialWeight m p j :
(Nat.choose m j : Real) * p ^ j * (1 - p) ^ (m - j)
Causalean.Mathlib.Probability.binomialWeight · Causalean/Mathlib/Probability/BernoulliMeasure.lean:351
17 supporting declarations (lemmas, instances)
  • bernoulliLaw_integral lemma — 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.
    p :
    ℝ
    hp0 :
    0 ≤ p
    hp1 :
    p ≤ 1
    f :
    ℝ → ℝ
    ∫ y, f y ∂(bernoulliLaw p) = p * f 1 + (1 - p) * f 0
    Proof (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)
    Causalean.Mathlib.Probability.bernoulliLaw_integral · Causalean/Mathlib/Probability/BernoulliMeasure.lean:42
  • bernoulliLaw_isProbabilityMeasure lemma — The custom bernoulliLaw is a probability measure for 0 ≤ p ≤ 1: its total mass is p + (1 - p) = 1.
    p :
    ℝ
    hp0 :
    0 ≤ p
    hp1 :
    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
    Causalean.Mathlib.Probability.bernoulliLaw_isProbabilityMeasure · Causalean/Mathlib/Probability/BernoulliMeasure.lean:61
  • bernoulliLaw_ae_nonneg lemma — The Bernoulli law on the real line is almost surely nonnegative, since all of its mass is placed at 0 and 1.
    p :
    ℝ
    0 ≤ᵐ[bernoulliLaw p] (fun y : ℝ => y)
    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
    Causalean.Mathlib.Probability.bernoulliLaw_ae_nonneg · Causalean/Mathlib/Probability/BernoulliMeasure.lean:74
  • bernoulliLaw_ae_le_one lemma — The Bernoulli law on the real line is almost surely at most one, since all of its mass is placed at 0 and 1.
    p :
    ℝ
    (fun y : ℝ => y) ≤ᵐ[bernoulliLaw p] fun _ => (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
    Causalean.Mathlib.Probability.bernoulliLaw_ae_le_one · Causalean/Mathlib/Probability/BernoulliMeasure.lean:87
  • bernoulliLaw_ae_zero_or_one lemma — A draw from the real-valued Bernoulli law is almost surely either 0 or 1.
    p :
    ℝ
    ∀ᵐ y ∂bernoulliLaw p, y = 0 ∨ y = 1
    Proof (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
    Causalean.Mathlib.Probability.bernoulliLaw_ae_zero_or_one · Causalean/Mathlib/Probability/BernoulliMeasure.lean:100
  • bernoulliLaw_ac_of_reference_interior lemma — A Bernoulli law is absolutely continuous with respect to any Bernoulli law whose success probability is strictly between zero and one.
    p q :
    ℝ
    hq0 :
    0 < q
    hq1 :
    q < 1
    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]
    Causalean.Mathlib.Probability.bernoulliLaw_ac_of_reference_interior · Causalean/Mathlib/Probability/BernoulliMeasure.lean:109
  • bernoulliLaw_llr_integrable lemma — The log-likelihood ratio between any two real-parameter Bernoulli laws is integrable under the first law.
    p q :
    ℝ
    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)
    Causalean.Mathlib.Probability.bernoulliLaw_llr_integrable · Causalean/Mathlib/Probability/BernoulliMeasure.lean:136
  • bernoulliLaw_lintegral_ofReal lemma — ℝ≥0∞/lintegral analogue of bernoulliLaw_integral: a Bernoulli law integrates an ℝ≥0∞-valued function as the two-point weighted sum.
    p :
    ℝ
    f :
    ℝ → ENNReal
    ∫⁻ y, f y ∂(bernoulliLaw p) = ofReal p * f 1 + ofReal (1 - p) * f 0
    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]
    Causalean.Mathlib.Probability.bernoulliLaw_lintegral_ofReal · Causalean/Mathlib/Probability/BernoulliMeasure.lean:265
  • measurable_bernoulliBool lemma — The Bool-valued Bernoulli distribution varies measurably with its success probability, so a measurable probability parameter can be used to construct a measurable kernel.
    Proof (Lean source)
    @[fun_prop] lemma measurable_bernoulliBool : Measurable bernoulliBool := by unfold bernoulliBool fun_prop
    Causalean.Mathlib.Probability.measurable_bernoulliBool · Causalean/Mathlib/Probability/BernoulliMeasure.lean:283
  • bernoulliBool_isProbabilityMeasure lemma — A Bool-valued Bernoulli distribution is a probability distribution whenever its success probability lies between zero and one.
    p :
    ℝ
    hp0 :
    0 ≤ p
    hp1 :
    p ≤ 1
    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
    Causalean.Mathlib.Probability.bernoulliBool_isProbabilityMeasure · Causalean/Mathlib/Probability/BernoulliMeasure.lean:290
  • bernoulliBool_integral lemma — 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.
    p :
    ℝ
    hp0 :
    0 ≤ p
    hp1 :
    p ≤ 1
    f :
    Bool → ℝ
    ∫ z, f z ∂bernoulliBool p = p * f true + (1 - p) * f false
    Proof (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)
    Causalean.Mathlib.Probability.bernoulliBool_integral · Causalean/Mathlib/Probability/BernoulliMeasure.lean:304
  • bernoulliBool_bind lemma — 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.
    β :
    p :
    ℝ
    K :
    Bool → Measure β
    (bernoulliBool p).bind K = ofReal p • K true + ofReal (1 - p) • K false
    Proof (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]
    Causalean.Mathlib.Probability.bernoulliBool_bind · Causalean/Mathlib/Probability/BernoulliMeasure.lean:322
  • bernoulliBool_map lemma — Transforming a Bool-valued Bernoulli draw produces a two-point distribution concentrated on the transformed success and failure values with their original probabilities.
    β :
    p :
    ℝ
    f :
    Bool → β
    = ofReal p • Measure.dirac (f true)
    + ofReal (1 - p) • Measure.dirac (f false)
    Proof (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]
    Causalean.Mathlib.Probability.bernoulliBool_map · Causalean/Mathlib/Probability/BernoulliMeasure.lean:334
  • sum_bernoulli_eq_binomial lemma — A Bernoulli-weighted sum of any function of the success count equals the corresponding sum against the binomial mass function.
    ι :
    p :
    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
    Proof (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
    Causalean.Mathlib.Probability.sum_bernoulli_eq_binomial · Causalean/Mathlib/Probability/BernoulliMeasure.lean:400
  • totalized_inverse_count_le lemma — The reciprocal of a positive integer, totalized to zero at the origin, is at most twice the reciprocal of its successor.
    j :
    (if 0 < j then (j : Real)⁻¹ else 0) ≤ 2 * ((j : Real) + 1)⁻¹
    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
    Causalean.Mathlib.Probability.totalized_inverse_count_le · Causalean/Mathlib/Probability/BernoulliMeasure.lean:425
  • binomial_totalized_inverse_count_le lemma — 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.
    m :
    p :
    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)
    Proof (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
    Causalean.Mathlib.Probability.binomial_totalized_inverse_count_le · Causalean/Mathlib/Probability/BernoulliMeasure.lean:445
  • binomial_inverse_complementary_counts_interior_le lemma — 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.
    m :
    p epsilon :
    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)
    Proof (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
    Causalean.Mathlib.Probability.binomial_inverse_complementary_counts_interior_le · Causalean/Mathlib/Probability/BernoulliMeasure.lean:528
Convergence­In­Distribution 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.

theorem const_mul_of_tendsto_const reviewed
MeasureTheory.TendstoInDistribution

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
Ω :
Type u_1
shared
ι :
Type u_2
shared
μ :
shared
l :
shared
l.IsCountablyGenerated
X :
ι → Ω → ℝ
Z :
Ω → ℝ
a :
ι → ℝ
a₀ :
ℝ
hXZ :
TendstoInDistribution X l Z (fun _ => μ) μ
ha :
Tendsto a l (𝓝 a₀)
TendstoInDistribution (fun n ω => a n * X n ω) l (fun ω => a₀ * Z ω) (fun _ => μ) μ
Proof (Lean source)
theorem TendstoInDistribution.const_mul_of_tendsto_const [IsProbabilityMeasure μ] [l.IsCountablyGenerated] {X : ι → Ω → ℝ} {Z : Ω → ℝ} {a : ι → ℝ} {a₀ : ℝ} (hXZ : TendstoInDistribution X l Z (fun _ => μ) μ) (ha : Tendsto a l (𝓝 a₀)) : TendstoInDistribution (fun n ω => a n * X n ω) l (fun ω => a₀ * Z ω) (fun _ => μ) μ := by have hY : TendstoInMeasure μ (fun n => fun _ : Ω => a n) l (fun _ => a₀) := tendstoInMeasure_const_of_tendsto (μ := μ) ha have hY_meas : ∀ n, AEMeasurable (fun _ : Ω => a n) μ := by intro n fun_prop simpa using (hXZ.continuous_comp_prodMk_of_tendstoInMeasure_const (g := fun p : ℝ × ℝ => p.2 * p.1) (by fun_prop) hY hY_meas)
MeasureTheory.TendstoInDistribution.const_mul_of_tendsto_const · Causalean/Mathlib/Probability/ConvergenceInDistribution.lean:57
theorem tendsto_map_mul_of_tendsto reviewed
MeasureTheory.ProbabilityMeasure

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
ι :
Type*
a :
ι → ℝ
a₀ :
ℝ
hν :
Tendsto νs l (𝓝 ν)
ha :
Tendsto a l (𝓝 a₀)
Tendsto (fun i => (νs i).map ((measurable_const.mul measurable_id).aemeasurable : AEMeasurable (fun x : ℝ => a i * x) (νs i : Measure ℝ))) l (𝓝 (ν.map ((measurable_const.mul measurable_id).aemeasurable : AEMeasurable (fun x : ℝ => a₀ * x) (ν : Measure ℝ))))
Proof (Lean source)
theorem tendsto_map_mul_of_tendsto {ι : Type*} {l : Filter ι} {νs : ι → ProbabilityMeasure ℝ} {ν : ProbabilityMeasure ℝ} {a : ι → ℝ} {a₀ : ℝ} (hν : Tendsto νs l (𝓝 ν)) (ha : Tendsto a l (𝓝 a₀)) : Tendsto (fun i => (νs i).map ((measurable_const.mul measurable_id).aemeasurable : AEMeasurable (fun x : ℝ => a i * x) (νs i : Measure ℝ))) l (𝓝 (ν.map ((measurable_const.mul measurable_id).aemeasurable : AEMeasurable (fun x : ℝ => a₀ * x) (ν : Measure ℝ)))) := by let mulMap : ℝ × ℝ → ℝ := fun p => p.1 * p.2 have hdirac : Tendsto (fun i => diracProba (a i)) l (𝓝 (diracProba a₀)) := (continuous_diracProba.tendsto a₀).comp ha have hprod : Tendsto (fun i => (diracProba (a i)).prod (νs i)) l (𝓝 ((diracProba a₀).prod ν)) := by exact (continuous_prod.tendsto (diracProba a₀, ν)).comp (hdirac.prodMk_nhds hν) have hmap : Tendsto (fun i => ((diracProba (a i)).prod (νs i)).map ((by fun_prop : Measurable mulMap).aemeasurable)) l (𝓝 (((diracProba a₀).prod ν).map ((by fun_prop : Measurable mulMap).aemeasurable))) := by exact tendsto_map_of_tendsto_of_continuous _ _ hprod (by fun_prop : Continuous mulMap) simpa [mulMap, map_mul_eq_map_prod_dirac] using hmap
MeasureTheory.ProbabilityMeasure.tendsto_map_mul_of_tendsto · Causalean/Mathlib/Probability/ConvergenceInDistribution.lean:97
2 supporting declarations (lemmas, instances)
  • tendstoInMeasure_const_of_tendsto lemma — 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.
    Ω :
    Type u_1
    shared
    ι :
    Type u_2
    shared
    μ :
    shared
    l :
    shared
    E :
    Type*
    ι → E
    E
    ha :
    Tendsto a l (𝓝 a₀)
    TendstoInMeasure μ (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
    MeasureTheory.tendstoInMeasure_const_of_tendsto · Causalean/Mathlib/Probability/ConvergenceInDistribution.lean:36
  • map_mul_eq_map_prod_dirac lemma — Multiplying a deterministic real value and a random draw has the same distribution as scaling that random draw by the deterministic value.
    c :
    ℝ
    ((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 ℝ))
    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
    MeasureTheory.ProbabilityMeasure.map_mul_eq_map_prod_dirac · Causalean/Mathlib/Probability/ConvergenceInDistribution.lean:79
Covariance­Cauchy­Schwarz 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.

theorem abs_covariance_le_sqrt_mul reviewed
Causalean.Mathlib

Cauchy–Schwarz for covariance. Under a finite measure, if XX is square-integrable and YY is square-integrable, then the absolute value of their covariance is at most the product of their standard deviations, ∣Cov(X,Y)∣≤Var(X)⋅Var(Y)|\mathrm{Cov}(X,Y)| \le \sqrt{\mathrm{Var}(X)} \cdot \sqrt{\mathrm{Var}(Y)}.

Formal statement
Ω :
shared
X Y :
Ω → ℝ
hX :
MemLp X 2 μ
hY :
MemLp Y 2 μ
|covariance X Y μ| ≤ sqrt (variance X μ) * sqrt (variance Y μ)
Proof (Lean source)
theorem abs_covariance_le_sqrt_mul [IsFiniteMeasure μ] {X Y : Ω → ℝ} (hX : MemLp X 2 μ) (hY : MemLp Y 2 μ) : |covariance X Y μ| ≤ sqrt (variance X μ) * sqrt (variance Y μ) := by have h := covariance_sq_le_variance_mul hX hY rw [← Real.sqrt_mul (variance_nonneg X μ), ← Real.sqrt_sq_eq_abs] exact Real.sqrt_le_sqrt h
Causalean.Mathlib.abs_covariance_le_sqrt_mul · Causalean/Mathlib/Probability/CovarianceCauchySchwarz.lean:72
1 supporting declaration (lemmas, instances)
Event­Selected­Mixture 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.

def eventSelectedMixture reviewed
Causalean.Mathlib.Probability

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.

Definition (Lean source)
J E :
Type*
A :
Set J
P H :
E → Real
z :
J × E
eventSelectedMixture A P H z :
(fst ⁻¹' A).indicator (fun z ↦ P z.2) z
+ (fst ⁻¹' A)ᶜ.indicator (fun z ↦ H z.2) z
Causalean.Mathlib.Probability.eventSelectedMixture · Causalean/Mathlib/Probability/EventSelectedMixture.lean:43
lemma variance_eventSelectedMixture reviewed
Causalean.Mathlib.Probability

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
μJ :
μE :
A :
Set J
hA :
P H :
E → Real
hP :
MemLp P 2 μE
hH :
MemLp H 2 μE
Var[eventSelectedMixture A P H; μJ.prod μE]
= μJ.real A * Var[P; μE]
+ (1 - μJ.real A) * Var[H; μE]
+ μJ.real A * (1 - μJ.real A) * ((∫ e, P e ∂μE) - ∫ e, H e ∂μE) ^ 2
Proof (Lean source)
lemma variance_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) : Var[eventSelectedMixture A P H; μJ.prod μE] = μJ.real A * Var[P; μE] + (1 - μJ.real A) * Var[H; μE] + μJ.real A * (1 - μJ.real A) * ((∫ e, P e ∂μE) - ∫ e, H e ∂μE) ^ 2 := by rw [variance_eq_sub (memLp_eventSelectedMixture μJ μE A hA P H hP hH)] change (∫ z, eventSelectedMixture A P H z ^ 2 ∂μJ.prod μE) - (∫ z, eventSelectedMixture A P H z ∂μJ.prod μE) ^ 2 = _ rw [ integral_eventSelectedMixture_sq μJ μE A hA P H hP hH, integral_eventSelectedMixture μJ μE A hA P H (hP.integrable one_le_two) (hH.integrable one_le_two), variance_eq_sub hP, variance_eq_sub hH] simp only [Pi.pow_apply] ring
Causalean.Mathlib.Probability.variance_eventSelectedMixture · Causalean/Mathlib/Probability/EventSelectedMixture.lean:135 · uses eventSelectedMixture
4 supporting declarations (lemmas, instances)
Finite­Cell­Conditional­Moment­Bridge 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.

def normalizedRestrict reviewed
Causalean.Mathlib.Probability

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)
Ω :
P :
C :
Set Ω
normalizedRestrict P C :
(P C)⁻¹ • P.restrict C
Causalean.Mathlib.Probability.normalizedRestrict · Causalean/Mathlib/Probability/FiniteCellConditionalMomentBridge.lean:29
def normalizedRestrictedIntegral reviewed
Causalean.Mathlib.Probability

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)
P :
C :
Set Ω
f :
Ω → E
normalizedRestrictedIntegral P C f :
E
∫ ω, f ω ∂normalizedRestrict P C
Causalean.Mathlib.Probability.normalizedRestrictedIntegral · Causalean/Mathlib/Probability/FiniteCellConditionalMomentBridge.lean:41
lemma eventCondExp_eq_sum_condProb_mul_eventCondExp reviewed
Causalean.Mathlib.Probability

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
Ω :
Type u_1
shared
ι :
Type*
μ :
A :
Set Ω
C :
ι → Set Ω
hAmeas :
hCmeas :
∀ i, MeasurableSet (C i)
hdisj :
Pairwise (onFun Disjoint C)
hcov :
(⋃ i, C i) = univ
hAC_fin :
∀ i, μ (A ∩ C i) ≠ ⊤
f :
Ω → ℝ
hf :
= ∑ i, (μ (A ∩ C i)).toReal / (μ A).toReal * normalizedRestrictedIntegral μ (A ∩ C i) f
Proof (Lean source)
lemma eventCondExp_eq_sum_condProb_mul_eventCondExp {ι : Type*} [Fintype ι] (μ : Measure Ω) (A : Set Ω) (C : ι → Set Ω) (hAmeas : MeasurableSet A) (hCmeas : ∀ i, MeasurableSet (C i)) (hdisj : Pairwise (onFun Disjoint C)) (hcov : (⋃ i, C i) = univ) (hAC_fin : ∀ i, μ (A ∩ C i) ≠ ⊤) (f : Ω → ℝ) (hf : Integrable f μ) : normalizedRestrictedIntegral μ A f = ∑ i, (μ (A ∩ C i)).toReal / (μ A).toReal * normalizedRestrictedIntegral μ (A ∩ C i) f := by have hAC_meas : ∀ i, MeasurableSet (A ∩ C i) := fun i => hAmeas.inter (hCmeas i) have hAC_disj : Pairwise (onFun Disjoint (fun i => A ∩ C i)) := by intro i j hij exact (hdisj hij).mono Set.inter_subset_right Set.inter_subset_right have hAC_cov : (⋃ i, A ∩ C i) = A := by rw [← Set.inter_iUnion, hcov, Set.inter_univ] have hsplit : ∫ ω in A, f ω ∂μ = ∑ i, ∫ ω in A ∩ C i, f ω ∂μ := by have h := MeasureTheory.integral_iUnion_fintype hAC_meas hAC_disj (fun _ => hf.integrableOn) rwa [hAC_cov] at h have hcell : ∀ i, ∫ ω in A ∩ C i, f ω ∂μ = (μ (A ∩ C i)).toReal * normalizedRestrictedIntegral μ (A ∩ C i) f := by intro i rw [mul_comm, ← eventCondExp_mul_measure_toReal μ (A ∩ C i) (hAC_fin i) f] have hLHS : normalizedRestrictedIntegral μ A f = (∫ ω in A, f ω ∂μ) / (μ A).toReal := eventCondExp_eq μ A f rw [hLHS, hsplit, Finset.sum_div] refine Finset.sum_congr rfl (fun i _ => ?_) rw [hcell i, mul_div_right_comm]
Causalean.Mathlib.Probability.eventCondExp_eq_sum_condProb_mul_eventCondExp · Causalean/Mathlib/Probability/FiniteCellConditionalMomentBridge.lean:101 · uses normalizedRestrictedIntegral
def BoundedTestFactorization reviewed
Causalean.Mathlib.Probability

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)
μ :
X :
Ω → S
Y :
Ω → T
φ :
S → ℝ
ψ :
T → ℝ
(∃ K : ℝ, ∀ x, |φ x| ≤ K)
(∃ L : ℝ, ∀ y, |ψ y| ≤ L)
BoundedTestFactorization μ X Y :
Prop
(∫ ω, φ (X ω) * ψ (Y ω) ∂μ) = (∫ ω, φ (X ω) ∂μ) * (∫ ω, ψ (Y ω) ∂μ)
Causalean.Mathlib.Probability.BoundedTestFactorization · Causalean/Mathlib/Probability/FiniteCellConditionalMomentBridge.lean:272
def NormalizedRestrictedBoundedTestFactorization reviewed
Causalean.Mathlib.Probability

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)
P :
C :
Set Ω
X :
Ω → S
Y :
Ω → T
NormalizedRestrictedBoundedTestFactorization P C X Y :
Prop
Causalean.Mathlib.Probability.NormalizedRestrictedBoundedTestFactorization · Causalean/Mathlib/Probability/FiniteCellConditionalMomentBridge.lean:290
def firstMomentVector reviewed
Causalean.Mathlib.Probability

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)
Ω :
n :
ℕ
μ :
X :
Ω → Fin n → ℝ
firstMomentVector μ X :
Fin n → ℝ
fun i => ∫ ω, X ω i ∂μ
Causalean.Mathlib.Probability.firstMomentVector · Causalean/Mathlib/Probability/FiniteCellConditionalMomentBridge.lean:350
def crossMomentMatrix reviewed
Causalean.Mathlib.Probability

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.

Definition (Lean source)
Ω :
m n :
ℕ
μ :
X :
Ω → Fin m → ℝ
Y :
Ω → Fin n → ℝ
crossMomentMatrix μ X Y :
Matrix (Fin m) (Fin n) ℝ
fun i j => ∫ ω, X ω i * Y ω j ∂μ
Causalean.Mathlib.Probability.crossMomentMatrix · Causalean/Mathlib/Probability/FiniteCellConditionalMomentBridge.lean:362
theorem normalizedRestricted_crossMomentMatrix_eq_outer reviewed
Causalean.Mathlib.Probability

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
Ω :
C :
Set Ω
hC :
hCpos :
0 < P C
m n :
ℕ
Ω → Fin m → ℝ
Ω → Fin n → ℝ
hX :
hY :
hXint :
∀ i, Integrable (fun ω => X ω i) (normalizedRestrict P C)
hYint :
∀ j, Integrable (fun ω => Y ω j) (normalizedRestrict P C)
Proof (Lean source)
theorem normalizedRestricted_crossMomentMatrix_eq_outer {Ω : 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) : crossMomentMatrix (normalizedRestrict P C) X Y = vecMulVec (firstMomentVector (normalizedRestrict P C) X) (firstMomentVector (normalizedRestrict P C) Y) := by ext i j exact (normalizedRestricted_coordinate_factorization hC hCpos hX hY hXint hYint hfactor i j).2
16 supporting declarations (lemmas, instances)
Finite­Markov­Oscillation 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.

def markovOperator reviewed
Causalean.Mathlib.Probability.FiniteMarkovOscillation

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)
S :
Type*
P :
S → S → ℝ
f :
S → ℝ
s :
S
markovOperator P f s :
ℝ
∑ s', P s s' * f s'
Causalean.Mathlib.Probability.FiniteMarkovOscillation.markovOperator · Causalean/Mathlib/Probability/FiniteMarkovOscillation.lean:22
def markovOperatorIter reviewed
Causalean.Mathlib.Probability.FiniteMarkovOscillation

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)
S :
Type*
P :
S → S → ℝ
markovOperatorIter P :
Nat → (S → ℝ) → S → ℝ
clause 1
| 0, f => f
clause 2
| n + 1, f => markovOperator P (markovOperatorIter P n f)
Causalean.Mathlib.Probability.FiniteMarkovOscillation.markovOperatorIter · Causalean/Mathlib/Probability/FiniteMarkovOscillation.lean:29
def OscillationBound reviewed
Causalean.Mathlib.Probability.FiniteMarkovOscillation

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)
S :
Type*
B :
ℝ
f :
S → ℝ
x y :
OscillationBound B f :
Prop
|f x - f y| ≤ B
Causalean.Mathlib.Probability.FiniteMarkovOscillation.OscillationBound · Causalean/Mathlib/Probability/FiniteMarkovOscillation.lean:43
lemma oscillationBound_markovOperatorIter reviewed
Causalean.Mathlib.Probability.FiniteMarkovOscillation

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
S :
Type*
Nonempty S
P :
S → S → ℝ
hP :
∀ s, IsProbabilityVector (P s)
alpha B :
ℝ
halpha :
0 ≤ alpha
hcontract :
∀ p q
then
(1 / 2 : ℝ) * ∑ s, |markovStep p P s - markovStep q P s|
≤ alpha * ((1 / 2 : ℝ) * ∑ s, |p s - q s|)
f :
S → ℝ
hf :
n :
OscillationBound (alpha ^ n * B) (markovOperatorIter P n f)
Proof (Lean source)
lemma oscillationBound_markovOperatorIter {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) (n : Nat) : OscillationBound (alpha ^ n * B) (markovOperatorIter P n f) := by induction n with | zero => simpa [markovOperatorIter] using hf | succ n ih => simpa [markovOperatorIter, pow_succ, mul_assoc, mul_left_comm, mul_comm] using oscillationBound_markovOperator P hP halpha hcontract ih
Causalean.Mathlib.Probability.FiniteMarkovOscillation.oscillationBound_markovOperatorIter · Causalean/Mathlib/Probability/FiniteMarkovOscillation.lean:224 · uses IsProbabilityVector , markovStep , OscillationBound , markovOperatorIter
def nonemptyOfProbabilityVector reviewed
Causalean.Mathlib.Probability.FiniteMarkovOscillation

Given a real vector on a finite carrier that is a probability vector, the carrier is nonempty.

Definition (Lean source)
S :
Type*
p :
S → ℝ
nonemptyOfProbabilityVector p hp :
Nonempty S
by classical by_contra hempty haveI : IsEmpty S := not_nonempty_iff.mp hempty have := hp.2 simpa using this
Causalean.Mathlib.Probability.FiniteMarkovOscillation.nonemptyOfProbabilityVector · Causalean/Mathlib/Probability/FiniteMarkovOscillation.lean:250 · uses IsProbabilityVector
8 supporting declarations (lemmas, instances)
  • markovOperatorIter_succ lemma — For a finite transition matrix, a step count, and a function, the successor iterate is one backward Markov step after the preceding iterate.
    S :
    Type*
    P :
    S → S → ℝ
    n :
    f :
    S → ℝ
    Proof (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
    Causalean.Mathlib.Probability.FiniteMarkovOscillation.markovOperatorIter_succ · Causalean/Mathlib/Probability/FiniteMarkovOscillation.lean:36
  • oscillationBound_nonneg lemma — If a function has an oscillation bound, that bound is nonnegative.
    S :
    Type*
    Nonempty S
    B :
    ℝ
    f :
    S → ℝ
    0 ≤ B
    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
    Causalean.Mathlib.Probability.FiniteMarkovOscillation.oscillationBound_nonneg · Causalean/Mathlib/Probability/FiniteMarkovOscillation.lean:48
  • abs_sum_sub_mul_le_oscillation_halfL1 lemma — 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.
    S :
    Type*
    Nonempty S
    S → ℝ
    B :
    ℝ
    f :
    S → ℝ
    hf :
    |∑ 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
    Causalean.Mathlib.Probability.FiniteMarkovOscillation.abs_sum_sub_mul_le_oscillation_halfL1 · Causalean/Mathlib/Probability/FiniteMarkovOscillation.lean:54
  • probability_complex_mean_tv_diameter lemma — 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.
    S :
    Type*
    Nonempty S
    S → ℝ
    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|)
    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)
    Causalean.Mathlib.Probability.FiniteMarkovOscillation.probability_complex_mean_tv_diameter · Causalean/Mathlib/Probability/FiniteMarkovOscillation.lean:100
  • isProbabilityVector_indicator lemma — For a state, its point mass is a finite probability vector.
    S :
    x :
    S
    IsProbabilityVector (fun y : S ↦ if y = x then 1 else 0)
    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
    Causalean.Mathlib.Probability.FiniteMarkovOscillation.isProbabilityVector_indicator · Causalean/Mathlib/Probability/FiniteMarkovOscillation.lean:144
  • halfL1_indicator_sub_indicator_le_one lemma — For two states, half the ℓ¹ distance between their point masses is at most one.
    S :
    x y :
    S
    (1 / 2 : ℝ) * ∑ z, |(if z = x then 1 else 0) - (if z = y then 1 else 0)| ≤ 1
    Proof (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
    Causalean.Mathlib.Probability.FiniteMarkovOscillation.halfL1_indicator_sub_indicator_le_one · Causalean/Mathlib/Probability/FiniteMarkovOscillation.lean:152
  • oscillationBound_markovOperator lemma — 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.
    S :
    Type*
    Nonempty S
    P :
    S → S → ℝ
    hP :
    ∀ s, IsProbabilityVector (P s)
    alpha B :
    ℝ
    halpha :
    0 ≤ alpha
    hcontract :
    ∀ p q
    then
    (1 / 2 : ℝ) * ∑ s, |markovStep p P s - markovStep q P s|
    ≤ alpha * ((1 / 2 : ℝ) * ∑ s, |p s - q s|)
    f :
    S → ℝ
    hf :
    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 _ _
    Causalean.Mathlib.Probability.FiniteMarkovOscillation.oscillationBound_markovOperator · Causalean/Mathlib/Probability/FiniteMarkovOscillation.lean:181
  • mono lemma — If a function has oscillation at most A and A is at most B, the function has oscillation at most B.
    S :
    Type*
    A B :
    ℝ
    f :
    S → ℝ
    hf :
    hAB :
    A ≤ B
    Proof (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
    Causalean.Mathlib.Probability.FiniteMarkovOscillation.OscillationBound.mono · Causalean/Mathlib/Probability/FiniteMarkovOscillation.lean:244
Finite­Markov­Perturbation 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.

lemma stochastic_moment_error reviewed
Causalean.Mathlib.Probability.FiniteMarkovPerturbation

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
S :
Type*
Matrix S S ℝ
p q r s :
S → ℝ
hr :
∀ i, r i ∈ Icc (0 : ℝ) 1
εν εP εr :
ℝ
hpq :
(1 / 2 : ℝ) * ∑ i, |p i - q i| ≤ εν
hPQ :
∀ i, (1 / 2 : ℝ) * ∑ j, |P i j - Q i j| ≤ εP
hrs :
∀ i, |r i - s i| ≤ εr
k :
|(∑ i, (vecMul p (P ^ k)) i * r i) - ∑ i, (vecMul q (Q ^ k)) i * s i|
≤ εν + (k : ℝ) * εP + εr
Proof (Lean source)
lemma stochastic_moment_error {S : Type*} [Fintype S] [DecidableEq S] {P Q : Matrix S S ℝ} (hP : IsStochasticMatrix P) (hQ : IsStochasticMatrix Q) {p q r s : S → ℝ} (hp : IsProbabilityVector p) (hq : IsProbabilityVector q) (hr : ∀ i, r i ∈ Icc (0 : ℝ) 1) {εν εP εr : ℝ} (hpq : (1 / 2 : ℝ) * ∑ i, |p i - q i| ≤ εν) (hPQ : ∀ i, (1 / 2 : ℝ) * ∑ j, |P i j - Q i j| ≤ εP) (hrs : ∀ i, |r i - s i| ≤ εr) (k : Nat) : |(∑ i, (vecMul p (P ^ k)) i * r i) - ∑ i, (vecMul q (Q ^ k)) i * s i| ≤ εν + (k : ℝ) * εP + εr := by letI : Nonempty S := nonemptyOfProbabilityVector p hp 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 : |(∑ i, p i * ((P ^ k).mulVec r) i) - ∑ i, q i * ((P ^ k).mulVec r) i| ≤ εν := by rw [← Finset.sum_sub_distrib] simpa only [sub_mul] using (abs_sum_sub_mul_le_oscillation_halfL1 hp hq hosc).trans (by simpa using hpq) have he := probability_mean_error hq (stochastic_power_reward_error hP hQ hr hPQ hrs k) have hdot (v f : S → ℝ) (R : Matrix S S ℝ) : (∑ i, (vecMul v R) i * f i) = ∑ i, v i * (R.mulVec f) i := by exact Matrix.dotProduct_mulVec v R f |>.symm rw [hdot, hdot] calc _ ≤ |(∑ i, p i * ((P ^ k).mulVec r) i) - ∑ i, q i * ((P ^ k).mulVec r) i| + |(∑ i, q i * ((P ^ k).mulVec r) i) - ∑ i, q i * ((Q ^ k).mulVec s) i| := abs_sub_le _ _ _ _ ≤ εν + ((k : ℝ) * εP + εr) := add_le_add ht he _ = _ := by ring
Causalean.Mathlib.Probability.FiniteMarkovPerturbation.stochastic_moment_error · Causalean/Mathlib/Probability/FiniteMarkovPerturbation.lean:101 · uses IsProbabilityVector , IsStochasticMatrix
4 supporting declarations (lemmas, instances)
  • probability_mean_unit lemma — A probability-weighted mean of values in the unit interval remains in the unit interval.
    S :
    Type*
    S → ℝ
    hf :
    ∀ i, f i ∈ Icc (0 : ℝ) 1
    (∑ i, p i * f i) ∈ Icc (0 : ℝ) 1
    Proof (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
    Causalean.Mathlib.Probability.FiniteMarkovPerturbation.probability_mean_unit · Causalean/Mathlib/Probability/FiniteMarkovPerturbation.lean:19
  • probability_mean_error lemma — Averaging under a probability vector cannot increase a uniform pointwise error, so the two weighted means differ by at most that error.
    S :
    Type*
    S → ℝ
    ε :
    ℝ
    hfg :
    ∀ i, |f i - g i| ≤ ε
    |(∑ 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]
    Causalean.Mathlib.Probability.FiniteMarkovPerturbation.probability_mean_error · Causalean/Mathlib/Probability/FiniteMarkovPerturbation.lean:32
  • stochastic_power_reward_unit lemma — Every iterate count of a stochastic transition matrix sends a unit-range reward to another unit-range function.
    S :
    Type*
    Matrix S S ℝ
    r :
    S → ℝ
    hr :
    ∀ i, r i ∈ Icc (0 : ℝ) 1
    k :
    i :
    ((P ^ k).mulVec r) i ∈ Icc (0 : ℝ) 1
    Proof (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
    Causalean.Mathlib.Probability.FiniteMarkovPerturbation.stochastic_power_reward_unit · Causalean/Mathlib/Probability/FiniteMarkovPerturbation.lean:48
  • stochastic_power_reward_error lemma — 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.
    S :
    Type*
    Matrix S S ℝ
    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 :
    i :
    |((P ^ k).mulVec r) i - ((Q ^ k).mulVec s) i| ≤ (k : ℝ) * εP + εr
    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
    Causalean.Mathlib.Probability.FiniteMarkovPerturbation.stochastic_power_reward_error · Causalean/Mathlib/Probability/FiniteMarkovPerturbation.lean:61
Finite­Partition­Conditional 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.

theorem measure_le_of_cond_le_on_finite_partition reviewed
Causalean.Mathlib.Probability

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
Ω ι :
C :
ι → Set Ω
hC :
∀ i, MeasurableSet (C i)
hdisj :
∀ i j
if
i ≠ j
then
Disjoint (C i) (C j)
hcover :
(⋃ i, C i) = univ
E :
Set Ω
hE :
β :
ℝ≥0∞
hcond :
∀ i
if
μ (C i) ≠ 0
then
μ[E | C i] ≤ β
μ E ≤ β
Proof (Lean source)
theorem measure_le_of_cond_le_on_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) (β : ℝ≥0∞) (hcond : ∀ i, μ (C i) ≠ 0 → μ[E | C i] ≤ β) : μ E ≤ β := by -- Insert the exact finite sum, bound positive cells by `β`, and use that cell masses sum to one. rw [measure_eq_sum_mul_cond_of_finite_partition μ C hC hdisj hcover E hE] calc ∑ i, μ (C i) * μ[E | C i] ≤ ∑ i, μ (C i) * β := by apply Finset.sum_le_sum intro i _ by_cases hzero : μ (C i) = 0 · simp [hzero] · simpa [mul_comm] using mul_le_mul_left (hcond i hzero) (μ (C i)) _ = (∑ i, μ (C i)) * β := by rw [Finset.sum_mul] _ = 1 * β := by have hmass : ∑ i, μ (C i) = 1 := by simpa only [hcover, measure_univ, tsum_fintype] using (measure_iUnion (μ := μ) (fun i j hij ↦ hdisj i j hij) hC).symm rw [hmass] _ = β := one_mul β
Causalean.Mathlib.Probability.measure_le_of_cond_le_on_finite_partition · Causalean/Mathlib/Probability/FinitePartitionConditional.lean:50
1 supporting declaration (lemmas, instances)
  • measure_eq_sum_mul_cond_of_finite_partition theorem — 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.
    Ω ι :
    C :
    ι → Set Ω
    hC :
    ∀ i, MeasurableSet (C i)
    hdisj :
    ∀ i j
    if
    i ≠ j
    then
    Disjoint (C i) (C j)
    hcover :
    (⋃ i, C i) = univ
    E :
    Set Ω
    hE :
    μ 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]
    Causalean.Mathlib.Probability.measure_eq_sum_mul_cond_of_finite_partition · Causalean/Mathlib/Probability/FinitePartitionConditional.lean:22
Gaussian­Moments 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)`.

lemma gaussianReal_Ioi_eq reviewed
Causalean.Mathlib

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
m :
ℝ
v :
ℝ≥0
hv :
v ≠ 0
c :
ℝ
((gaussianReal m v) (Ioi c)).toReal = 1 - stdNormalCDF ((c - m) / sqrt (v : ℝ))
Proof (Lean source)
lemma gaussianReal_Ioi_eq (m : ℝ) (v : ℝ≥0) (hv : v ≠ 0) (c : ℝ) : ((gaussianReal m v) (Ioi c)).toReal = 1 - stdNormalCDF ((c - m) / sqrt (v : ℝ)) := by let s : ℝ := sqrt (v : ℝ) let t : ℝ := (c - m) / s have hvpos_nn : (0 : ℝ≥0) < v := by exact bot_lt_iff_ne_bot.mpr hv have hvpos : 0 < (v : ℝ) := by exact_mod_cast hvpos_nn have hspos : 0 < s := by dsimp [s] exact Real.sqrt_pos.2 hvpos have hpre : (fun z : ℝ => s * z + m) ⁻¹' Ioi c = Ioi t := by simpa [t] using affine_preimage_Ioi (s := s) (c := c) (m := m) hspos calc ((gaussianReal m v) (Ioi c)).toReal = (((gaussianReal 0 1).map (fun z : ℝ => s * z + m)) (Ioi c)).toReal := by rw [gaussianReal_eq_map_std m v] _ = ((gaussianReal 0 1) (Ioi t)).toReal := by rw [Measure.map_apply] · rw [hpre] · exact (continuous_const.mul continuous_id |>.add continuous_const).measurable · exact measurableSet_Ioi _ = ∫ x in Ioi t, stdNormalPDF x := stdNormalMeasure_Ioi_toReal_eq_integral t _ = 1 - stdNormalCDF t := integral_Ioi_stdNormalPDF t _ = 1 - stdNormalCDF ((c - m) / sqrt (v : ℝ)) := by rfl
Causalean.Mathlib.gaussianReal_Ioi_eq · Causalean/Mathlib/Probability/GaussianMoments.lean:147 · uses stdNormalCDF
lemma integral_Ioi_id_gaussianReal reviewed
Causalean.Mathlib

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
m :
ℝ
v :
ℝ≥0
hv :
v ≠ 0
c :
ℝ
∫ y in Ioi c, y ∂(gaussianReal m v)
= m * (1 - stdNormalCDF ((c - m) / sqrt (v : ℝ)))
+ sqrt (v : ℝ) * stdNormalPDF ((c - m) / sqrt (v : ℝ))
Proof (Lean source)
lemma integral_Ioi_id_gaussianReal (m : ℝ) (v : ℝ≥0) (hv : v ≠ 0) (c : ℝ) : ∫ y in Ioi c, y ∂(gaussianReal m v) = m * (1 - stdNormalCDF ((c - m) / sqrt (v : ℝ))) + sqrt (v : ℝ) * stdNormalPDF ((c - m) / sqrt (v : ℝ)) := by let s : ℝ := sqrt (v : ℝ) let t : ℝ := (c - m) / s have hvpos_nn : (0 : ℝ≥0) < v := by exact bot_lt_iff_ne_bot.mpr hv have hvpos : 0 < (v : ℝ) := by exact_mod_cast hvpos_nn have hspos : 0 < s := by dsimp [s] exact Real.sqrt_pos.2 hvpos have hpre : (fun z : ℝ => s * z + m) ⁻¹' Ioi c = Ioi t := by simpa [t] using affine_preimage_Ioi (s := s) (c := c) (m := m) hspos calc ∫ y in Ioi c, y ∂(gaussianReal m v) = ∫ y in Ioi c, y ∂Measure.map (fun z : ℝ => s * z + m) (gaussianReal 0 1) := by rw [gaussianReal_eq_map_std m v] _ = ∫ z in (fun z : ℝ => s * z + m) ⁻¹' Ioi c, (s * z + m) ∂(gaussianReal 0 1) := by rw [setIntegral_map] · exact measurableSet_Ioi · exact continuous_id.aestronglyMeasurable · exact (continuous_const.mul continuous_id |>.add continuous_const).measurable.aemeasurable _ = ∫ z in Ioi t, (s * z + m) ∂(gaussianReal 0 1) := by rw [hpre] _ = ∫ z in Ioi t, gaussianPDFReal 0 1 z * (s * z + m) := integral_Ioi_affine_gaussianReal_eq_density s m t _ = s * (∫ z in Ioi t, z * stdNormalPDF z) + m * (∫ z in Ioi t, stdNormalPDF z) := integral_Ioi_affine_stdNormal s m t _ = s * stdNormalPDF t + m * (1 - stdNormalCDF t) := by rw [integral_Ioi_id_mul_stdNormalPDF, integral_Ioi_stdNormalPDF] _ = m * (1 - stdNormalCDF ((c - m) / sqrt (v : ℝ))) + sqrt (v : ℝ) * stdNormalPDF ((c - m) / sqrt (v : ℝ)) := by dsimp [s, t] ring
Causalean.Mathlib.integral_Ioi_id_gaussianReal · Causalean/Mathlib/Probability/GaussianMoments.lean:177 · uses stdNormalCDF , stdNormalPDF
6 supporting declarations (lemmas, instances)
Gaussian­Weighted­Sum 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.

theorem map_weighted_sum_gaussian reviewed
Causalean.Mathlib

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
Ω :
Type u_1
shared
n :
ℕ
ξ :
Fin n → Ω → ℝ
hindep :
iIndepFun ξ μ
hmeas :
∀ i, Measurable (ξ i)
hlaw :
∀ i, μ.map (ξ i) = gaussianReal 0 1
a :
Fin n → ℝ
μ.map (fun ω => ∑ i, a i * ξ i ω) = gaussianReal 0 ⟨∑ i, (a i) ^ 2, by positivity⟩
Proof (Lean source)
theorem map_weighted_sum_gaussian {n : ℕ} (ξ : Fin n → Ω → ℝ) (hindep : iIndepFun ξ μ) (hmeas : ∀ i, Measurable (ξ i)) (hlaw : ∀ i, μ.map (ξ i) = gaussianReal 0 1) (a : Fin n → ℝ) : μ.map (fun ω => ∑ i, a i * ξ i ω) = gaussianReal 0 ⟨∑ i, (a i) ^ 2, by positivity⟩ := by -- The summands `g i ω = a i * ξ i ω`. set g : Fin n → Ω → ℝ := fun i ω => a i * ξ i ω with hg -- Each summand is measurable, independent, and Gaussian with variance `(a i)²`. have hg_meas : ∀ i, Measurable (g i) := fun i => (hmeas i).const_mul (a i) have hg_indep : iIndepFun g μ := by have : g = fun i => (fun x => a i * x) ∘ ξ i := by funext i ω; simp [hg, comp] rw [this] exact hindep.comp _ (fun i => measurable_const_mul (a i)) have hg_law : ∀ i, μ.map (g i) = gaussianReal 0 ⟨(a i) ^ 2, sq_nonneg _⟩ := by intro i have hgi : g i = (fun x => a i * x) ∘ ξ i := rfl have hmap : μ.map (g i) = (gaussianReal 0 1).map (fun x => a i * x) := by rw [hgi, ← Measure.map_map (measurable_const_mul (a i)) (hmeas i), hlaw i] rw [hmap, gaussianReal_map_const_mul (a i)] congr 1 · ring · ext; simp; rfl -- General `Finset`-indexed statement, then specialise to `univ`. have key : ∀ s : Finset (Fin n), μ.map (fun ω => ∑ i ∈ s, g i ω) = gaussianReal 0 ⟨∑ i ∈ s, (a i) ^ 2, by positivity⟩ := by intro s induction s using Finset.induction with | empty => simp only [Finset.sum_empty] rw [Measure.map_const] simp only [measure_univ, one_smul] rw [show (⟨(0 : ℝ), by positivity⟩ : NNReal) = 0 from rfl] exact (gaussianReal_zero_var 0).symm | insert j s hj ih => -- Split off the `j`-th summand: rewrite as the Pi-sum `(partial sum) + g j`. have hsum : (fun ω => ∑ i ∈ insert j s, g i ω) = (fun ω => ∑ i ∈ s, g i ω) + g j := by funext ω; rw [Finset.sum_insert hj]; simp [Pi.add_apply]; ring rw [hsum] -- Independence of the partial sum and the new term. have hindepFun : IndepFun (fun ω => ∑ i ∈ s, g i ω) (g j) μ := by have h := hg_indep.indepFun_finset_sum_of_notMem hg_meas (s := s) (i := j) hj have heq : (∑ i ∈ s, g i) = (fun ω => ∑ i ∈ s, g i ω) := by funext ω; simp [Finset.sum_apply] rwa [heq] at h -- Convolution of the two Gaussian laws. have hconv := gaussianReal_add_gaussianReal_of_indepFun hindepFun ih (hg_law j) rw [hconv] congr 1 · simp · ext show (∑ i ∈ s, a i ^ 2) + a j ^ 2 = ∑ i ∈ insert j s, a i ^ 2 rw [Finset.sum_insert hj] ring have := key univ simpa using this
Causalean.Mathlib.map_weighted_sum_gaussian · Causalean/Mathlib/Probability/GaussianWeightedSum.lean:24
Hermite­Facts 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.

theorem classicalHermiteFacts reviewed
Causalean.Mathlib.Probability

Probabilists' Hermite polynomials satisfy the real exponential generating series, Gaussian orthogonality with factorial norms, and the zero-order identity.

Formal statement
conclusion 1
z t :
ℝ
HasSum (fun j : ℕ => (aeval z (hermite j) : ℝ) * t ^ j / (Nat.factorial j : ℝ)) (exp (z * t - t ^ 2 / 2))
conclusion 2
j k :
ℕ
(∫ z, (aeval z (hermite j) : ℝ) * aeval z (hermite k) ∂gaussianReal 0 1)
= if j = k then (Nat.factorial j : ℝ) else 0
conclusion 3
hermite 0 = 1
Proof (Lean source)
theorem classicalHermiteFacts : (∀ z t : ℝ, HasSum (fun j : ℕ => (aeval z (hermite j) : ℝ) * t ^ j / (Nat.factorial j : ℝ)) (exp (z * t - t ^ 2 / 2))) ∧ (∀ j k : ℕ, (∫ z, (aeval z (hermite j) : ℝ) * aeval z (hermite k) ∂gaussianReal 0 1) = if j = k then (Nat.factorial j : ℝ) else 0) ∧ hermite 0 = 1 := by exact ⟨hasSum_hermite, integral_hermite_mul, hermite_zero⟩
Causalean.Mathlib.Probability.classicalHermiteFacts · Causalean/Mathlib/Probability/HermiteFacts.lean:20
Hermite­Gaussian 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.

theorem integral_hermite_mul reviewed
Causalean.Mathlib.Probability

Two probabilists' Hermite polynomials have standard Gaussian inner product equal to the order factorial when their orders agree and zero otherwise.

Formal statement
j k :
ℕ
(∫ x, (aeval x (hermite j) : ℝ) * aeval x (hermite k) ∂gaussianReal 0 1)
= if j = k then (Nat.factorial j : ℝ) else 0
Proof (Lean source)
theorem integral_hermite_mul (j k : ℕ) : (∫ x, (aeval x (hermite j) : ℝ) * aeval x (hermite k) ∂gaussianReal 0 1) = if j = k then (Nat.factorial j : ℝ) else 0 := by induction j generalizing k with | zero => cases k with | zero => simp | succ k => simp only [hermite_zero, map_one, one_mul] rw [integral_hermite_succ] simp | succ j ih => cases k with | zero => simp only [hermite_zero, map_one, mul_one] rw [integral_hermite_succ] simp | succ k => rw [integral_hermite_succ_mul_succ, ih] by_cases h : j = k · subst k simp [Nat.factorial_succ] · simp [h]
Causalean.Mathlib.Probability.integral_hermite_mul · Causalean/Mathlib/Probability/HermiteGaussian.lean:332
15 supporting declarations (lemmas, instances)
  • integrable_eval_mul_gaussian theorem — A real polynomial, multiplied by a Gaussian weight with positive precision, is integrable on the real line.
    p :
    ℝ[X]
    b :
    ℝ
    hb :
    0 < b
    Integrable (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
    Causalean.Mathlib.Probability.integrable_eval_mul_gaussian · Causalean/Mathlib/Probability/HermiteGaussian.lean:25
  • tendsto_eval_mul_gaussian_cocompact theorem — A real polynomial, multiplied by a Gaussian weight with positive precision, tends to zero at both ends of the real line.
    p :
    ℝ[X]
    b :
    ℝ
    hb :
    0 < b
    Tendsto (fun x : ℝ => p.eval x * exp (-b * x ^ 2)) (cocompact ℝ) (𝓝 0)
    Proof (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
    Causalean.Mathlib.Probability.tendsto_eval_mul_gaussian_cocompact · Causalean/Mathlib/Probability/HermiteGaussian.lean:44
  • gaussianPDFReal_standard theorem — The variance-one, mean-zero Gaussian density at a real point is the normalized exponential of minus half the squared point.
    x :
    ℝ
    gaussianPDFReal 0 1 x = (sqrt (2 * pi))⁻¹ * exp (-(x ^ 2 / 2))
    Proof (Lean source)
    theorem gaussianPDFReal_standard (x : ℝ) : gaussianPDFReal 0 1 x = (sqrt (2 * pi))⁻¹ * exp (-(x ^ 2 / 2)) := by simp [gaussianPDFReal, neg_div]
    Causalean.Mathlib.Probability.gaussianPDFReal_standard · Causalean/Mathlib/Probability/HermiteGaussian.lean:67
  • integrable_eval_gaussianReal theorem — Every real polynomial is integrable under the standard Gaussian law.
    p :
    ℝ[X]
    Integrable (fun x : ℝ => p.eval x) (gaussianReal 0 1)
    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
    Causalean.Mathlib.Probability.integrable_eval_gaussianReal · Causalean/Mathlib/Probability/HermiteGaussian.lean:74
  • integral_gaussianReal_standard theorem — Integrating a real function under the standard Gaussian law equals its Lebesgue integral against the normalized Gaussian weight.
    f :
    ℝ → ℝ
    (∫ x, f x ∂gaussianReal 0 1)
    = (sqrt (2 * pi))⁻¹ * ∫ x, f x * exp (-(x ^ 2 / 2))
    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]
    Causalean.Mathlib.Probability.integral_gaussianReal_standard · Causalean/Mathlib/Probability/HermiteGaussian.lean:95
  • hermite_eval_succ theorem — Evaluating a successor Hermite polynomial at a real point gives the point times the preceding polynomial minus its polynomial derivative.
    n :
    ℕ
    x :
    ℝ
    (aeval x (hermite (n + 1)) : ℝ)
    = x * aeval x (hermite n) - aeval x (derivative (hermite n))
    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]
    Causalean.Mathlib.Probability.hermite_eval_succ · Causalean/Mathlib/Probability/HermiteGaussian.lean:106
  • derivative_hermite_succ theorem — Differentiating a successor Hermite polynomial gives its order times the preceding Hermite polynomial.
    n :
    ℕ
    derivative (hermite (n + 1)) = C (n + 1 : ℤ) * hermite n
    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
    Causalean.Mathlib.Probability.derivative_hermite_succ · Causalean/Mathlib/Probability/HermiteGaussian.lean:113
  • hasDerivAt_hermite_succ theorem — At a real point, a successor Hermite polynomial has derivative equal to its order times the preceding evaluation.
    n :
    ℕ
    x :
    ℝ
    HasDerivAt (fun y : ℝ => (aeval y (hermite (n + 1)) : ℝ)) ((n + 1 : ℝ) * aeval x (hermite n)) x
    Proof (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
    Causalean.Mathlib.Probability.hasDerivAt_hermite_succ · Causalean/Mathlib/Probability/HermiteGaussian.lean:132
  • deriv_hermite_succ theorem — The analytic derivative of a successor Hermite evaluation at a real point is its order times the preceding evaluation.
    n :
    ℕ
    x :
    ℝ
    deriv (fun y : ℝ => (aeval y (hermite (n + 1)) : ℝ)) x = (n + 1 : ℝ) * aeval x (hermite n)
    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
    Causalean.Mathlib.Probability.deriv_hermite_succ · Causalean/Mathlib/Probability/HermiteGaussian.lean:141
  • hasDerivAt_standardGaussianWeight theorem — At a real point, the unnormalized standard Gaussian weight has derivative equal to minus the point times the weight.
    x :
    ℝ
    HasDerivAt (fun y : ℝ => exp (-(y ^ 2 / 2))) (-x * exp (-(x ^ 2 / 2))) x
    Proof (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
    Causalean.Mathlib.Probability.hasDerivAt_standardGaussianWeight · Causalean/Mathlib/Probability/HermiteGaussian.lean:150
  • integral_mul_eval_mul_gaussian theorem — 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.
    p :
    ℝ[X]
    (∫ x : ℝ, (x * p.eval x) * exp (-(x ^ 2 / 2)))
    = ∫ x : ℝ, p.derivative.eval x * exp (-(x ^ 2 / 2))
    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
    Causalean.Mathlib.Probability.integral_mul_eval_mul_gaussian · Causalean/Mathlib/Probability/HermiteGaussian.lean:158
  • integral_mul_eval_gaussianReal theorem — For a real polynomial, the standard Gaussian expectation of the variable times its evaluation equals the expectation of its derivative.
    p :
    ℝ[X]
    (∫ x, x * p.eval x ∂gaussianReal 0 1) = ∫ x, p.derivative.eval x ∂gaussianReal 0 1
    Proof (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]
    Causalean.Mathlib.Probability.integral_mul_eval_gaussianReal · Causalean/Mathlib/Probability/HermiteGaussian.lean:205
  • integrable_hermite_mul theorem — Products of two real Hermite evaluations are integrable under the standard Gaussian law.
    j k :
    ℕ
    Integrable (fun x : ℝ => (aeval x (hermite j) : ℝ) * aeval x (hermite k)) (gaussianReal 0 1)
    Proof (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 ℝ))
    Causalean.Mathlib.Probability.integrable_hermite_mul · Causalean/Mathlib/Probability/HermiteGaussian.lean:219
  • integral_hermite_succ theorem — Every positive-order Hermite polynomial has zero standard Gaussian expectation.
    n :
    ℕ
    (∫ x, (aeval x (hermite (n + 1)) : ℝ) ∂gaussianReal 0 1) = 0
    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]
    Causalean.Mathlib.Probability.integral_hermite_succ · Causalean/Mathlib/Probability/HermiteGaussian.lean:228
  • integral_hermite_succ_mul_succ theorem — Raising both Hermite orders by one multiplies their standard Gaussian inner product by the second raised order.
    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
    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 _ _
    Causalean.Mathlib.Probability.integral_hermite_succ_mul_succ · Causalean/Mathlib/Probability/HermiteGaussian.lean:262
Hermite­Generating 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.

theorem hasSum_hermite reviewed
Causalean.Mathlib.Probability

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
z t :
ℝ
HasSum (fun j : ℕ => (aeval z (hermite j) : ℝ) * t ^ j / (Nat.factorial j : ℝ)) (exp (z * t - t ^ 2 / 2))
Proof (Lean source)
theorem hasSum_hermite (z t : ℝ) : HasSum (fun j : ℕ => (aeval z (hermite j) : ℝ) * t ^ j / (Nat.factorial j : ℝ)) (exp (z * t - t ^ 2 / 2)) := by have h := hasSum_expSeries_convolution (z * t) (-(t ^ 2 / 2)) simpa only [sub_eq_add_neg] using h.congr_fun (fun n => hermite_term_eq_convolution n z t)
Causalean.Mathlib.Probability.hasSum_hermite · Causalean/Mathlib/Probability/HermiteGenerating.lean:272
7 supporting declarations (lemmas, instances)
  • coeff_hermite_div_factorial theorem — 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.
    m k :
    ℕ
    ((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
    Causalean.Mathlib.Probability.coeff_hermite_div_factorial · Causalean/Mathlib/Probability/HermiteGenerating.lean:27
  • hermite_eval_div_factorial theorem — A factorial-normalized Hermite evaluation equals the finite sum over its even degree gaps.
    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) : ℝ))
    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
    Causalean.Mathlib.Probability.hermite_eval_div_factorial · Causalean/Mathlib/Probability/HermiteGenerating.lean:66
  • hermite_term_eq_convolution theorem — A Hermite exponential-series term is the finite convolution of a linear exponential and an even quadratic exponential.
    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)
    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]
    Causalean.Mathlib.Probability.hermite_term_eq_convolution · Causalean/Mathlib/Probability/HermiteGenerating.lean:117
  • hasSum_even_expSeries theorem — Inserting zeros at the odd indices of a real exponential series preserves its sum, the exponential of its argument.
    u :
    ℝ
    HasSum (fun n : ℕ => if Even n then u ^ (n / 2) / (factorial (n / 2) : ℝ) else 0) (exp u)
    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
    Causalean.Mathlib.Probability.hasSum_even_expSeries · Causalean/Mathlib/Probability/HermiteGenerating.lean:181
  • summable_norm_even_expSeries theorem — The absolute values of the exponential series with zeros inserted at odd indices form a summable series.
    u :
    ℝ
    Summable (fun n : ℕ => ‖if Even n then u ^ (n / 2) / (factorial (n / 2) : ℝ) else 0‖)
    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
    Causalean.Mathlib.Probability.summable_norm_even_expSeries · Causalean/Mathlib/Probability/HermiteGenerating.lean:206
  • hasSum_expSeries_convolution theorem — The finite Cauchy convolution of a linear exponential argument and an even-position exponential argument has sum equal to the exponential of their sum.
    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))
    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
    Causalean.Mathlib.Probability.hasSum_expSeries_convolution · Causalean/Mathlib/Probability/HermiteGenerating.lean:230
  • summable_norm_hermite theorem — The absolute values of the real Hermite exponential-series terms form a summable series.
    z t :
    ℝ
    Summable (fun j : ℕ => ‖(aeval z (hermite j) : ℝ) * t ^ j / (Nat.factorial j : ℝ)‖)
    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)
    Causalean.Mathlib.Probability.summable_norm_hermite · Causalean/Mathlib/Probability/HermiteGenerating.lean:261
Iid­Mean­Variance 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.

theorem iid_mean_euclidean_abs_le reviewed
Causalean.Mathlib.Probability

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
Ω ι :
n :
ℕ
hn :
0 < n
ξ :
ι → Ω → ℝ
hξ :
∀ k, MemLp (ξ k) 2 μ
∫ s, sqrt (∑ k : ι, ((n : ℝ)⁻¹ * (∑ i : Fin n, ξ k (s i)) - ∫ ω, ξ k ω ∂μ) ^ 2) ∂(Measure.pi fun _ : Fin n => μ)
≤ sqrt ((∑ k : ι, ∫ ω, (ξ k ω) ^ 2 ∂μ) / (n : ℝ))
Proof (Lean source)
theorem iid_mean_euclidean_abs_le {Ω ι : Type*} [MeasurableSpace Ω] [Fintype ι] (μ : Measure Ω) [IsProbabilityMeasure μ] {n : ℕ} (hn : 0 < n) (ξ : ι → Ω → ℝ) (hξ : ∀ k, MemLp (ξ k) 2 μ) : ∫ s, sqrt (∑ k : ι, ((n : ℝ)⁻¹ * (∑ i : Fin n, ξ k (s i)) - ∫ ω, ξ k ω ∂μ) ^ 2) ∂(Measure.pi fun _ : Fin n => μ) ≤ sqrt ((∑ k : ι, ∫ ω, (ξ k ω) ^ 2 ∂μ) / (n : ℝ)) := by haveI : Nonempty (Fin n) := Fin.pos_iff_nonempty.mp hn simpa using iid_mean_euclidean_abs_le_fintype (ι := Fin n) (κ := ι) μ ξ hξ
Causalean.Mathlib.Probability.iid_mean_euclidean_abs_le · Causalean/Mathlib/Probability/IidMeanVariance.lean:317
15 supporting declarations (lemmas, instances)
  • sqrt_sum_sq_le_sum_abs lemma — The Euclidean length of a finite real-valued vector is no greater than the sum of the absolute values of its components.
    ι :
    Type*
    v :
    ι → ℝ
    sqrt (∑ i, (v i) ^ 2) ≤ ∑ i, |v i|
    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 _)
    Causalean.Mathlib.Probability.sqrt_sum_sq_le_sum_abs · Causalean/Mathlib/Probability/IidMeanVariance.lean:37
  • integrable_euclidean_of_integrable theorem — The Euclidean length of a finite family of integrable real functions is itself integrable.
    Ω ι :
    v :
    Ω → ι → ℝ
    hv :
    ∀ i, Integrable (fun ω => v ω i) μ
    Integrable (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 ω)
    Causalean.Mathlib.Probability.integrable_euclidean_of_integrable · Causalean/Mathlib/Probability/IidMeanVariance.lean:48
  • memLp_two_sqrt_sum_sq theorem — The Euclidean length of a finite family of square-integrable real functions is itself square-integrable.
    Ω ι :
    Type*
    ι → Ω → ℝ
    hY :
    ∀ k, MemLp (Y k) 2 μ
    MemLp (fun ω => sqrt (∑ k, (Y k ω) ^ 2)) 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 _)
    Causalean.Mathlib.Probability.memLp_two_sqrt_sum_sq · Causalean/Mathlib/Probability/IidMeanVariance.lean:64
  • iid_mean_sq_le_fintype theorem — 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.
    Ω ι :
    Type*
    Nonempty ι
    ξ :
    Ω → ℝ
    hξ :
    MemLp ξ 2 μ
    ∫ 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
    Causalean.Mathlib.Probability.iid_mean_sq_le_fintype · Causalean/Mathlib/Probability/IidMeanVariance.lean:81
  • iid_mean_abs_le_fintype theorem — 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.
    Ω ι :
    Type*
    Nonempty ι
    ξ :
    Ω → ℝ
    hξ :
    MemLp ξ 2 μ
    ∫ 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ξ)))
    Causalean.Mathlib.Probability.iid_mean_abs_le_fintype · Causalean/Mathlib/Probability/IidMeanVariance.lean:144
  • memLp_two_iid_mean_euclidean_fintype theorem — The centred coordinatewise sample averages of finitely many square-integrable statistics form a square-integrable Euclidean length on the product sample space.
    Ω ι κ :
    ξ :
    κ → Ω → ℝ
    hξ :
    ∀ k, MemLp (ξ k) 2 μ
    MemLp (fun s => sqrt (∑ k : κ, ((Fintype.card ι : ℝ)⁻¹ * (∑ i : ι, ξ k (s i)) - ∫ ω, ξ k ω ∂μ) ^ 2)) 2 (Measure.pi fun _ : ι => μ)
    Proof (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 _
    Causalean.Mathlib.Probability.memLp_two_iid_mean_euclidean_fintype · Causalean/Mathlib/Probability/IidMeanVariance.lean:168
  • iid_mean_euclidean_abs_le_fintype theorem — 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.
    Ω ι κ :
    Type*
    Nonempty ι
    ξ :
    κ → Ω → ℝ
    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 ι : ℝ))
    Proof (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]
    Causalean.Mathlib.Probability.iid_mean_euclidean_abs_le_fintype · Causalean/Mathlib/Probability/IidMeanVariance.lean:186
  • iid_average_integral_fintype lemma — An average of independent, identically distributed observations has the same expectation as the population statistic being averaged.
    Ω ι :
    Type*
    Nonempty ι
    F :
    Ω → ℝ
    hF :
    (∫ 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
    Causalean.Mathlib.Probability.iid_average_integral_fintype · Causalean/Mathlib/Probability/IidMeanVariance.lean:231
  • iid_average_variance_fintype lemma — The variance of an average of independent, identically distributed observations is the population variance divided by the sample size.
    Ω ι :
    F :
    Ω → ℝ
    hF :
    MemLp F 2 μ
    variance (fun sample : ι → Ω => (Fintype.card ι : ℝ)⁻¹ * ∑ i, F (sample i)) (Measure.pi (fun _ : ι => μ))
    = (Fintype.card ι : ℝ)⁻¹ * variance F μ
    Proof (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
    Causalean.Mathlib.Probability.iid_average_variance_fintype · Causalean/Mathlib/Probability/IidMeanVariance.lean:254
  • iid_mean_sq_le theorem — 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.
    Ω :
    n :
    ℕ
    hn :
    0 < n
    ξ :
    Ω → ℝ
    hξ :
    MemLp ξ 2 μ
    ∫ s, ((n : ℝ)⁻¹ * (∑ i : Fin n, ξ (s i)) - ∫ ω, ξ ω ∂μ) ^ 2 ∂(Measure.pi fun _ : Fin n => μ)
    ≤ (∫ ω, (ξ ω) ^ 2 ∂μ) / (n : ℝ)
    Proof (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ξ
    Causalean.Mathlib.Probability.iid_mean_sq_le · Causalean/Mathlib/Probability/IidMeanVariance.lean:294
  • iid_mean_abs_le theorem — 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.
    Ω :
    n :
    ℕ
    hn :
    0 < n
    ξ :
    Ω → ℝ
    hξ :
    MemLp ξ 2 μ
    ∫ s, |(n : ℝ)⁻¹ * (∑ i : Fin n, ξ (s i)) - ∫ ω, ξ ω ∂μ| ∂(Measure.pi fun _ : Fin n => μ)
    ≤ sqrt ((∫ ω, (ξ ω) ^ 2 ∂μ) / (n : ℝ))
    Proof (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ξ
    Causalean.Mathlib.Probability.iid_mean_abs_le · Causalean/Mathlib/Probability/IidMeanVariance.lean:305
  • memLp_two_iid_mean_euclidean theorem — 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.
    Ω ι :
    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 => μ)
    Proof (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ξ
    Causalean.Mathlib.Probability.memLp_two_iid_mean_euclidean · Causalean/Mathlib/Probability/IidMeanVariance.lean:333
  • integrable_iid_mean_euclidean theorem — The centred coordinatewise sample averages of finitely many integrable statistics over an n-point independent, identically distributed sample have integrable Euclidean length.
    Ω ι :
    n :
    ℕ
    ξ :
    ι → Ω → ℝ
    hξ :
    ∀ k, Integrable (ξ k) μ
    Integrable (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
    Causalean.Mathlib.Probability.integrable_iid_mean_euclidean · Causalean/Mathlib/Probability/IidMeanVariance.lean:347
  • iid_average_integral lemma — An average of n independent, identically distributed observations has the same expectation as the population statistic being averaged.
    Ω :
    m :
    ℕ
    hm :
    0 < m
    F :
    Ω → ℝ
    hF :
    (∫ sample : Fin m → Ω, (m : ℝ)⁻¹ * ∑ i, F (sample i) ∂Measure.pi (fun _ : Fin m => μ))
    = ∫ o, F o ∂μ
    Proof (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
    Causalean.Mathlib.Probability.iid_average_integral · Causalean/Mathlib/Probability/IidMeanVariance.lean:366
  • iid_average_variance lemma — The variance of an average of independent, identically distributed observations is the population variance divided by the sample size (including the zero-length case).
    Ω :
    m :
    ℕ
    F :
    Ω → ℝ
    hF :
    MemLp F 2 μ
    variance (fun sample : Fin m → Ω => (m : ℝ)⁻¹ * ∑ i, F (sample i)) (Measure.pi (fun _ : Fin m => μ))
    = (m : ℝ)⁻¹ * variance F μ
    Proof (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
    Causalean.Mathlib.Probability.iid_average_variance · Causalean/Mathlib/Probability/IidMeanVariance.lean:379
Kac­Bernstein 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.

lemma gaussianForm_of_funeq reviewed
Causalean.Mathlib.Probability

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
f g :
ℝ → ℂ
hf :
ContDiff ℝ 2 f
hg :
ContDiff ℝ 2 g
hf0 :
f 0 = 1
hg0 :
g 0 = 1
hfe :
∀ u v : ℝ, f (u + v) * g (u - v) = f u * g u * (f v * g (-v))
∃ c : ℂ,
conclusion 1
∀ᶠ t in nhds (0 : ℝ), f t = exp (deriv f 0 * t + c * t ^ 2 / 2)
conclusion 2
∀ᶠ t in nhds (0 : ℝ), g t = exp (deriv g 0 * t + c * t ^ 2 / 2)
Proof (Lean source)
lemma gaussianForm_of_funeq {f g : ℝ → ℂ} (hf : ContDiff ℝ 2 f) (hg : ContDiff ℝ 2 g) (hf0 : f 0 = 1) (hg0 : g 0 = 1) (hfe : ∀ u v : ℝ, f (u + v) * g (u - v) = f u * g u * (f v * g (-v))) : ∃ c : ℂ, (∀ᶠ t in nhds (0 : ℝ), f t = exp (deriv f 0 * t + c * t ^ 2 / 2)) ∧ (∀ᶠ t in nhds (0 : ℝ), g t = exp (deriv g 0 * t + c * t ^ 2 / 2)) := by let lf : ℝ → ℂ := fun t => deriv f t / f t let lg : ℝ → ℂ := fun t => deriv g t / g t have hfD : Differentiable ℝ f := (hf.of_le (by norm_num : (1 : WithTop ℕ∞) ≤ 2)).differentiable_one have hgD : Differentiable ℝ g := (hg.of_le (by norm_num : (1 : WithTop ℕ∞) ≤ 2)).differentiable_one have hdfD : Differentiable ℝ (deriv f) := hf.differentiable_deriv_two have hdgD : Differentiable ℝ (deriv g) := hg.differentiable_deriv_two have hf_ne : ∀ᶠ t in nhds (0 : ℝ), f t ≠ 0 := hf.continuous.continuousAt.eventually_ne (by simp [hf0] : f 0 ≠ 0) have hg_ne : ∀ᶠ t in nhds (0 : ℝ), g t ≠ 0 := hg.continuous.continuousAt.eventually_ne (by simp [hg0] : g 0 ≠ 0) have hlf0 : lf 0 = deriv f 0 := by simp [lf, hf0] have hlg0 : lg 0 = deriv g 0 := by simp [lg, hg0] have hlfDiffAt : ∀ {x : ℝ}, f x ≠ 0 → DifferentiableAt ℝ lf x := by intro x hx exact (hdfD x).div (hfD x) hx have hlgDiffAt : ∀ {x : ℝ}, g x ≠ 0 → DifferentiableAt ℝ lg x := by intro x hx exact (hdgD x).div (hgD x) hx have hD1 : ∀ u v : ℝ, deriv f (u + v) * g (u - v) + f (u + v) * deriv g (u - v) = (deriv f u * g u + f u * deriv g u) * (f v * g (-v)) := by intro u v have hleftF : (fun x : ℝ => f (x + v) * g (x - v)) = (fun x : ℝ => f x * g x * (f v * g (-v))) := by funext x exact hfe x v have hfp : HasDerivAt (fun x : ℝ => f (x + v)) (deriv f (u + v)) u := by simpa using (hfD (u + v)).hasDerivAt.comp_add_const u v have hgm : HasDerivAt (fun x : ℝ => g (x - v)) (deriv g (u - v)) u := by simpa using (hgD (u - v)).hasDerivAt.comp_sub_const u v have hleft : HasDerivAt (fun x : ℝ => f (x + v) * g (x - v)) (deriv f (u + v) * g (u - v) + f (u + v) * deriv g (u - v)) u := by exact hfp.fun_mul hgm have hfu : HasDerivAt (fun x : ℝ => f x) (deriv f u) u := (hfD u).hasDerivAt have hgu : HasDerivAt (fun x : ℝ => g x) (deriv g u) u := (hgD u).hasDerivAt have hright : HasDerivAt (fun x : ℝ => f x * g x * (f v * g (-v))) ((deriv f u * g u + f u * deriv g u) * (f v * g (-v))) u := by exact (hfu.fun_mul hgu).mul_const (f v * g (-v)) have hright' : HasDerivAt (fun x : ℝ => f (x + v) * g (x - v)) ((deriv f u * g u + f u * deriv g u) * (f v * g (-v))) u := by simpa [hleftF] using hright exact hleft.unique hright' have hE1_at : ∀ u v : ℝ, f (u + v) ≠ 0 → g (u - v) ≠ 0 → f u ≠ 0 → g u ≠ 0 → f v ≠ 0 → g (-v) ≠ 0 → lf (u + v) + lg (u - v) = lf u + lg u := by intro u v hfp hgm hfu hgu hfv hgnv have hD1' := hD1 u v have hFE := hfe u v dsimp [lf, lg] calc deriv f (u + v) / f (u + v) + deriv g (u - v) / g (u - v) = (deriv f (u + v) * g (u - v) + f (u + v) * deriv g (u - v)) / (f (u + v) * g (u - v)) := by field_simp [hfp, hgm] _ = ((deriv f u * g u + f u * deriv g u) * f v * g (-v)) / (f u * g u * f v * g (-v)) := by rw [hD1', hFE] ring _ = (deriv f u * g u + f u * deriv g u) / (f u * g u) := by field_simp [hfu, hgu, hfv, hgnv] _ = deriv f u / f u + deriv g u / g u := by field_simp [hfu, hgu] have hsecondLogDeriv : ∃ c : ℂ, (∀ᶠ t in nhds (0 : ℝ), deriv lf t = c) ∧ (∀ᶠ t in nhds (0 : ℝ), deriv lg t = c) := by let c : ℂ := deriv lg 0 have hpair_ne : ∀ᶠ p : ℝ × ℝ in nhds ((0, 0) : ℝ × ℝ), f (p.1 + p.2) ≠ 0 ∧ g (p.1 - p.2) ≠ 0 ∧ f p.1 ≠ 0 ∧ g p.1 ≠ 0 ∧ f p.2 ≠ 0 ∧ g (-p.2) ≠ 0 := by have h_add : Tendsto (fun p : ℝ × ℝ => p.1 + p.2) (nhds ((0, 0) : ℝ × ℝ)) (nhds (0 : ℝ)) := by have hc : Continuous (fun p : ℝ × ℝ => p.1 + p.2) := continuous_fst.add continuous_snd simpa using hc.tendsto ((0, 0) : ℝ × ℝ) have h_sub : Tendsto (fun p : ℝ × ℝ => p.1 - p.2) (nhds ((0, 0) : ℝ × ℝ)) (nhds (0 : ℝ)) := by have hc : Continuous (fun p : ℝ × ℝ => p.1 - p.2) := continuous_fst.sub continuous_snd simpa using hc.tendsto ((0, 0) : ℝ × ℝ) have h_fst : Tendsto (fun p : ℝ × ℝ => p.1) (nhds ((0, 0) : ℝ × ℝ)) (nhds (0 : ℝ)) := by simpa [ContinuousAt] using (continuous_fst.continuousAt (x := ((0, 0) : ℝ × ℝ))) have h_snd : Tendsto (fun p : ℝ × ℝ => p.2) (nhds ((0, 0) : ℝ × ℝ)) (nhds (0 : ℝ)) := by simpa [ContinuousAt] using (continuous_snd.continuousAt (x := ((0, 0) : ℝ × ℝ))) have h_neg_snd : Tendsto (fun p : ℝ × ℝ => -p.2) (nhds ((0, 0) : ℝ × ℝ)) (nhds (0 : ℝ)) := by have hc : Continuous (fun p : ℝ × ℝ => -p.2) := continuous_snd.neg simpa using hc.tendsto ((0, 0) : ℝ × ℝ) filter_upwards [h_add.eventually hf_ne, h_sub.eventually hg_ne, h_fst.eventually hf_ne, h_fst.eventually hg_ne, h_snd.eventually hf_ne, h_neg_snd.eventually hg_ne] with p h1 h2 h3 h4 h5 h6 exact ⟨h1, h2, h3, h4, h5, h6⟩ have hderiv_pair : ∀ᶠ p : ℝ × ℝ in nhds ((0, 0) : ℝ × ℝ), deriv lf (p.1 + p.2) = deriv lg (p.1 - p.2) := by filter_upwards [hpair_ne] with p hp rcases hp with ⟨hfp, hgm, hfu, hgu, hfv, hgnv⟩ let u : ℝ := p.1 let v : ℝ := p.2 have hEq : (fun w : ℝ => lf (u + w) + lg (u - w)) =ᶠ[nhds v] fun _ : ℝ => lf u + lg u := by have hfu' : f u ≠ 0 := by simpa [u] using hfu have hgu' : g u ≠ 0 := by simpa [u] using hgu have h1 : ∀ᶠ w in nhds v, f (u + w) ≠ 0 := ((hf.continuous.continuousAt.comp ((continuous_const.add continuous_id).continuousAt))).eventually_ne (by simpa [u, v] using hfp) have h2 : ∀ᶠ w in nhds v, g (u - w) ≠ 0 := ((hg.continuous.continuousAt.comp ((continuous_const.sub continuous_id).continuousAt))).eventually_ne (by simpa [u, v] using hgm) have h3 : ∀ᶠ w in nhds v, f w ≠ 0 := hf.continuous.continuousAt.eventually_ne (by simpa [v] using hfv) have h4 : ∀ᶠ w in nhds v, g (-w) ≠ 0 := (hg.continuous.continuousAt.comp continuous_neg.continuousAt).eventually_ne (by simpa [v] using hgnv) filter_upwards [h1, h2, h3, h4] with w hw1 hw2 hw3 hw4 exact hE1_at u w hw1 hw2 hfu' hgu' hw3 hw4 have hlfp : HasDerivAt (fun w : ℝ => lf (u + w)) (deriv lf (u + v)) v := by simpa using (hlfDiffAt (by simpa [u, v] using hfp)).hasDerivAt.comp_const_add u v have hlgm : HasDerivAt (fun w : ℝ => lg (u - w)) (-(deriv lg (u - v))) v := by simpa using (hlgDiffAt (by simpa [u, v] using hgm)).hasDerivAt.comp_const_sub u v have hleft : HasDerivAt (fun w : ℝ => lf (u + w) + lg (u - w)) (deriv lf (u + v) - deriv lg (u - v)) v := by exact (hlfp.fun_add hlgm).congr_deriv (by ring) have hconst : HasDerivAt (fun _ : ℝ => lf u + lg u) (deriv lf (u + v) - deriv lg (u - v)) v := hleft.congr_of_eventuallyEq hEq.symm have hzero : HasDerivAt (fun _ : ℝ => lf u + lg u) 0 v := hasDerivAt_const v _ have hsub : deriv lf (u + v) - deriv lg (u - v) = 0 := hconst.unique hzero have hres : deriv lf (u + v) = deriv lg (u - v) := sub_eq_zero.mp hsub simpa [u, v] using hres have hlfDeriv : ∀ᶠ t in nhds (0 : ℝ), deriv lf t = c := by have hline : Tendsto (fun t : ℝ => (t / 2, t / 2)) (nhds (0 : ℝ)) (nhds ((0, 0) : ℝ × ℝ)) := by simpa [ContinuousAt] using ((continuous_id.div_const (2 : ℝ)).prodMk (continuous_id.div_const (2 : ℝ))).continuousAt (x := (0 : ℝ)) filter_upwards [hline.eventually hderiv_pair] with t ht have ht' : deriv lf (t / 2 + t / 2) = deriv lg (t / 2 - t / 2) := ht have hsum : t / 2 + t / 2 = t := by ring have hsub : t / 2 - t / 2 = 0 := by ring simpa [c, hsum, hsub] using ht' have hlgDeriv : ∀ᶠ t in nhds (0 : ℝ), deriv lg t = c := by have hlf0c : deriv lf 0 = c := hlfDeriv.self_of_nhds have hline : Tendsto (fun t : ℝ => (t / 2, -(t / 2))) (nhds (0 : ℝ)) (nhds ((0, 0) : ℝ × ℝ)) := by simpa [ContinuousAt] using ((continuous_id.div_const (2 : ℝ)).prodMk ((continuous_id.div_const (2 : ℝ)).neg)).continuousAt (x := (0 : ℝ)) filter_upwards [hline.eventually hderiv_pair] with t ht have ht' : deriv lf (t / 2 + -(t / 2)) = deriv lg (t / 2 - -(t / 2)) := ht have hsum : t / 2 + -(t / 2) = 0 := by ring have hsub : t / 2 - -(t / 2) = t := by ring have ht0 : deriv lf 0 = deriv lg t := by simpa [hsum, hsub] using ht' exact ht0.symm.trans hlf0c exact ⟨c, hlfDeriv, hlgDeriv⟩ obtain ⟨c, hlfDeriv, hlgDeriv⟩ := hsecondLogDeriv have hlogAffine : (∀ᶠ t in nhds (0 : ℝ), lf t = deriv f 0 + c * t) ∧ (∀ᶠ t in nhds (0 : ℝ), lg t = deriv g 0 + c * t) := by have hAffDeriv : ∀ a x : ℂ, ∀ t : ℝ, HasDerivAt (fun s : ℝ => a + x * s) x t := by intro a x t have hcoe : HasDerivAt (fun s : ℝ => (s : ℂ)) 1 t := HasDerivAt.ofReal_comp (hasDerivAt_id t) exact ((hcoe.const_mul x).const_add a).congr_deriv (by ring) constructor · rcases Metric.eventually_nhds_iff_ball.mp (hlfDeriv.and hf_ne) with ⟨r, hr, hball⟩ have hlfOn : DifferentiableOn ℝ lf (ball (0 : ℝ) r) := by intro x hx exact (hlfDiffAt (hball x hx).2).differentiableWithinAt have hAffOn : DifferentiableOn ℝ (fun t : ℝ => deriv f 0 + c * t) (ball (0 : ℝ) r) := by intro x hx exact ((hAffDeriv (deriv f 0) c x).differentiableAt).differentiableWithinAt have hEqOn : EqOn lf (fun t : ℝ => deriv f 0 + c * t) (ball (0 : ℝ) r) := by refine Metric.isOpen_ball.eqOn_of_deriv_eq (convex_ball (0 : ℝ) r).isPreconnected hlfOn hAffOn ?_ (Metric.mem_ball_self hr) ?_ · intro x hx have hxder : deriv lf x = c := (hball x hx).1 have hmodel : deriv (fun t : ℝ => deriv f 0 + c * t) x = c := (hAffDeriv (deriv f 0) c x).deriv rw [hxder, hmodel] · simp [hlf0] refine Metric.eventually_nhds_iff_ball.mpr ⟨r, hr, fun t ht => ?_⟩ exact hEqOn ht · rcases Metric.eventually_nhds_iff_ball.mp (hlgDeriv.and hg_ne) with ⟨r, hr, hball⟩ have hlgOn : DifferentiableOn ℝ lg (ball (0 : ℝ) r) := by intro x hx exact (hlgDiffAt (hball x hx).2).differentiableWithinAt have hAffOn : DifferentiableOn ℝ (fun t : ℝ => deriv g 0 + c * t) (ball (0 : ℝ) r) := by intro x hx exact ((hAffDeriv (deriv g 0) c x).differentiableAt).differentiableWithinAt have hEqOn : EqOn lg (fun t : ℝ => deriv g 0 + c * t) (ball (0 : ℝ) r) := by refine Metric.isOpen_ball.eqOn_of_deriv_eq (convex_ball (0 : ℝ) r).isPreconnected hlgOn hAffOn ?_ (Metric.mem_ball_self hr) ?_ · intro x hx have hxder : deriv lg x = c := (hball x hx).1 have hmodel : deriv (fun t : ℝ => deriv g 0 + c * t) x = c := (hAffDeriv (deriv g 0) c x).deriv rw [hxder, hmodel] · simp [hlg0] refine Metric.eventually_nhds_iff_ball.mpr ⟨r, hr, fun t ht => ?_⟩ exact hEqOn ht have hsolve : (∀ᶠ t in nhds (0 : ℝ), f t = exp (deriv f 0 * t + c * t ^ 2 / 2)) ∧ (∀ᶠ t in nhds (0 : ℝ), g t = exp (deriv g 0 * t + c * t ^ 2 / 2)) := by have hExpDeriv : ∀ a : ℂ, ∀ t : ℝ, HasDerivAt (fun s : ℝ => exp (a * s + c * s ^ 2 / 2)) ((a + c * t) * exp (a * t + c * t ^ 2 / 2)) t := by intro a t have hcoe : HasDerivAt (fun s : ℝ => (s : ℂ)) 1 t := HasDerivAt.ofReal_comp (hasDerivAt_id t) have hinner : HasDerivAt (fun s : ℝ => a * s + c * s ^ 2 / 2) (a + c * t) t := ((hcoe.const_mul a).fun_add (((hcoe.fun_pow 2).const_mul c).div_const 2)).congr_deriv (by norm_num; ring) simpa [mul_comm, mul_left_comm, mul_assoc] using hinner.cexp constructor · let Ef : ℝ → ℂ := fun t => exp (deriv f 0 * t + c * t ^ 2 / 2) -- … truncated; follow the source link for the rest …
Causalean.Mathlib.Probability.gaussianForm_of_funeq · Causalean/Mathlib/Probability/KacBernstein.lean:159
theorem bernsteinCharacterization reviewed
Causalean.Mathlib.Probability

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
Ω :
Type u_1
Ω → ℝ
Ω → ℝ
shared
mX :
mY :
hX2 :
MemLp X 2 P
hY2 :
MemLp Y 2 P
hXY :
IndepFun X Y P
hUV :
IndepFun (X + Y) (X - Y) P
conclusion 1
IsGaussian (P.map X)
conclusion 2
IsGaussian (P.map Y)
Proof (Lean source)
theorem bernsteinCharacterization (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) : IsGaussian (P.map X) ∧ IsGaussian (P.map Y) := by -- Assembly: `bernstein_charFun_gaussian_nhds_zero` gives the local Gaussian forms -- for both `f = charFun (P.map X)` and `g = charFun (P.map Y)` with shared `σ²`. -- Extend each to all of `ℝ` by the doubling instance `f (2t) = f t ^ 2 · g t · g (−t)` -- of `bernstein_charFun_funeq` (induction on `2ⁿ`-scaled neighbourhoods), then -- identify the law via `Measure.ext_of_charFun` against `gaussianReal mf σ²` -- (resp. `gaussianReal mg σ²`) and conclude `IsGaussian` from the `gaussianReal` -- instance / `isGaussian_iff_gaussian_charFun`. obtain ⟨mf, mg, σ2, hσ, hXloc, hYloc⟩ := bernstein_charFun_gaussian_nhds_zero (P := P) (X := X) (Y := Y) mX mY hX2 hY2 hXY hUV haveI : IsProbabilityMeasure (P.map X) := Measure.isProbabilityMeasure_map mX.aemeasurable haveI : IsProbabilityMeasure (P.map Y) := Measure.isProbabilityMeasure_map mY.aemeasurable let Φf : ℝ → ℂ := fun t => exp (mf * t * I - σ2 * t ^ 2 / 2) let Φg : ℝ → ℂ := fun t => exp (mg * t * I - σ2 * t ^ 2 / 2) let EqAt : ℝ → Prop := fun t => charFun (P.map X) t = Φf t ∧ charFun (P.map Y) t = Φg t have hloc : ∀ᶠ t in nhds (0 : ℝ), EqAt t := by filter_upwards [hXloc, hYloc] with t htX htY exact ⟨htX, htY⟩ have DBLf : ∀ t : ℝ, charFun (P.map X) (2 * t) = charFun (P.map X) t ^ 2 * charFun (P.map Y) t * charFun (P.map Y) (-t) := by intro t have h := bernstein_charFun_funeq (P := P) (X := X) (Y := Y) mX mY hXY hUV t t calc charFun (P.map X) (2 * t) = charFun (P.map X) (t + t) := by rw [show (2 : ℝ) * t = t + t by ring] _ = charFun (P.map X) t ^ 2 * charFun (P.map Y) t * charFun (P.map Y) (-t) := by simpa [sq, mul_assoc, mul_left_comm, mul_comm] using h have DBLg : ∀ t : ℝ, charFun (P.map Y) (2 * t) = charFun (P.map Y) t ^ 2 * charFun (P.map X) t * charFun (P.map X) (-t) := by intro t have h := bernstein_charFun_funeq (P := P) (X := X) (Y := Y) mX mY hXY hUV t (-t) calc charFun (P.map Y) (2 * t) = charFun (P.map Y) (t - (-t)) := by rw [show (2 : ℝ) * t = t - (-t) by ring] _ = charFun (P.map Y) t ^ 2 * charFun (P.map X) t * charFun (P.map X) (-t) := by simpa [sq, mul_assoc, mul_left_comm, mul_comm] using h have TDBLf : ∀ t : ℝ, Φf (2 * t) = Φf t ^ 2 * Φg t * Φg (-t) := by intro t simp only [Φf, Φg] simp only [pow_two] rw [← Complex.exp_add, ← Complex.exp_add, ← Complex.exp_add] congr 1 norm_num ring_nf have TDBLg : ∀ t : ℝ, Φg (2 * t) = Φg t ^ 2 * Φf t * Φf (-t) := by intro t simp only [Φf, Φg] simp only [pow_two] rw [← Complex.exp_add, ← Complex.exp_add, ← Complex.exp_add] congr 1 norm_num ring_nf have step : ∀ t : ℝ, EqAt t → EqAt (-t) → EqAt (2 * t) := by intro t ht hnt constructor · calc charFun (P.map X) (2 * t) = charFun (P.map X) t ^ 2 * charFun (P.map Y) t * charFun (P.map Y) (-t) := DBLf t _ = Φf t ^ 2 * Φg t * Φg (-t) := by rw [ht.1, ht.2, hnt.2] _ = Φf (2 * t) := (TDBLf t).symm · calc charFun (P.map Y) (2 * t) = charFun (P.map Y) t ^ 2 * charFun (P.map X) t * charFun (P.map X) (-t) := DBLg t _ = Φg t ^ 2 * Φf t * Φf (-t) := by rw [ht.2, ht.1, hnt.1] _ = Φg (2 * t) := (TDBLg t).symm have grow : ∀ n : ℕ, ∀ t : ℝ, EqAt t → EqAt (-t) → EqAt ((2 : ℝ) ^ n * t) ∧ EqAt (-((2 : ℝ) ^ n * t)) := by intro n induction n with | zero => intro t ht hnt simpa using intro ht hnt | succ n ih => intro t ht hnt obtain ⟨ha, hna⟩ := ih t ht hnt have h2a : EqAt (2 * ((2 : ℝ) ^ n * t)) := step ((2 : ℝ) ^ n * t) ha hna have h2na : EqAt (2 * (-((2 : ℝ) ^ n * t))) := by exact step (-((2 : ℝ) ^ n * t)) hna (by simpa using ha) constructor · simpa [pow_succ, mul_assoc, mul_left_comm, mul_comm] using h2a · simpa [pow_succ, mul_assoc, mul_left_comm, mul_comm] using h2na have hkey : ∀ s : ℝ, EqAt s := by intro s have hseq : Tendsto (fun n : ℕ => s / (2 : ℝ) ^ n) atTop (nhds 0) := by have hpow : Tendsto (fun n : ℕ => (2 : ℝ) ^ n) atTop atTop := tendsto_pow_atTop_atTop_of_one_lt (by norm_num : (1 : ℝ) < 2) simpa [div_eq_mul_inv] using (tendsto_const_nhds.mul (tendsto_inv_atTop_zero.comp hpow) : Tendsto (fun n : ℕ => s * (((2 : ℝ) ^ n)⁻¹)) atTop (nhds (s * 0))) have hz : ∀ᶠ n in atTop, EqAt (s / (2 : ℝ) ^ n) := hseq.eventually hloc have hnz : ∀ᶠ n in atTop, EqAt (-(s / (2 : ℝ) ^ n)) := by have hlocNeg : ∀ᶠ t in nhds (-(0 : ℝ)), EqAt t := by simpa using hloc exact hseq.neg.eventually hlocNeg obtain ⟨n, hn⟩ := (hz.and hnz).exists have hgrow := grow n (s / (2 : ℝ) ^ n) hn.1 hn.2 have hpow_ne : (2 : ℝ) ^ n ≠ 0 := pow_ne_zero n (by norm_num : (2 : ℝ) ≠ 0) have hs_eq : (2 : ℝ) ^ n * (s / (2 : ℝ) ^ n) = s := by field_simp [hpow_ne] simpa [hs_eq] using hgrow.1 have hμX : P.map X = gaussianReal mf σ2.toNNReal := by refine Measure.ext_of_charFun ?_ funext t rw [(hkey t).1, charFun_gaussianReal] simp only [Φf] congr 1 rw [Real.coe_toNNReal σ2 hσ] ring have hμY : P.map Y = gaussianReal mg σ2.toNNReal := by refine Measure.ext_of_charFun ?_ funext t rw [(hkey t).2, charFun_gaussianReal] simp only [Φg] congr 1 rw [Real.coe_toNNReal σ2 hσ] ring constructor · rw [hμX] infer_instance · rw [hμY] infer_instance
Causalean.Mathlib.Probability.bernsteinCharacterization · Causalean/Mathlib/Probability/KacBernstein.lean:623
4 supporting declarations (lemmas, instances)
  • bernstein_charFun_funeq lemma — 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.
    Ω :
    Type u_1
    Ω → ℝ
    Ω → ℝ
    shared
    mX :
    mY :
    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))
    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]
    Causalean.Mathlib.Probability.bernstein_charFun_funeq · Causalean/Mathlib/Probability/KacBernstein.lean:60
  • charFun_eventually_ne_zero lemma — 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.
    ∀ᶠ t in nhds (0 : ℝ), charFun μ t ≠ 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)
    Causalean.Mathlib.Probability.charFun_eventually_ne_zero · Causalean/Mathlib/Probability/KacBernstein.lean:140
  • charFun_contDiff_two lemma — 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.
    Ω :
    Type u_1
    Ω → ℝ
    shared
    hZ :
    MemLp Z 2 P
    ContDiff ℝ 2 (charFun (P.map Z))
    Proof (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)
    Causalean.Mathlib.Probability.charFun_contDiff_two · Causalean/Mathlib/Probability/KacBernstein.lean:149
  • bernstein_charFun_gaussian_nhds_zero lemma — 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 ℝ.
    Ω :
    Type u_1
    Ω → ℝ
    Ω → ℝ
    shared
    mX :
    mY :
    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 : ℝ,
    conclusion 1
    0 ≤ σ2
    conclusion 2
    ∀ᶠ t in nhds (0 : ℝ), charFun (P.map X) t
    = exp (mf * t * I - σ2 * t ^ 2 / 2)
    conclusion 3
    ∀ᶠ t in nhds (0 : ℝ), charFun (P.map Y) t
    = exp (mg * t * I - σ2 * t ^ 2 / 2)
    Proof (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
    Causalean.Mathlib.Probability.bernstein_charFun_gaussian_nhds_zero · Causalean/Mathlib/Probability/KacBernstein.lean:488
Measurable­Cond­Quantile 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.

def condQuantile reviewed
Causalean.Mathlib

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.

Definition (Lean source)
α :
Type u_1
shared
ρ :
Measure (α × ℝ)
τ :
α → ℝ
a :
α
condQuantile ρ τ a :
ℝ
sInf {x : ℝ | τ a ≤ condCDF ρ a x}
theorem measurable_condQuantile_and_attains reviewed
Causalean.Mathlib

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
α :
Type u_1
shared
ρ :
Measure (α × ℝ)
τ :
α → ℝ
hτ :
hτ0 :
∀ a, 0 < τ a
hτ1 :
∀ a, τ a < 1
hcont :
∀ a, ContinuousAt (condCDF ρ a) (condQuantile ρ τ a)
conclusion 1
conclusion 2
a :
condCDF ρ a (condQuantile ρ τ a) = τ a
Proof (Lean source)
theorem measurable_condQuantile_and_attains (ρ : Measure (α × ℝ)) (τ : α → ℝ) (hτ : Measurable τ) (hτ0 : ∀ a, 0 < τ a) (hτ1 : ∀ a, τ a < 1) (hcont : ∀ a, ContinuousAt (condCDF ρ a) (condQuantile ρ τ a)) : Measurable (condQuantile ρ τ) ∧ ∀ a, condCDF ρ a (condQuantile ρ τ a) = τ a := by constructor · refine measurable_of_Iic (α := ℝ) (fun t => ?_) have hset : (condQuantile ρ τ) ⁻¹' Iic t = {a | τ a ≤ condCDF ρ a t} := by ext a exact condQuantile_le_iff (ρ := ρ) (τ := τ) (a := a) (x := t) (hτ0 a) (hτ1 a) rw [hset] exact measurableSet_le hτ (measurable_condCDF ρ t) · intro a have hge : τ a ≤ condCDF ρ a (condQuantile ρ τ a) := le_condCDF_condQuantile (ρ := ρ) (τ := τ) (a := a) (hτ1 a) have hle : condCDF ρ a (condQuantile ρ τ a) ≤ τ a := by by_contra hnot have hlt : τ a < condCDF ρ a (condQuantile ρ τ a) := lt_of_not_ge hnot let q := condQuantile ρ τ a have hnear : ∀ᶠ y in 𝓝 q, τ a < condCDF ρ a y := by simpa [q] using ((hcont a).tendsto.eventually_const_lt hlt) obtain ⟨ε, hεpos, hε⟩ := Metric.eventually_nhds_iff.mp hnear let x := q - ε / 2 have hxlt : x < q := sub_lt_self q (half_pos hεpos) have hdist : dist x q < ε := by rw [Real.dist_eq] have hhalf_pos : 0 < ε / 2 := half_pos hεpos have hcalc : x - q = -(ε / 2) := by simp [x] rw [hcalc, abs_neg, abs_of_pos hhalf_pos] linarith have hxS : τ a ≤ condCDF ρ a x := (hε hdist).le have hq_le_x : q ≤ x := by change condQuantile ρ τ a ≤ x exact condQuantile_le_of_le_condCDF (ρ := ρ) (τ := τ) (a := a) (hτ0 a) hxS exact not_lt_of_ge hq_le_x hxlt exact le_antisymm hle hge
Causalean.Mathlib.measurable_condQuantile_and_attains · Causalean/Mathlib/Probability/MeasurableCondQuantile.lean:110 · uses condQuantile
7 supporting declarations (lemmas, instances)
  • condQuantileSet_up_closed lemma — If a response value's conditional cumulative distribution function reaches a target level, then every larger response value also reaches that level.
    α :
    Type u_1
    Measure (α × ℝ)
    α → ℝ
    α
    shared
    x x' :
    ℝ
    hx :
    x ∈ {y : ℝ | τ a ≤ condCDF ρ a y}
    hxx' :
    x ≤ x'
    x' ∈ {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')
    Causalean.Mathlib.condQuantileSet_up_closed · Causalean/Mathlib/Probability/MeasurableCondQuantile.lean:45
  • bddBelow_condQuantileSet lemma — At a strictly positive conditional-quantile level, the response values whose conditional cumulative distribution function reaches that level are bounded below.
    α :
    Type u_1
    Measure (α × ℝ)
    α → ℝ
    α
    shared
    hτ0 :
    0 < τ a
    BddBelow {x : ℝ | τ a ≤ condCDF ρ a x}
    Proof (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))
    Causalean.Mathlib.bddBelow_condQuantileSet · Causalean/Mathlib/Probability/MeasurableCondQuantile.lean:52
  • nonempty_condQuantileSet lemma — At a conditional-quantile level strictly below one, some response value has a conditional cumulative distribution function that reaches that level.
    α :
    Type u_1
    Measure (α × ℝ)
    α → ℝ
    α
    shared
    hτ1 :
    τ a < 1
    ({x : ℝ | τ a ≤ condCDF ρ a x}).Nonempty
    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⟩
    Causalean.Mathlib.nonempty_condQuantileSet · Causalean/Mathlib/Probability/MeasurableCondQuantile.lean:63
  • le_condCDF_condQuantile lemma — At a target level below one, the conditional generalized inverse reaches at least that level in the conditional cumulative distribution function.
    α :
    Type u_1
    Measure (α × ℝ)
    α → ℝ
    α
    shared
    hτ1 :
    τ a < 1
    τ a ≤ condCDF ρ a (condQuantile ρ τ a)
    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
    Causalean.Mathlib.le_condCDF_condQuantile · Causalean/Mathlib/Probability/MeasurableCondQuantile.lean:71
  • le_condCDF_of_condQuantile_le lemma — A conditional quantile below a value makes the conditional CDF reach any level below one.
    α :
    Type u_1
    Measure (α × ℝ)
    α → ℝ
    α
    shared
    x :
    ℝ
    hτ1 :
    τ a < 1
    hx :
    condQuantile ρ τ a ≤ x
    τ a ≤ condCDF ρ a x
    Proof (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)
    Causalean.Mathlib.le_condCDF_of_condQuantile_le · Causalean/Mathlib/Probability/MeasurableCondQuantile.lean:88
  • condQuantile_le_of_le_condCDF lemma — 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.
    α :
    Type u_1
    Measure (α × ℝ)
    α → ℝ
    α
    shared
    x :
    ℝ
    hτ0 :
    0 < τ a
    hx :
    τ a ≤ condCDF ρ a x
    condQuantile ρ τ a ≤ x
    Proof (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
    Causalean.Mathlib.condQuantile_le_of_le_condCDF · Causalean/Mathlib/Probability/MeasurableCondQuantile.lean:95
  • condQuantile_le_iff lemma — At an interior target level, a point is above the conditional generalized inverse exactly when its conditional cumulative distribution function has reached that level.
    α :
    Type u_1
    Measure (α × ℝ)
    α → ℝ
    α
    shared
    x :
    ℝ
    hτ0 :
    0 < τ a
    hτ1 :
    τ a < 1
    condQuantile ρ τ a ≤ x ↔ τ a ≤ condCDF ρ a x
    Proof (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⟩
Product­Absolutely­Continuous 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.

theorem pi_iid_absolutelyContinuous reviewed
Causalean.Mathlib.Probability.ProductAbsolutelyContinuous

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
Ω :
hac :
μ ≪ ν
n :
ℕ
Measure.pi (fun _ : Fin n => μ) ≪ Measure.pi (fun _ : Fin n => ν)
Proof (Lean source)
theorem pi_iid_absolutelyContinuous {Ω : Type*} [MeasurableSpace Ω] (μ ν : Measure Ω) [SigmaFinite μ] [SigmaFinite ν] (hac : μ ≪ ν) (n : ℕ) : Measure.pi (fun _ : Fin n => μ) ≪ Measure.pi (fun _ : Fin n => ν) := by induction n with | zero => rw [Measure.pi_of_empty (fun _ : Fin 0 => μ), Measure.pi_of_empty (fun _ : Fin 0 => ν)] | succ n ih => set e := piFinSuccAbove (fun _ : Fin (n + 1) => Ω) 0 with he have hμ := (measurePreserving_piFinSuccAbove (fun _ : Fin (n + 1) => μ) 0).map_eq have hν := (measurePreserving_piFinSuccAbove (fun _ : Fin (n + 1) => ν) 0).map_eq have hprod : μ.prod (Measure.pi (fun _ : Fin n => μ)) ≪ ν.prod (Measure.pi (fun _ : Fin n => ν)) := hac.prod ih have hmap : (Measure.pi (fun _ : Fin (n + 1) => μ)).map e ≪ (Measure.pi (fun _ : Fin (n + 1) => ν)).map e := by rw [hμ, hν]; exact hprod have hmapped := hmap.map (f := e.symm) e.symm.measurable rwa [Measure.map_map e.symm.measurable e.measurable, MeasurableEquiv.symm_comp_self, Measure.map_id, Measure.map_map e.symm.measurable e.measurable, MeasurableEquiv.symm_comp_self, Measure.map_id] at hmapped
Causalean.Mathlib.Probability.ProductAbsolutelyContinuous.pi_iid_absolutelyContinuous · Causalean/Mathlib/Probability/ProductAbsolutelyContinuous.lean:57
1 supporting declaration (lemmas, instances)
  • rnDeriv_prod_eq theorem — Product density factorization. For μ₁ ≪ ν₁ and μ₂ ≪ ν₂, the Radon–Nikodym density of the product is (a.e.) the product of the marginal densities.
    α :
    Type u_1
    shared
    β :
    Type u_2
    shared
    μ₁ ν₁ :
    μ₂ ν₂ :
    SFinite ν₂
    μ₁.HaveLebesgueDecomposition ν₁
    μ₂.HaveLebesgueDecomposition ν₂
    h₁ :
    μ₁ ≪ ν₁
    h₂ :
    μ₂ ≪ ν₂
    (μ₁.prod μ₂).rnDeriv (ν₁.prod ν₂)
    =ᵐ[ν₁.prod ν₂] fun z => μ₁.rnDeriv ν₁ z.1 * μ₂.rnDeriv ν₂ z.2
    Proof (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
    Causalean.Mathlib.Probability.ProductAbsolutelyContinuous.rnDeriv_prod_eq · Causalean/Mathlib/Probability/ProductAbsolutelyContinuous.lean:29
Signed­Two­Point 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.

def twoPointMean reviewed
Causalean.Mathlib.Probability

For a real scale and a real target mean, the symmetric two-point mean measure is the sum of a point mass at BB weighted by max⁡((1+u/B)/2,0)\max((1+u/B)/2,0) and a point mass at −B-B weighted by max⁡((1−u/B)/2,0)\max((1-u/B)/2,0).

Definition (Lean source)
B u :
ℝ
twoPointMean B u :
ofReal ((1 + u / B) / 2) • Measure.dirac B
+ ofReal ((1 - u / B) / 2) • Measure.dirac (-B)
Causalean.Mathlib.Probability.twoPointMean · Causalean/Mathlib/Probability/SignedTwoPoint.lean:41
lemma bernoulli_mean_channel_kl reviewed
Causalean.Mathlib.Probability

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
B u v :
ℝ
hB :
0 < B
hu :
|u| ≤ B / 2
hv :
|v| ≤ B / 2
≤ ofReal ((u - v) ^ 2 / B ^ 2)
Proof (Lean source)
lemma bernoulli_mean_channel_kl (B u v : ℝ) (hB : 0 < B) (hu : |u| ≤ B / 2) (hv : |v| ≤ B / 2) : klDiv (twoPointMean B u) (twoPointMean B v) ≤ ofReal ((u - v) ^ 2 / B ^ 2) := by let p : ℝ := (1 + u / B) / 2 let q : ℝ := (1 + v / B) / 2 have hB_ne : B ≠ 0 := ne_of_gt hB have hu_bounds := abs_le.mp hu have hv_bounds := abs_le.mp hv have hp_lo : 1 / 4 ≤ p := by dsimp [p] field_simp [hB_ne] nlinarith [hu_bounds.1, hB] have hp_hi : p ≤ 3 / 4 := by dsimp [p] field_simp [hB_ne] nlinarith [hu_bounds.2, hB] have hq_lo : 1 / 4 ≤ q := by dsimp [q] field_simp [hB_ne] nlinarith [hv_bounds.1, hB] have hq_hi : q ≤ 3 / 4 := by dsimp [q] field_simp [hB_ne] nlinarith [hv_bounds.2, hB] haveI : IsFiniteMeasure (bernoulliLaw p) := by rw [bernoulliLaw] refine ⟨?_⟩ rw [Measure.add_apply, Measure.smul_apply, Measure.smul_apply] simp only [Measure.dirac_apply, Set.mem_univ, Set.indicator_of_mem, Pi.one_apply, smul_eq_mul, mul_one] exact ENNReal.add_lt_top.2 ⟨ENNReal.ofReal_lt_top, ENNReal.ofReal_lt_top⟩ haveI : IsFiniteMeasure (bernoulliLaw q) := by rw [bernoulliLaw] refine ⟨?_⟩ rw [Measure.add_apply, Measure.smul_apply, Measure.smul_apply] simp only [Measure.dirac_apply, Set.mem_univ, Set.indicator_of_mem, Pi.one_apply, smul_eq_mul, mul_one] exact ENNReal.add_lt_top.2 ⟨ENNReal.ofReal_lt_top, ENNReal.ofReal_lt_top⟩ rw [twoPointMean_eq_map_bernoulli B u hB.ne', twoPointMean_eq_map_bernoulli B v hB.ne', klDiv_map_measurableEquiv] have hbern : klDiv (bernoulliLaw p) (bernoulliLaw q) ≤ ofReal (4 * (p - q) ^ 2) := bernoulliLaw_klDiv_le_four_sq_sub hp_lo hp_hi hq_lo hq_hi calc klDiv (bernoulliLaw p) (bernoulliLaw q) ≤ ofReal (4 * (p - q) ^ 2) := hbern _ = ofReal ((u - v) ^ 2 / B ^ 2) := by congr 1 subst p subst q field_simp [hB_ne] ring
Causalean.Mathlib.Probability.bernoulli_mean_channel_kl · Causalean/Mathlib/Probability/SignedTwoPoint.lean:174 · uses twoPointMean
8 supporting declarations (lemmas, instances)
  • measurable_twoPointMean lemma — For a fixed scale B, the signed two-point mean channel is measurable as a function of the target mean u.
    B :
    ℝ
    Measurable (fun u : ℝ => twoPointMean B u)
    Proof (Lean source)
    @[fun_prop] lemma measurable_twoPointMean (B : ℝ) : Measurable (fun u : ℝ => twoPointMean B u) := by unfold twoPointMean fun_prop
    Causalean.Mathlib.Probability.measurable_twoPointMean · Causalean/Mathlib/Probability/SignedTwoPoint.lean:48
  • twoPointMean_coef_nonneg lemma — When the scale is positive and the target mean lies within that scale, both weights in the signed two-point distribution are nonnegative.
    B u :
    ℝ
    hB :
    0 < B
    hu :
    |u| ≤ B
    conclusion 1
    0 ≤ (1 + u / B) / 2
    conclusion 2
    0 ≤ (1 - u / B) / 2
    Proof (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]
    Causalean.Mathlib.Probability.twoPointMean_coef_nonneg · Causalean/Mathlib/Probability/SignedTwoPoint.lean:55
  • twoPointMean_isProbabilityMeasure lemma — The signed two-point channel is a probability measure. For 0 < B and |u| ≤ B the total mass of twoPointMean B u is 1.
    B u :
    ℝ
    hB :
    0 < B
    hu :
    |u| ≤ B
    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
    Causalean.Mathlib.Probability.twoPointMean_isProbabilityMeasure · Causalean/Mathlib/Probability/SignedTwoPoint.lean:62
  • twoPointMean_integral lemma — 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).
    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)
    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)
    Causalean.Mathlib.Probability.twoPointMean_integral · Causalean/Mathlib/Probability/SignedTwoPoint.lean:76
  • twoPointMean_mean lemma — The mean is u. For 0 < B and |u| ≤ B, the expectation of the identity under twoPointMean B u is exactly u.
    B u :
    ℝ
    hB :
    0 < B
    hu :
    |u| ≤ B
    ∫ y, y ∂twoPointMean B u = u
    Proof (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
    Causalean.Mathlib.Probability.twoPointMean_mean · Causalean/Mathlib/Probability/SignedTwoPoint.lean:94
  • twoPointMean_bad_support_zero lemma — 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.
    B M :
    ℝ
    wplus wminus :
    ℝ≥0∞
    hBM :
    |B| ≤ M
    (wplus • Measure.dirac B + wminus • Measure.dirac (-B)) {y | y ∉ Icc (-M) M} = 0
    Proof (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
    Causalean.Mathlib.Probability.twoPointMean_bad_support_zero · Causalean/Mathlib/Probability/SignedTwoPoint.lean:102
  • klDiv_map_measurableEquiv lemma — 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(μ, ν).
    α β :
    e :
    α ≃ᵐ β
    klDiv (Measure.map e μ) (Measure.map e ν) = klDiv μ ν
    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μν]
    Causalean.Mathlib.Probability.klDiv_map_measurableEquiv · Causalean/Mathlib/Probability/SignedTwoPoint.lean:128
  • twoPointMean_eq_map_bernoulli lemma — 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).
    B u :
    ℝ
    hB :
    B ≠ 0
    = 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]
    Causalean.Mathlib.Probability.twoPointMean_eq_map_bernoulli · Causalean/Mathlib/Probability/SignedTwoPoint.lean:154
Std­Normal­Moments 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.

lemma integral_Ioi_id_mul_stdNormalPDF reviewed
Causalean.Mathlib

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
c :
ℝ
∫ t in Ioi c, t * stdNormalPDF t = stdNormalPDF c
Proof (Lean source)
lemma integral_Ioi_id_mul_stdNormalPDF (c : ℝ) : ∫ t in Ioi c, t * stdNormalPDF t = stdNormalPDF c := by let phi : ℝ → ℝ := fun x => exp (-x ^ 2 / 2) have phi_pos : ∀ x : ℝ, 0 < phi x := fun x => Real.exp_pos _ have phi_continuous : Continuous phi := by dsimp [phi] fun_prop have gaussianPDFReal_eq : ∀ x : ℝ, gaussianPDFReal 0 1 x = (sqrt (2 * π))⁻¹ * phi x := by intro x unfold gaussianPDFReal dsimp [phi] congr 2 · norm_num · ring have neg_phi_hasDerivAt : ∀ x : ℝ, HasDerivAt (fun y => -phi y) (x * phi x) x := by intro x dsimp [phi] have hpow : HasDerivAt (fun y : ℝ => -y ^ 2 / 2) (-x) x := by have := ((hasDerivAt_pow 2 x).div_const 2).fun_neg simpa [neg_div, pow_one] using this.congr_deriv (by ring) have hcomp : HasDerivAt (fun y => exp (-y ^ 2 / 2)) (exp (-x ^ 2 / 2) * (-x)) x := (Real.hasDerivAt_exp _).comp x hpow exact hcomp.fun_neg.congr_deriv (by ring) have abs_le_exp_sq_div_four : ∀ x : ℝ, |x| ≤ exp (x ^ 2 / 4) := by intro x have h1 : |x| ≤ 1 + x ^ 2 / 4 := by nlinarith [sq_nonneg (|x| / 2 - 1), sq_abs x, abs_nonneg x] exact h1.trans (by have := Real.add_one_le_exp (x ^ 2 / 4); linarith) have x_mul_phi_integrable : Integrable (fun x : ℝ => x * phi x) := by have hdom : Integrable (fun x : ℝ => exp (-(1/4 : ℝ) * x ^ 2)) := integrable_exp_neg_mul_sq (by norm_num) refine hdom.mono' ((continuous_id.mul phi_continuous).aestronglyMeasurable) ?_ filter_upwards with x have hexp : phi x = exp (-(1/2 : ℝ) * x ^ 2) := by dsimp [phi] ring_nf rw [Real.norm_eq_abs, abs_mul, abs_of_nonneg (phi_pos x).le, hexp] calc |x| * exp (-(1/2 : ℝ) * x ^ 2) ≤ exp (x ^ 2 / 4) * exp (-(1/2 : ℝ) * x ^ 2) := by gcongr exact abs_le_exp_sq_div_four x _ = exp (-(1/4 : ℝ) * x ^ 2) := by rw [← Real.exp_add] congr 1 ring have mul_phi_integrableOn_Ioi : IntegrableOn (fun x => x * phi x) (Ioi c) := by exact x_mul_phi_integrable.integrableOn have neg_phi_tendsto_atTop : Tendsto (fun x => -phi x) atTop (nhds 0) := by have : Tendsto phi atTop (nhds 0) := by dsimp [phi] have hsq : Tendsto (fun x : ℝ => x ^ 2) atTop atTop := by exact Filter.tendsto_pow_atTop (α := ℝ) (n := 2) (by norm_num) have h2 : Tendsto (fun x : ℝ => -x ^ 2 / 2) atTop atBot := by apply Filter.Tendsto.atBot_div_const (by norm_num) exact Filter.tendsto_neg_atBot_iff.mpr hsq exact Real.tendsto_exp_atBot.comp h2 simpa using this.neg have integral_Ioi_mul_phi : ∫ x in Ioi c, x * phi x = phi c := by have := integral_Ioi_of_hasDerivAt_of_tendsto' (f := fun y => -phi y) (f' := fun x => x * phi x) (a := c) (m := 0) (fun x _ => neg_phi_hasDerivAt x) mul_phi_integrableOn_Ioi neg_phi_tendsto_atTop simpa using this calc ∫ t in Ioi c, t * stdNormalPDF t = ∫ t in Ioi c, (sqrt (2 * π))⁻¹ * (t * phi t) := by congr 1 ext t rw [stdNormalPDF, gaussianPDFReal_eq] ring _ = (sqrt (2 * π))⁻¹ * ∫ t in Ioi c, t * phi t := by rw [integral_const_mul] _ = (sqrt (2 * π))⁻¹ * phi c := by rw [integral_Ioi_mul_phi] _ = stdNormalPDF c := by rw [stdNormalPDF, gaussianPDFReal_eq]
Causalean.Mathlib.integral_Ioi_id_mul_stdNormalPDF · Causalean/Mathlib/Probability/StdNormalMoments.lean:56 · uses stdNormalPDF
1 supporting declaration (lemmas, instances)
Variance­Prod 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.

lemma variance_prod_eq_integral_variance_add reviewed
Causalean.Mathlib.Probability

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.

Formal statement
μ :
ν :
F :
Ω × T → ℝ
m :
T → ℝ
hF :
MemLp F 2 (μ.prod ν)
hsection :
∀ᵐ t ∂ν, MemLp (fun s => F (s, t)) 2 μ
hm :
MemLp m 2 ν
hmean :
∀ᵐ t ∂ν, (∫ s, F (s, t) ∂μ) = m t
variance F (μ.prod ν) = (∫ t, variance (fun s => F (s, t)) μ ∂ν) + variance m ν
Proof (Lean source)
lemma variance_prod_eq_integral_variance_add {Ω T : Type*} [MeasurableSpace Ω] [MeasurableSpace T] (μ : Measure Ω) (ν : Measure T) [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] (F : Ω × T → ℝ) (m : T → ℝ) (hF : MemLp F 2 (μ.prod ν)) (hsection : ∀ᵐ t ∂ν, MemLp (fun s => F (s, t)) 2 μ) (hm : MemLp m 2 ν) (hmean : ∀ᵐ t ∂ν, (∫ s, F (s, t) ∂μ) = m t) : variance F (μ.prod ν) = (∫ t, variance (fun s => F (s, t)) μ ∂ν) + variance m ν := by have hFsq : Integrable (fun z => F z ^ 2) (μ.prod ν) := hF.integrable_sq have hinnerSq : Integrable (fun t => ∫ s, F (s, t) ^ 2 ∂μ) ν := by simpa only [Function.uncurry_apply_pair] using hFsq.integral_prod_right have hvariance : (fun t => variance (fun s => F (s, t)) μ) =ᵐ[ν] fun t => (∫ s, F (s, t) ^ 2 ∂μ) - (m t) ^ 2 := by filter_upwards [hsection, hmean] with t htsection htmean rw [variance_eq_sub htsection, htmean] simp only [Pi.pow_apply] rw [variance_eq_sub hF, variance_eq_sub hm] rw [integral_congr_ae hvariance] simp only [Pi.pow_apply] rw [integral_sub hinnerSq hm.integrable_sq] rw [integral_prod_symm _ hFsq] have hFint : Integrable F (μ.prod ν) := hF.integrable (by norm_num) rw [integral_prod_symm _ hFint] rw [integral_congr_ae hmean] ring
Causalean.Mathlib.Probability.variance_prod_eq_integral_variance_add · Causalean/Mathlib/Probability/VarianceProd.lean:26