Mathlib.Probability.Certified­Finite­Markov­Expectation.Certified­Normal­CDFEnclosure

Scalable proof-producing rational enclosures for standard-normal CDF values, combining central Gaussian power series, exact normalization and exponential certificates, symmetry, and Mills-ratio tails.

Basic 5 core · 3 supporting This module fixes the supported numerical range and target cell width, and packages the exact interval reflection used to transport a certificate between positive and negative endpoints. ★ stdNormalCDF_eq_half_add_scale_mul_integral

Basic operations for certified standard-normal CDF enclosures

This module fixes the supported numerical range and target cell width, and packages the exact interval reflection used to transport a certificate between positive and negative endpoints. The analytic CDF is Causalean's stdNormalCDF; all reported endpoints remain exact rationals.

def targetWidth reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

The requested maximum width of a high-precision caller cell is exactly 10⁻¹², represented as a rational rather than a floating-point number.

Definition (Lean source)
targetWidth :
1 / 10 ^ 12
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.targetWidth · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Basic.lean:16
def supportedEndpointBound reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

The reusable checker is required to support endpoints of absolute value at most 193 / 5.

Definition (Lean source)
supportedEndpointBound :
193 / 5
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.supportedEndpointBound · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Basic.lean:20
def centralCutoff reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

The central-series/tail boundary is the exact rational number eight.

Definition (Lean source)
centralCutoff :
8
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.centralCutoff · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Basic.lean:24
def reflectInterval reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

Reflecting an interval I across one half produces the interval 1 - I.

Definition (Lean source)
reflectInterval I :
(RatInterval.point 1).sub I
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.reflectInterval · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Basic.lean:27 · uses RatInterval
theorem stdNormalCDF_eq_half_add_scale_mul_integral reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

At a rational endpoint with nonnegative value, the standard-normal CDF is one half plus the density normalization constant times the unnormalised Gaussian integral from zero to that endpoint.

Formal statement
q :
hq :
0 ≤ q
stdNormalCDF (q : ℝ)
= (1 / 2 : ℝ)
+ (1 / sqrt (2 * pi)) * (∫ t in (0 : ℝ)..(q : ℝ), exp (-(t ^ 2) / 2))
Proof (Lean source)
theorem stdNormalCDF_eq_half_add_scale_mul_integral (q : ℚ) (hq : 0 ≤ q) : stdNormalCDF (q : ℝ) = (1 / 2 : ℝ) + (1 / sqrt (2 * pi)) * (∫ t in (0 : ℝ)..(q : ℝ), exp (-(t ^ 2) / 2)) := by rw [stdNormalCDF_eq_half_add_rescaled_integral q hq] congr 1 have hsubst : (∫ u in (0 : ℝ)..1, (q : ℝ) * stdNormalPDF ((q : ℝ) * u)) = ∫ x in (0 : ℝ)..(q : ℝ), stdNormalPDF x := by rw [intervalIntegral.integral_const_mul, intervalIntegral.mul_integral_comp_mul_left] simp rw [hsubst, ← intervalIntegral.integral_const_mul] apply intervalIntegral.integral_congr intro x hx simp [stdNormalPDF, gaussianPDFReal]
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.stdNormalCDF_eq_half_add_scale_mul_integral · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Basic.lean:53 · uses stdNormalCDF
3 supporting declarations (lemmas, instances)
Exponential 5 core · 4 supporting A caller supplies a natural split m, a Taylor degree, and an enclosure; the Boolean checker verifies 0 < m, |q/m| ≤ 1, and exact interval refinement. ★ sound

Finite rational exponential certificates with explicit range reduction

A caller supplies a natural split m, a Taylor degree, and an enclosure; the Boolean checker verifies 0 < m, |q/m| ≤ 1, and exact interval refinement. Raising the checked Taylor interval to m encloses exp q. For normal tails the exponent has magnitude below 745, so a split of at most 745 suffices independently of the denominator of the rational endpoint.

def expTaylorInterval reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

The finite Taylor interval for exp z, using Causalean's exact rational partial sum and explicit remainder radius.

Definition (Lean source)
z :
degree :
expTaylorInterval z degree :
expReducedRaw z degree
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.expTaylorInterval · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Exponential.lean:18 · uses RatInterval
structure ExpCertificate reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

A finite exponential certificate is raw caller-supplied range-reduction, Taylor-degree, and rational-enclosure data; expCheck validates it.

Definition (Lean source)
q :
Number of equal exponent pieces.
split :
Taylor truncation index for the reduced exponent.
degree :
Rational interval exposed to the tail checker.
enclosure :
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.ExpCertificate · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Exponential.lean:119
def expCertificateInterval reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

The exact interval computed from the caller's split and Taylor degree.

Definition (Lean source)
q :
expCertificateInterval c :
(expTaylorInterval (q / (c.split : ℚ)) c.degree).npow c.split
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.expCertificateInterval · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Exponential.lean:129 · uses RatInterval , ExpCertificate
def expCheck reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

The executable exponential checker validates positive range reduction, a unit reduced argument, and exact refinement into the reported interval.

Definition (Lean source)
q :
expCheck q c :
decide (0 < c.split ∧ |q / (c.split : ℚ)| ≤ 1 ∧ c.enclosure.lo ≤ (expCertificateInterval c).lo ∧ (expCertificateInterval c).hi ≤ c.enclosure.hi)
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.expCheck · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Exponential.lean:133 · uses ExpCertificate
theorem sound reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.ExpCertificate

A finite rational exponential certificate whose executable check succeeds contains the real exponential at its certified argument.

Formal statement
q :
hcheck :
c.enclosure.Contains (exp (q : ℝ))
Proof (Lean source)
theorem ExpCertificate.sound {q : ℚ} (c : ExpCertificate q) (hcheck : expCheck q c = true) : c.enclosure.Contains (exp (q : ℝ)) := by -- Decode the three rational checks. Enclose the reduced exponential with -- `expTaylorInterval_sound`, raise it using `RatInterval.npow_sound`, and -- identify the enclosed power with `exp q` via `Real.exp_nat_mul` and the -- nonzero real cast of the checked positive split. Finish by monotonicity -- along the checked `Subinterval` relation. have hchecked : 0 < c.split ∧ |q / (c.split : ℚ)| ≤ 1 ∧ c.enclosure.lo ≤ (expCertificateInterval c).lo ∧ (expCertificateInterval c).hi ≤ c.enclosure.hi := of_decide_eq_true (by simpa [expCheck] using hcheck) rcases hchecked with ⟨hsplit, hreduced, hlo, hhi⟩ have hbase := expTaylorInterval_sound (q / (c.split : ℚ)) hreduced c.degree have hpow := RatInterval.npow_sound hbase c.split have hsplitR : (c.split : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt hsplit) have hmul : (c.split : ℝ) * ((q / (c.split : ℚ) : ℚ) : ℝ) = (q : ℝ) := by rw [Rat.cast_div] exact mul_div_cancel₀ _ hsplitR have hexp : exp ((q / (c.split : ℚ) : ℚ) : ℝ) ^ c.split = exp (q : ℝ) := by rw [← Real.exp_nat_mul, hmul] have hsub : (expCertificateInterval c).Subinterval c.enclosure := ⟨hlo, hhi⟩ apply RatInterval.Contains.mono hsub rw [← hexp] exact hpow
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.ExpCertificate.sound · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Exponential.lean:140 · uses Contains , ExpCertificate , expCheck
4 supporting declarations (lemmas, instances)
  • expTaylorInterval_sound theorem — On the unit interval, the finite rational Taylor interval encloses the real exponential.
    z :
    hz :
    |z| ≤ 1
    degree :
    (expTaylorInterval z degree).Contains (exp (z : ℝ))
    Proof (Lean source)
    theorem expTaylorInterval_sound (z : ℚ) (hz : |z| ≤ 1) (degree : ℕ) : (expTaylorInterval z degree).Contains (exp (z : ℝ)) := by -- Follow the reduced-input part of Causalean's `expRaw_sound`: apply -- `Real.exp_bound`, then identify its partial sum and remainder with -- `Transcendental.expPartial` and `expRemainder` by exact casts. have hzR : |(z : ℝ)| ≤ 1 := by exact_mod_cast hz have hb := Real.exp_bound hzR (n := degree + 1) (Nat.succ_pos degree) have hp : ((Transcendental.expPartial z degree : ℚ) : ℝ) = ∑ k ∈ range (degree + 1), (z : ℝ) ^ k / (k.factorial : ℝ) := by simp [Transcendental.expPartial] have hr : ((Transcendental.expRemainder z degree : ℚ) : ℝ) = |(z : ℝ)| ^ (degree + 1) * ((degree + 2 : ℕ) : ℝ) / (((degree + 1).factorial : ℝ) * (degree + 1 : ℕ)) := by simp [Transcendental.expRemainder] rw [← hp] at hb have hb' : |exp (z : ℝ) - (Transcendental.expPartial z degree : ℝ)| ≤ (Transcendental.expRemainder z degree : ℝ) := by rw [hr] convert hb using 1 <;> norm_num [Nat.cast_succ] <;> ring rw [abs_le] at hb' simp only [expTaylorInterval, Transcendental.expReducedRaw, RatInterval.Contains, Rat.cast_sub, Rat.cast_add] constructor <;> linarith [hb'.1, hb'.2]
    Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.expTaylorInterval_sound · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Exponential.lean:24
  • expTaylorInterval_width theorem — The width of the raw reduced exponential interval is exactly twice its explicit rational Taylor remainder radius.
    z :
    degree :
    (expTaylorInterval z degree).width = 2 * Transcendental.expRemainder z degree
    Proof (Lean source)
    theorem expTaylorInterval_width (z : ℚ) (degree : ℕ) : (expTaylorInterval z degree).width = 2 * Transcendental.expRemainder z degree := by -- Unfold the interval endpoints and its width, then use ring arithmetic. simp only [expTaylorInterval, Transcendental.expReducedRaw, RatInterval.width] ring
    Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.expTaylorInterval_width · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Exponential.lean:54
  • two_pow_le_factorial_succ theorem — The factorial (n+1)! dominates 2^n; this is the discrete estimate used to turn Taylor factorial decay into a geometric precision bound.
    n :
    2 ^ n ≤ (n + 1).factorial
    Proof (Lean source)
    theorem two_pow_le_factorial_succ (n : ℕ) : 2 ^ n ≤ (n + 1).factorial := by -- Induct on `n`; rewrite both recurrences and use `2 ≤ n+2`. induction n with | zero => norm_num | succ n ih => rw [pow_succ, Nat.factorial_succ] calc 2 ^ n * 2 ≤ (n + 1).factorial * 2 := Nat.mul_le_mul_right 2 ih _ ≤ (n + 1).factorial * (n + 1 + 1) := by gcongr <;> omega _ = (n + 1 + 1) * (n + 1).factorial := Nat.mul_comm _ _
    Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.two_pow_le_factorial_succ · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Exponential.lean:64
  • expTaylorInterval_width_le_geometric theorem — From degree one onward, the unit-range exponential interval has width at most 3 / 2^degree, explicitly witnessing logarithmic degree in inverse target width.
    z :
    hz :
    |z| ≤ 1
    degree :
    hdegree :
    1 ≤ degree
    (expTaylorInterval z degree).width ≤ 3 / (2 : ℚ) ^ degree
    Proof (Lean source)
    theorem expTaylorInterval_width_le_geometric (z : ℚ) (hz : |z| ≤ 1) (degree : ℕ) (hdegree : 1 ≤ degree) : (expTaylorInterval z degree).width ≤ 3 / (2 : ℚ) ^ degree := by -- Rewrite the width with `expTaylorInterval_width`. Bound `|z|^(n+1)` by -- one, `(n+2)/(n+1)` by `3/2`, and use -- `two_pow_le_factorial_succ`; clear only manifestly positive denominators. have habsPow : |z| ^ (degree + 1) ≤ (1 : ℚ) := pow_le_one₀ (abs_nonneg z) hz have hratioNat : 2 * (degree + 2) ≤ 3 * (degree + 1) := by omega have hratio : (2 : ℚ) * |z| ^ (degree + 1) * (degree + 2 : ℕ) ≤ 3 * (degree + 1 : ℕ) := by calc (2 : ℚ) * |z| ^ (degree + 1) * (degree + 2 : ℕ) ≤ 2 * 1 * (degree + 2 : ℕ) := by gcongr _ ≤ 3 * (degree + 1 : ℕ) := by exact_mod_cast hratioNat have hfactorialQ : (2 : ℚ) ^ degree ≤ ((degree + 1).factorial : ℚ) := by exact_mod_cast two_pow_le_factorial_succ degree have hcross : ((2 : ℚ) * |z| ^ (degree + 1) * (degree + 2 : ℕ)) * 2 ^ degree ≤ 3 * (((degree + 1).factorial : ℚ) * (degree + 1 : ℕ)) := by calc ((2 : ℚ) * |z| ^ (degree + 1) * (degree + 2 : ℕ)) * 2 ^ degree ≤ (3 * (degree + 1 : ℕ)) * 2 ^ degree := by gcongr _ ≤ (3 * (degree + 1 : ℕ)) * ((degree + 1).factorial : ℚ) := by gcongr _ = 3 * (((degree + 1).factorial : ℚ) * (degree + 1 : ℕ)) := by ring rw [expTaylorInterval_width, Transcendental.expRemainder] rw [show (2 : ℚ) * (|z| ^ (degree + 1) * (degree + 2 : ℕ) / (((degree + 1).factorial : ℚ) * (degree + 1 : ℕ))) = ((2 : ℚ) * |z| ^ (degree + 1) * (degree + 2 : ℕ)) / (((degree + 1).factorial : ℚ) * (degree + 1 : ℕ)) by ring] apply (div_le_div_iff₀ (by positivity) (by positivity)).2 exact hcross
    Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.expTaylorInterval_width_le_geometric · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Exponential.lean:78
Normalization 6 core · 1 supporting This module isolates the reusable exact-rational certificate for 1 / sqrt (2 * π). ★ sound

Certified normalization intervals for the standard normal density

This module isolates the reusable exact-rational certificate for 1 / sqrt (2 * π). It reuses Causalean's Machin enclosure for π, rational square-root enclosure, and interval reciprocal, without invoking its uniform normal-CDF quadrature.

structure NormalizationSchedule reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

A normalization schedule is the finite precision datum used for the Machin-π and Newton square-root computations.

Definition (Lean source)
Precision used by the certified `π` and square-root evaluators.
fuel :
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.NormalizationSchedule · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Normalization.lean:17
def normalizationInterval reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

The raw normalization interval is the reciprocal square-root enclosure when its exact rational guards succeed, and a harmless fallback otherwise.

Definition (Lean source)
normalizationInterval s :
if htwoPi : 0
≤ (twoPiInterval s.fuel).lo then let root := RatInterval.sqrtInterval (twoPiInterval s.fuel) htwoPi s.fuel if hroot : root.hi < 0 ∨ 0 < root.lo then root.inv hroot else RatInterval.point 0 else RatInterval.point 0
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.normalizationInterval · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Normalization.lean:23 · uses RatInterval , NormalizationSchedule
def normalizationScheduleCheck reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

The executable schedule checker validates that the computed interval is nonnegative and that its square-root enclosure excludes zero.

Definition (Lean source)
normalizationScheduleCheck s :
if htwoPi : 0
≤ (twoPiInterval s.fuel).lo then let root := RatInterval.sqrtInterval (twoPiInterval s.fuel) htwoPi s.fuel decide (root.hi < 0 ∨ 0 < root.lo) else false
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.normalizationScheduleCheck · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Normalization.lean:31 · uses NormalizationSchedule
structure NormalizationCertificate reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

A normalization certificate is raw finite schedule and caller-enclosure data; normalizationCheck validates all side conditions.

Definition (Lean source)
Finite exact-arithmetic schedule for the normalization constant.
Caller-facing enclosure of `1 / sqrt (2π)`.
enclosure :
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.NormalizationCertificate · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Normalization.lean:39
def normalizationCheck reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

The executable normalization checker validates every guarded interval operation and the exact rational refinement into the caller's enclosure.

Definition (Lean source)
normalizationCheck c :
normalizationScheduleCheck c.schedule && decide (c.enclosure.lo ≤ (normalizationInterval c.schedule).lo ∧ (normalizationInterval c.schedule).hi ≤ c.enclosure.hi)
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.normalizationCheck · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Normalization.lean:47 · uses NormalizationCertificate
theorem sound reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.NormalizationCertificate

A normalization certificate whose executable check succeeds contains the standard-normal density scale.

Formal statement
c.enclosure.Contains (1 / sqrt (2 * pi))
Proof (Lean source)
theorem NormalizationCertificate.sound (c : NormalizationCertificate) (hcheck : normalizationCheck c = true) : c.enclosure.Contains (1 / sqrt (2 * pi)) := by -- Split the Boolean conjunction, decode the exact `Subinterval` decision, -- and apply `RatInterval.Contains.mono` to `normalizationInterval_sound`. unfold normalizationCheck at hcheck rw [Bool.and_eq_true] at hcheck rcases hcheck with ⟨hschedule, hrefinement⟩ have hrefinement' : c.enclosure.lo ≤ (normalizationInterval c.schedule).lo ∧ (normalizationInterval c.schedule).hi ≤ c.enclosure.hi := of_decide_eq_true hrefinement exact (normalizationInterval_sound c.schedule hschedule).mono hrefinement'
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.NormalizationCertificate.sound · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Normalization.lean:78 · uses Contains , NormalizationCertificate , normalizationCheck
1 supporting declaration (lemmas, instances)
Central 5 core · 0 supporting Central certificates combine an exact Gaussian-integral alternating enclosure with a certified rational normalization constant. ★ centralCheck_sound

Central-range standard-normal CDF certificates

Central certificates combine an exact Gaussian-integral alternating enclosure with a certified rational normalization constant. Absolute value reduces the work to a nonnegative endpoint and reflectInterval transports the result back to a negative endpoint.

structure CentralCertificate reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

Finite certificate data for central evaluation: a series degree and a certified enclosure of 1 / sqrt (2π).

Definition (Lean source)
Last included Gaussian-integral series index.
degree :
Certified normalization constant used to scale the raw integral.
normalization :
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.CentralCertificate · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Central.lean:17
def centralMagnitudeInterval reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

The positive-magnitude central evaluator returns 1/2 plus the product of the normalization enclosure and alternating integral enclosure.

Definition (Lean source)
x :
centralMagnitudeInterval x c :
(RatInterval.point (1 / 2)).add (c.normalization.enclosure.mul (gaussianIntegralInterval x c.degree))
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.centralMagnitudeInterval · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Central.lean:25 · uses RatInterval , CentralCertificate
def centralInterval reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

The signed central evaluator uses CDF symmetry when the endpoint is negative.

Definition (Lean source)
q :
centralInterval q c :
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.centralInterval · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Central.lean:31 · uses RatInterval , CentralCertificate
def centralCheck reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

The central checker validates normalization, the cutoff, the exact alternating-tail condition, and refinement into the caller-supplied interval.

Definition (Lean source)
q :
reported :
centralCheck q c reported :
normalizationCheck c.normalization && decide (|q| ≤ centralCutoff ∧ |q| ^ 2 ≤ 2 * (c.degree + 2 : ℕ) ∧ reported.lo ≤ (centralInterval q c).lo ∧ (centralInterval q c).hi ≤ reported.hi)
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.centralCheck · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Central.lean:37 · uses RatInterval , CentralCertificate
theorem centralCheck_sound reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

When the central-series checker accepts the supplied certificate and interval, that interval contains the standard-normal CDF at the rational endpoint.

Formal statement
q :
reported :
hcheck :
centralCheck q c reported = true
reported.Contains (stdNormalCDF (q : ℝ))
Proof (Lean source)
theorem centralCheck_sound {q : ℚ} {c : CentralCertificate} {reported : RatInterval} (hcheck : centralCheck q c reported = true) : reported.Contains (stdNormalCDF (q : ℝ)) := by unfold centralCheck at hcheck rw [Bool.and_eq_true] at hcheck rcases hcheck with ⟨hnormalization, hconditions⟩ have hconditions' : |q| ≤ centralCutoff ∧ |q| ^ 2 ≤ 2 * (c.degree + 2 : ℕ) ∧ reported.lo ≤ (centralInterval q c).lo ∧ (centralInterval q c).hi ≤ reported.hi := of_decide_eq_true hconditions rcases hconditions' with ⟨_, hmono, hlo, hhi⟩ have hmagnitude : (centralMagnitudeInterval |q| c).Contains (stdNormalCDF (((|q| : ℚ) : ℝ))) := by rw [stdNormalCDF_eq_half_add_scale_mul_integral |q| (abs_nonneg q)] have hhalf : (RatInterval.point (1 / 2)).Contains (1 / 2 : ℝ) := by norm_num [RatInterval.point, RatInterval.Contains] exact RatInterval.add_sound hhalf (RatInterval.mul_sound (c.normalization.sound hnormalization) (gaussianIntegralInterval_sound |q| (abs_nonneg q) c.degree hmono)) have hcentral : (centralInterval q c).Contains (stdNormalCDF (q : ℝ)) := by by_cases hq : 0 ≤ q · simpa [centralInterval, hq, abs_of_nonneg hq] using hmagnitude · have hqneg : q < 0 := lt_of_not_ge hq have hqabs : q = -|q| := by simp [abs_of_neg hqneg] rw [centralInterval, if_neg hq] have hreflected := reflectInterval_stdNormalCDF_sound hmagnitude rw [show (q : ℝ) = -(((|q| : ℚ) : ℝ)) by exact_mod_cast hqabs] exact hreflected exact RatInterval.Contains.mono ⟨hlo, hhi⟩ hcentral
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.centralCheck_sound · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Central.lean:46 · uses RatInterval , Contains , CentralCertificate , centralCheck , stdNormalCDF
Checker 7 core · 5 supporting The public checker consumes a caller-supplied rational interval and finite certificate data. ★ normalCDFCheck_sound

Top-level certified standard-normal CDF checker

The public checker consumes a caller-supplied rational interval and finite certificate data. It selects either the central power-series check or the Mills-tail check, validates every rational side condition, and proves that the reported interval contains the exact standard-normal CDF. It also exposes the subtraction rule needed for transition probabilities formed from CDF differences.

inductive MethodCertificate reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

The top-level certificate method is either a central-series certificate or a tail certificate tied to the endpoint whose exponential it encloses.

Definition (Lean source)
q :
MethodCertificate q :
Type
central :
(certificate : CentralCertificate)

Use the central alternating Gaussian-integral series.

tail :
(certificate : TailCertificate q)

Use the Mills-ratio tail evaluator.

Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.MethodCertificate · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Checker.lean:19
def normalCDFCheck reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

The top-level executable checker dispatches to the selected method and validates the caller-supplied rational enclosure.

Definition (Lean source)
q :
method :
reported :
normalCDFCheck q method reported :
match method with | .central certificate
=> centralCheck q certificate reported | .tail certificate => tailCheck q certificate reported
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.normalCDFCheck · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Checker.lean:27 · uses RatInterval , MethodCertificate
theorem normalCDFCheck_sound reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

When the selected top-level certificate check succeeds, the caller-supplied rational interval contains the exact standard-normal CDF at its endpoint.

Formal statement
reported :
hcheck :
normalCDFCheck q method reported = true
reported.Contains (stdNormalCDF (q : ℝ))
Proof (Lean source)
theorem normalCDFCheck_sound {q : ℚ} {method : MethodCertificate q} {reported : RatInterval} (hcheck : normalCDFCheck q method reported = true) : reported.Contains (stdNormalCDF (q : ℝ)) := by cases method with | central c => exact centralCheck_sound hcheck | tail c => exact tailCheck_sound hcheck
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.normalCDFCheck_sound · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Checker.lean:35 · uses RatInterval , Contains , MethodCertificate , normalCDFCheck , stdNormalCDF
def fineNormalCDFCheck reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

The executable high-precision checker accepts exactly when the analytic checker accepts and the caller's endpoint and reported width satisfy the exact rational limits |q| ≤ 193/5 and width ≤ 10⁻¹².

Definition (Lean source)
q :
method :
reported :
fineNormalCDFCheck q method reported :
normalCDFCheck q method reported && decide (|q| ≤ supportedEndpointBound ∧ reported.width ≤ targetWidth)
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.fineNormalCDFCheck · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Checker.lean:43 · uses RatInterval , MethodCertificate
structure NormalCDFCertificate reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

A proof-producing endpoint certificate packages caller data with the successful result of the executable checker.

Definition (Lean source)
q :
Central or tail finite certificate data.
method :
Rational interval supplied by the caller.
enclosure :
The exact checker accepts the supplied interval.
checked :
normalCDFCheck q method enclosure = true
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.NormalCDFCertificate · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Checker.lean:62
structure FineNormalCDFCertificate reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

A fine endpoint certificate packages its data with successful evaluation of the public executable high-precision checker; range and width are checked, not separately trusted as caller-provided proof fields.

Definition (Lean source)
q :
Central or tail finite certificate data.
method :
Rational interval supplied by the caller.
enclosure :
The exact checker accepts containment, range, and width simultaneously.
checked :
fineNormalCDFCheck q method enclosure = true
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.FineNormalCDFCertificate · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Checker.lean:77
def toNormalCDFCertificate reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.FineNormalCDFCertificate

Forgetting the fine limits yields an ordinary checked CDF certificate.

Definition (Lean source)
q :
toNormalCDFCertificate c :
NormalCDFCertificate q
clause 1
method := c.method
clause 2
enclosure := c.enclosure
clause 3
checked := by have h := c.checked simp only [fineNormalCDFCheck, Bool.and_eq_true] at h exact h.1
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.FineNormalCDFCertificate.toNormalCDFCertificate · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Checker.lean:88 · uses FineNormalCDFCertificate , NormalCDFCertificate
5 supporting declarations (lemmas, instances)
Power­Series 7 core · 9 supporting The unnormalised integral ∫₀ˣ exp (-t²/2) dt has rational coefficients (-1)^k x^(2k+1) / (2^k k! ★ gaussianIntegralInterval_sound

Exact power-series enclosures for the Gaussian integral

The unnormalised integral ∫₀ˣ exp (-t²/2) dt has rational coefficients (-1)^k x^(2k+1) / (2^k k! (2k+1)). Once the coefficient magnitudes are decreasing, two consecutive partial sums bracket the integral. This is the central-range engine; it uses a finite sum whose degree grows with requested precision and never constructs a mesh of reciprocal-width size.

The formulas follow the classical error-function series recorded in NIST DLMF §7.6(i), after substituting z = x / sqrt 2.

def gaussianIntegralMagnitude reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

The magnitude of the kth integrated Gaussian-series term at x, namely x to the power 2k+1 divided by 2^k k! (2k+1). It is nonnegative for nonnegative x, which is how it is used; for negative x the same formula is negative.

Definition (Lean source)
x :
k :
gaussianIntegralMagnitude x k :
x ^ (2 * k + 1) / ((2 : ℝ) ^ k * (k.factorial : ℝ) * (2 * k + 1 : ℕ))
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.gaussianIntegralMagnitude · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/PowerSeries.lean:23
def gaussianIntegrandTerm reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

The kth function in the power series for exp (-t²/2).

Definition (Lean source)
k :
t :
gaussianIntegrandTerm k t :
(-1 : ℝ) ^ k * t ^ (2 * k) / ((2 : ℝ) ^ k * (k.factorial : ℝ))
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.gaussianIntegrandTerm · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/PowerSeries.lean:30
def gaussianIntegralTerm reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

The exact rational kth signed term in the integrated Gaussian power series at the rational endpoint x.

Definition (Lean source)
x :
k :
gaussianIntegralTerm x k :
(-1 : ℚ) ^ k * x ^ (2 * k + 1) / ((2 : ℚ) ^ k * (k.factorial : ℚ) * (2 * k + 1 : ℕ))
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.gaussianIntegralTerm · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/PowerSeries.lean:93
def gaussianIntegralPartial reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

The exact rational Gaussian-integral partial sum through degree index n.

Definition (Lean source)
x :
n :
gaussianIntegralPartial x n :
∑ k ∈ range (n + 1), gaussianIntegralTerm x k
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.gaussianIntegralPartial · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/PowerSeries.lean:99
def gaussianIntegralRemainder reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

The first omitted coefficient magnitude after partial sum index n.

Definition (Lean source)
x :
n :
gaussianIntegralRemainder x n :
|x| ^ (2 * (n + 1) + 1) / ((2 : ℚ) ^ (n + 1) * ((n + 1).factorial : ℚ) * (2 * (n + 1) + 1 : ℕ))
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.gaussianIntegralRemainder · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/PowerSeries.lean:103
def gaussianIntegralInterval reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

The alternating enclosure is the rational interval whose endpoints are two consecutive Gaussian-integral partial sums.

Definition (Lean source)
x :
n :
gaussianIntegralInterval x n :
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.gaussianIntegralInterval · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/PowerSeries.lean:109 · uses RatInterval
theorem gaussianIntegralInterval_sound reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

At a rational endpoint that is nonnegative, with a partial-sum index satisfying the exact decreasing-tail condition, two consecutive rational Gaussian-series sums enclose the unnormalised Gaussian integral.

Formal statement
x :
hx :
0 ≤ x
n :
hmono :
x ^ 2 ≤ 2 * (n + 2 : ℕ)
(gaussianIntegralInterval x n).Contains (∫ t in (0 : ℝ)..(x : ℝ), exp (-(t ^ 2) / 2))
Proof (Lean source)
theorem gaussianIntegralInterval_sound (x : ℚ) (hx : 0 ≤ x) (n : ℕ) (hmono : x ^ 2 ≤ 2 * (n + 2 : ℕ)) : (gaussianIntegralInterval x n).Contains (∫ t in (0 : ℝ)..(x : ℝ), exp (-(t ^ 2) / 2)) := by have hxR : (0 : ℝ) ≤ (x : ℝ) := by exact_mod_cast hx have hmonoR : (x : ℝ) ^ 2 ≤ 2 * ((n + 2 : ℕ) : ℝ) := by exact_mod_cast hmono let a : ℕ → ℝ := fun k => gaussianIntegralMagnitude (x : ℝ) k let s : ℕ → ℝ := fun k => (-1 : ℝ) ^ k * a k have hs : HasSum s (∫ t in (0 : ℝ)..(x : ℝ), exp (-(t ^ 2) / 2)) := by exact gaussianIntegral_hasSum (x : ℝ) hxR have ha : Summable a := by have habs : Summable (fun k => ‖s k‖) := hs.summable.norm apply habs.congr intro k simp only [s, Real.norm_eq_abs, abs_mul, abs_pow, abs_neg, abs_one, one_pow, one_mul, abs_of_nonneg (gaussianIntegralMagnitude_nonneg (x : ℝ) hxR k), a] have hanti := gaussianIntegralMagnitude_antitone_from (x : ℝ) hxR n hmonoR have hb : Summable (fun j => a (j + (n + 1))) := (summable_nat_add_iff (n + 1)).2 ha have hbanti : Antitone (fun j => a (j + (n + 1))) := by refine antitone_nat_of_succ_le ?_ intro j simpa only [Nat.add_assoc, Nat.add_comm, Nat.add_left_comm] using hanti (j + (n + 1)) (by omega) let r : ℝ := ∑' j, (-1 : ℝ) ^ j * a (j + (n + 1)) have hr_tendsto := hb.tendsto_alternating_series_tsum have hr0 : 0 ≤ r := by have h := hbanti.alternating_series_le_tendsto hr_tendsto 0 exact h have hrle : r ≤ a (n + 1) := by have h := hbanti.tendsto_le_alternating_series hr_tendsto 0 simpa [r] using h have htail : (∑' j, s (j + (n + 1))) = (-1 : ℝ) ^ (n + 1) * r := by rw [← tsum_mul_left] apply tsum_congr intro j simp only [s, pow_add] ring have hsplit := hs.summable.sum_add_tsum_nat_add (n + 1) rw [hs.tsum_eq, htail] at hsplit have hrepresentation : (∫ t in (0 : ℝ)..(x : ℝ), exp (-(t ^ 2) / 2)) = (∑ k ∈ range (n + 1), s k) + (-1 : ℝ) ^ (n + 1) * r := hsplit.symm have hterm_cast (k : ℕ) : ((gaussianIntegralTerm x k : ℚ) : ℝ) = s k := by simp only [gaussianIntegralTerm, gaussianIntegralMagnitude, s, a] push_cast ring have hpartial_cast (m : ℕ) : ((gaussianIntegralPartial x m : ℚ) : ℝ) = ∑ k ∈ range (m + 1), s k := by simp only [gaussianIntegralPartial, Rat.cast_sum] apply Finset.sum_congr rfl intro k hk exact hterm_cast k have hnext_cast : ((gaussianIntegralPartial x (n + 1) : ℚ) : ℝ) = (∑ k ∈ range (n + 1), s k) + (-1 : ℝ) ^ (n + 1) * a (n + 1) := by rw [hpartial_cast] simpa only [Nat.add_assoc] using (Finset.sum_range_succ s (n + 1)) rw [gaussianIntegralInterval, RatInterval.Contains, Rat.cast_min, Rat.cast_max, hpartial_cast, hnext_cast] obtain heven | hodd := Nat.even_or_odd (n + 1) · have hsign : (-1 : ℝ) ^ (n + 1) = 1 := by simpa using heven.neg_one_pow rw [hsign, one_mul] at hrepresentation ⊢ constructor · apply min_le_iff.mpr left linarith · apply le_max_iff.mpr right linarith · have hsign : (-1 : ℝ) ^ (n + 1) = -1 := by simpa using hodd.neg_one_pow rw [hsign, neg_one_mul] at hrepresentation ⊢ constructor · apply min_le_iff.mpr right linarith · apply le_max_iff.mpr left linarith
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.gaussianIntegralInterval_sound · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/PowerSeries.lean:203 · uses Contains , gaussianIntegralInterval
9 supporting declarations (lemmas, instances)
Tail 6 core · 8 supporting For x > 8, the checker encloses the density using a finite rational exponential certificate and a rational normalization certificate, then applies the classical Mills bounds x φ(x)/(x²+1) ≤ 1-Φ(x) ≤ φ(x)/x. ★ tailCheck_sound

Mills-ratio standard-normal tail certificates

For x > 8, the checker encloses the density using a finite rational exponential certificate and a rational normalization certificate, then applies the classical Mills bounds x φ(x)/(x²+1) ≤ 1-Φ(x) ≤ φ(x)/x. These are the normal-tail counterpart of NIST DLMF §7.8 and avoid evaluating a nearly-one CDF by cancellation-prone central quadrature.

structure TailCertificate reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

A tail certificate combines rational normalization and exponential certificates for the density at the absolute endpoint.

Definition (Lean source)
q :
Certified normalization constant.
normalization :
Certified value of `exp (-|q|²/2)`.
exponential :
ExpCertificate (-|q| ^ 2 / 2)
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.TailCertificate · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Tail.lean:232
def tailDensityInterval reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

The certified rational interval for the density φ(|q|).

Definition (Lean source)
q :
tailDensityInterval q c :
c.normalization.enclosure.mul c.exponential.enclosure
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.tailDensityInterval · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Tail.lean:240 · uses RatInterval , TailCertificate
def millsTailInterval reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

A rational Mills tail enclosure is the hull of the lower-factor product and upper-factor product with the certified density interval, the factors being x/(x²+1) and 1/x. It encloses the upper tail only for positive x, as required by its soundness theorem; at x = 0 both factors are zero by the division convention.

Definition (Lean source)
x :
density :
millsTailInterval x density :
((RatInterval.point (x / (x ^ 2 + 1))).mul density).hull ((RatInterval.point (1 / x)).mul density)
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.millsTailInterval · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Tail.lean:257 · uses RatInterval
def tailInterval reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

The signed tail evaluator returns the upper-tail interval directly for a negative endpoint and reflects it for a nonnegative endpoint.

Definition (Lean source)
q :
tailInterval q c :
upperTail :
if 0 ≤ q then reflectInterval upperTail else upperTail
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.tailInterval · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Tail.lean:297 · uses RatInterval , TailCertificate
def tailCheck reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

The tail checker validates normalization and exponential subcertificates, the strict cutoff, and exact refinement into the caller-supplied interval.

Definition (Lean source)
q :
reported :
tailCheck q c reported :
normalizationCheck c.normalization && expCheck (-|q| ^ 2 / 2) c.exponential && decide (centralCutoff < |q| ∧ reported.lo ≤ (tailInterval q c).lo ∧ (tailInterval q c).hi ≤ reported.hi)
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.tailCheck · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Tail.lean:303 · uses RatInterval , TailCertificate
theorem tailCheck_sound reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure

When the Mills-tail checker accepts the supplied certificate and interval, that interval contains the standard-normal CDF at the rational endpoint.

Formal statement
q :
reported :
hcheck :
tailCheck q c reported = true
reported.Contains (stdNormalCDF (q : ℝ))
Proof (Lean source)
theorem tailCheck_sound {q : ℚ} {c : TailCertificate q} {reported : RatInterval} (hcheck : tailCheck q c reported = true) : reported.Contains (stdNormalCDF (q : ℝ)) := by -- Decode the normalization, exponential, strict-cutoff, and refinement -- checks. The strict cutoff makes `|q|` positive, so -- `tailDensityInterval_sound` and `millsTailInterval_sound` enclose the -- upper-tail probability at `|q|`. Split on the sign of `q`: for positive -- `q`, reflect `1 - Φ(q)` once; for negative `q`, use `q = -|q|` and -- `stdNormalCDF_neg`. First obtain containment in `tailInterval q c`, then -- finish by `RatInterval.Contains.mono` using the decoded refinement pair. unfold tailCheck at hcheck rw [Bool.and_eq_true] at hcheck rcases hcheck with ⟨hcertificates, hconditions⟩ rw [Bool.and_eq_true] at hcertificates rcases hcertificates with ⟨hnormalization, hexponential⟩ have hconditions' : centralCutoff < |q| ∧ reported.lo ≤ (tailInterval q c).lo ∧ (tailInterval q c).hi ≤ reported.hi := of_decide_eq_true hconditions rcases hconditions' with ⟨hcutoff, hlo, hhi⟩ have habspos : 0 < |q| := (by norm_num [centralCutoff] : (0 : ℚ) < centralCutoff).trans hcutoff have hdensity := tailDensityInterval_sound q c hnormalization hexponential have hupper := millsTailInterval_sound |q| habspos (tailDensityInterval q c) hdensity have htail : (tailInterval q c).Contains (stdNormalCDF (q : ℝ)) := by by_cases hq : 0 ≤ q · simpa [tailInterval, hq, abs_of_nonneg hq] using (reflectInterval_sound hupper) · have hqneg : q < 0 := lt_of_not_ge hq have hqabs : q = -|q| := by simp [abs_of_neg hqneg] rw [tailInterval, if_neg hq] rw [show (q : ℝ) = -(((|q| : ℚ) : ℝ)) by exact_mod_cast hqabs, stdNormalCDF_neg] exact hupper exact RatInterval.Contains.mono ⟨hlo, hhi⟩ htail
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedNormalCDFEnclosure.tailCheck_sound · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/CertifiedNormalCDFEnclosure/Tail.lean:312 · uses RatInterval , Contains , TailCertificate , tailCheck , stdNormalCDF
8 supporting declarations (lemmas, instances)