Mathlib.Probability.Certified­Finite­Markov­Expectation

Exact rational interval arithmetic for finite-state Markov kernels, certified normal-CDF transition probabilities, stationary-reward enclosures, and strict policy comparisons.

Certified­Normal­CDFEnclosure 41 core · 30 supporting · 7 submodules 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.
Interval 22 core · 18 supporting This module lifts Causalean's exact rational scalar intervals to finite sums, vectors, matrices, matrix products, and row-vector actions. ★ intervalMatrixMul_sound★ sound

Finite rational interval linear algebra

This module lifts Causalean's exact rational scalar intervals to finite sums, vectors, matrices, matrix products, and row-vector actions. All computations are performed on rational endpoints, while the soundness theorems relate the computed intervals to real linear algebra.

abbrev IntervalVector reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

An interval vector assigns one exact rational interval to each coordinate.

Definition (Lean source)
ι :
Type*
IntervalVector ι :
Type u_1
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.IntervalVector · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/Interval.lean:61
abbrev IntervalMatrix reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

An interval matrix assigns one exact rational interval to each row and column.

Definition (Lean source)
ι κ :
Type*
IntervalMatrix ι κ :
Type (max u_1 u_2)
ι → κ → RatInterval
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.IntervalMatrix · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/Interval.lean:64
def ContainsVector reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

An interval vector contains a real vector when it contains every coordinate.

Definition (Lean source)
ι :
Type*
x :
ι → ℝ
i :
ContainsVector I x :
Prop
(I i).Contains (x i)
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.ContainsVector · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/Interval.lean:67 · uses IntervalVector
def ContainsMatrix reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

An interval matrix contains a real matrix when it contains every entry.

Definition (Lean source)
ι κ :
Type*
I :
A :
Matrix ι κ ℝ
i j :
ContainsMatrix I A :
Prop
(I i j).Contains (A i j)
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.ContainsMatrix · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/Interval.lean:71 · uses IntervalMatrix
def VectorSubinterval reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

Coordinatewise rational interval refinement for vectors.

Definition (Lean source)
ι :
Type*
I J :
i :
VectorSubinterval I J :
Prop
(I i).Subinterval (J i)
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.VectorSubinterval · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/Interval.lean:75 · uses IntervalVector
def MatrixSubinterval reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

Coordinatewise rational interval refinement for matrices.

Definition (Lean source)
ι κ :
Type*
I J :
i j :
MatrixSubinterval I J :
Prop
(I i j).Subinterval (J i j)
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.MatrixSubinterval · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/Interval.lean:79 · uses IntervalMatrix
def intervalSum reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

The finite interval sum is the ordinary finite sum using outward interval addition.

Definition (Lean source)
ι :
Type*
I :
intervalSum I :
∑ i, I i
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.intervalSum · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/Interval.lean:83 · uses RatInterval
def intervalDot reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

The interval dot product sums outward products of corresponding coordinates.

Definition (Lean source)
ι :
Type*
I J :
intervalDot I J :
intervalSum fun i => (I i).mul (J i)
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.intervalDot · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/Interval.lean:87 · uses RatInterval , IntervalVector
def intervalMulVec reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

Applying an interval matrix to an interval column vector uses interval dot products rowwise.

Definition (Lean source)
ι κ :
Type*
A :
intervalMulVec A x :
fun i => intervalDot (A i) x
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.intervalMulVec · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/Interval.lean:92 · uses IntervalMatrix , IntervalVector
def intervalVecMul reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

Applying an interval row vector to an interval matrix uses interval dot products columnwise.

Definition (Lean source)
ι κ :
Type*
A :
intervalVecMul x A :
fun j => intervalDot x (fun i => A i j)
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.intervalVecMul · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/Interval.lean:97 · uses IntervalMatrix , IntervalVector
def intervalMatrixMul reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

Interval matrix multiplication computes every entry by an interval dot product.

Definition (Lean source)
ι κ υ :
Type*
A :
B :
intervalMatrixMul A B :
fun i j => intervalDot (A i) (fun k => B k j)
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.intervalMatrixMul · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/Interval.lean:102 · uses IntervalMatrix
def intervalExpectation reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

The interval reward expectation is the interval dot product of mass and reward vectors.

Definition (Lean source)
ι :
Type*
mass reward :
intervalExpectation mass reward :
intervalDot mass reward
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.intervalExpectation · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/Interval.lean:107 · uses RatInterval , IntervalVector
theorem intervalMatrixMul_sound reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

When the first rational interval matrix encloses a real matrix and the second rational interval matrix encloses a real matrix, their interval matrix product encloses the corresponding real matrix product.

Formal statement
ι κ υ :
Type*
Matrix ι κ ℝ
Matrix κ υ ℝ
hA :
hB :
Proof (Lean source)
theorem intervalMatrixMul_sound {ι κ υ : Type*} [Fintype κ] {A : IntervalMatrix ι κ} {B : IntervalMatrix κ υ} {M : Matrix ι κ ℝ} {N : Matrix κ υ ℝ} (hA : ContainsMatrix A M) (hB : ContainsMatrix B N) : ContainsMatrix (intervalMatrixMul A B) (M * N) := by intro i j exact intervalDot_sound (hA i) (fun k => hB k j)
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.intervalMatrixMul_sound · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/Interval.lean:153 · uses ContainsMatrix , IntervalMatrix , intervalMatrixMul
def scalarSubintervalCheck reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

Given an inner rational interval and an outer rational interval, the scalar subinterval check is the exact endpoint comparison that accepts exactly when the inner interval lies inside the outer interval.

Definition (Lean source)
inner outer :
scalarSubintervalCheck inner outer :
decide (outer.lo ≤ inner.lo ∧ inner.hi ≤ outer.hi)
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.scalarSubintervalCheck · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/Interval.lean:183 · uses RatInterval
structure ScalarIntervalCertificate reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

A scalar interval certificate records that an exact rational value lies in a reported rational interval, through a checked point-interval refinement.

Definition (Lean source)
q :
checked :
(RatInterval.point q).Subinterval I

The point interval at the exact value refines the reported interval.

Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.ScalarIntervalCertificate · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/Interval.lean:193 · uses RatInterval
structure FiniteVectorCertificate reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

A finite-vector certificate records independently checked scalar enclosures for each coordinate of an exact rational vector in a rational interval vector, through one certificate per coordinate.

Definition (Lean source)
ι :
Type*
q :
ι → ℚ
coordinate :
∀ i, ScalarIntervalCertificate (q i) (I i)

Independently checked certificate for each vector coordinate.

Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.FiniteVectorCertificate · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/Interval.lean:203 · uses IntervalVector
structure FiniteMatrixCertificate reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

A finite-matrix certificate records independently checked scalar enclosures for each entry of an exact rational matrix in a rational interval matrix, through one certificate per entry.

Definition (Lean source)
ι κ :
Type*
q :
Matrix ι κ ℚ
I :
entry :
∀ i j, ScalarIntervalCertificate (q i j) (I i j)

Independently checked certificate for each matrix entry.

Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.FiniteMatrixCertificate · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/Interval.lean:216 · uses IntervalMatrix
inductive IntervalFoldCertificate reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

An interval-fold certificate records a proof-producing binary assembly of a list of intervals into one output interval, with the empty-list case and the one-more-interval case checked separately.

Definition (Lean source)
IntervalFoldCertificate :
nil :
{output : RatInterval} (checked : (RatInterval.point 0).Subinterval output) : IntervalFoldCertificate [] output

The empty list is enclosed by any interval containing the point zero.

cons :
{head tailBound output : RatInterval} {tail : List RatInterval} (tailCertificate : IntervalFoldCertificate tail tailBound) (checked : (head.add tailBound).Subinterval output) : IntervalFoldCertificate (head :: tail) output

A certified tail and one checked addition certify the interval-list sum.

Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.IntervalFoldCertificate · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/Interval.lean:230 · uses RatInterval
structure CertifiedChunk reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

A certified chunk records a bounded partial interval sum of a finite interval family, with the selected maximum chunk size, its indices, its reported bound, a size proof, and a local exact-sum refinement proof.

Definition (Lean source)
ι :
Type*
terms :
chunkSize :
Indices assigned to this chunk.
indices :
Caller-supplied interval bound for this chunk.
bound :
The chunk contains no more than the selected number of terms.
size_le :
indices.card ≤ chunkSize
The exact interval sum for this chunk refines its reported bound.
checked :
(∑ i ∈ indices, terms i).Subinterval bound
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedChunk · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/Interval.lean:280 · uses RatInterval
structure ChunkedSumCertificate reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

A chunked-sum certificate assembles a finite interval family using a selected chunk-size bound into a reported output interval, through bounded chunk certificates, their pairwise disjointness, their exhaustive coverage, and a checked binary assembly.

Definition (Lean source)
ι :
terms :
chunkSize :
output :
Independently checked bounded chunks.
chunks :
List (CertifiedChunk terms chunkSize)
No index is counted by two different chunks.
pairwise_disjoint :
(chunks.map (fun c => c.indices)).Pairwise (fun s t => Disjoint s t)
Every index occurs in some chunk.
covers :
(chunks.map (fun c => c.indices)).foldr (fun s acc => s ∪ acc) ∅ = univ
Chunk bounds are combined only through checked binary additions.
assembly :
IntervalFoldCertificate (chunks.map (fun c => c.bound)) output
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.ChunkedSumCertificate · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/Interval.lean:292 · uses RatInterval
theorem sound reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.ChunkedSumCertificate

When a chunked-sum certificate is supplied, the complete interval sum refines its reported output interval.

Formal statement
ι :
chunkSize :
output :
c :
ChunkedSumCertificate terms chunkSize output
(intervalSum terms).Subinterval output
Proof (Lean source)
theorem ChunkedSumCertificate.sound {ι : Type*} [Fintype ι] [DecidableEq ι] {terms : ι → RatInterval} {chunkSize : ℕ} {output : RatInterval} (c : ChunkedSumCertificate terms chunkSize output) : (intervalSum terms).Subinterval output := by have chunk_refinements (cs : List (CertifiedChunk terms chunkSize)) : Forall₂ RatInterval.Subinterval (cs.map (fun d => ∑ i ∈ d.indices, terms i)) (cs.map (fun d => d.bound)) := by induction cs with | nil => exact .nil | cons d ds ih => exact .cons d.checked ih apply RatInterval.subinterval_trans ?_ c.assembly.refines_sum have hfull : intervalSum terms = (c.chunks.map (fun d => ∑ i ∈ d.indices, terms i)).sum := by simpa only [intervalSum, List.map_map, Function.comp_def] using sum_eq_sum_chunks terms (c.chunks.map (fun d => d.indices)) c.pairwise_disjoint c.covers rw [hfull] exact listSum_subinterval (chunk_refinements c.chunks)
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.ChunkedSumCertificate.sound · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/Interval.lean:335 · uses RatInterval , Subinterval , ChunkedSumCertificate , intervalSum
abbrev ChunkedDotCertificate reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

Given left interval-vector factors, right interval-vector factors, a chunk-size bound, and an output interval, a chunked dot-product certificate is the corresponding chunked certificate for outward interval products.

Definition (Lean source)
ι :
left right :
chunkSize :
output :
ChunkedDotCertificate left right chunkSize output :
Type u_1
ChunkedSumCertificate (fun i => (left i).mul (right i)) chunkSize output
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.ChunkedDotCertificate · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/Interval.lean:364 · uses RatInterval , IntervalVector
18 supporting declarations (lemmas, instances)
Finite­Kernel 16 core · 8 supporting This module defines row-stochastic finite kernels and their action on probability row vectors. ★ contractsL1_of_rationalMinorization

Finite stochastic kernels, contraction, and checked interval recurrences

This module defines row-stochastic finite kernels and their action on probability row vectors. It also provides exact-rational certificates for kernel minorization and for a finite interval recurrence enclosing successive iterates of a real Markov chain.

def IsProbabilityVector reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

A real vector is a probability vector when its entries are nonnegative and sum to one. This is definitionally membership in Mathlib's standard simplex (see isProbabilityVector_iff_mem_stdSimplex).

Definition (Lean source)
ι :
Type*
p :
ι → ℝ
IsProbabilityVector p :
Prop
clause 1
i :
0 ≤ p i
clause 2
∑ i, p i = 1
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.IsProbabilityVector · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/FiniteKernel.lean:18
def IsStochasticMatrix reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

A real square matrix is row-stochastic when every entry is nonnegative and every row sums to one. This is the same condition as membership in Mathlib's Matrix.rowStochastic (see isStochasticMatrix_iff_mem_rowStochastic), stated without its decidable-equality infrastructure.

Definition (Lean source)
ι :
Type*
P :
Matrix ι ι ℝ
IsStochasticMatrix P :
Prop
clause 1
i j :
0 ≤ P i j
clause 2
i :
∑ j, P i j = 1
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.IsStochasticMatrix · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/FiniteKernel.lean:24
def markovStep reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

One Markov step multiplies a row vector by a square matrix. No condition is imposed; it is a step of a Markov chain when the vector is a probability vector and the matrix is row-stochastic.

Definition (Lean source)
ι :
Type*
p :
ι → ℝ
P :
Matrix ι ι ℝ
markovStep p P :
ι → ℝ
vecMul p P
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.markovStep · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/FiniteKernel.lean:31
def markovIterate reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

The successive row vectors obtained from an initial row vector by repeated multiplication by a fixed square matrix. They are the successive distributions of a Markov chain when the start is a probability vector and the matrix is row-stochastic (see IsStochasticMatrix.iterate_probability).

Definition (Lean source)
ι :
Type*
P :
Matrix ι ι ℝ
p0 :
ι → ℝ
markovIterate P p0 :
ℕ → (ι → ℝ)
clause 1
| 0 => p0
clause 2
| n + 1 => markovStep (markovIterate P p0 n) P
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.markovIterate · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/FiniteKernel.lean:37
def IsStationary reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

A stationary distribution is a probability vector fixed by one Markov step.

Definition (Lean source)
ι :
Type*
P :
Matrix ι ι ℝ
π :
ι → ℝ
IsStationary P π :
Prop
clause 2
markovStep π P = π
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.IsStationary · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/FiniteKernel.lean:45
def l1Distance reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

The finite ℓ¹ distance is the sum of absolute coordinate differences.

Definition (Lean source)
ι :
Type*
p q :
ι → ℝ
l1Distance p q :
∑ i, |p i - q i|
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.l1Distance · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/FiniteKernel.lean:50
def ContractsL1 reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

A square matrix contracts probability vectors in ℓ¹ by a supplied coefficient: the one-step images of any two probability vectors are at most the coefficient times their ℓ¹ distance apart. Row-stochasticity of the matrix is not part of this predicate and is assumed separately.

Definition (Lean source)
ι :
Type*
P :
Matrix ι ι ℝ
ρ :
p q :
ContractsL1 P ρ :
Prop
l1Distance (markovStep p P) (markovStep q P) ≤ ρ * l1Distance p q
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.ContractsL1 · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/FiniteKernel.lean:54
def Minorizes reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

A Doeblin minorization says every row of a square matrix dominates the same probability vector scaled by a common mass ε between zero and one. Row-stochasticity of the matrix is not part of this predicate and is assumed separately.

Definition (Lean source)
ι :
Type*
P :
Matrix ι ι ℝ
ε :
ν :
ι → ℝ
Minorizes P ε ν :
Prop
clause 2
0 ≤ ε
clause 3
ε ≤ 1
clause 4
i j :
ε * ν j ≤ P i j
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.Minorizes · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/FiniteKernel.lean:62
structure CertifiedKernel reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

A certified real kernel packages a stochastic matrix together with an entrywise rational interval table that contains it.

Definition (Lean source)
ι :
Type*
P :
Matrix ι ι ℝ
Exact rational interval table for the transition entries.
intervals :
Every real transition entry lies in its reported rational interval.
contains :
ContainsMatrix intervals P
The underlying real transition matrix is row-stochastic.
stochastic :
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CertifiedKernel · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/FiniteKernel.lean:69
structure RationalProbabilityVector reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

A rational probability-vector certificate contains exact nonnegativity and sum checks.

Definition (Lean source)
ι :
Type*
Exact rational mass at each state.
value :
ι → ℚ
Every rational mass is nonnegative.
nonneg :
∀ i, 0 ≤ value i
The exact rational masses sum to one.
sum_eq_one :
∑ i, value i = 1
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.RationalProbabilityVector · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/FiniteKernel.lean:79
def toReal reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.RationalProbabilityVector

The real probability vector denoted by an exact rational certificate.

Definition (Lean source)
ι :
Type*
toReal p :
ι → ℝ
fun i => (p.value i : ℝ)
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.RationalProbabilityVector.toReal · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/FiniteKernel.lean:88 · uses RationalProbabilityVector
structure RationalMinorizationCertificate reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

A rational minorization certificate is checked solely by exact rational nonnegativity, normalization, and entrywise lower-endpoint comparisons.

Definition (Lean source)
ι :
Type*
K :
Common minorization mass.
epsilon :
Exact rational minorizing probability vector.
The common mass is nonnegative.
epsilon_nonneg :
0 ≤ epsilon
The common mass is at most one.
epsilon_le_one :
epsilon ≤ 1
Each interval lower endpoint dominates the minorizing mass at that column.
lower_checked :
∀ i j, epsilon * nu.value j ≤ (K i j).lo
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.RationalMinorizationCertificate · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/FiniteKernel.lean:93 · uses IntervalMatrix
structure FiniteIterateCertificate reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

A finite iterate certificate stores steps + 2 interval vectors and checks each recurrence inclusion using exact rational interval arithmetic.

Definition (Lean source)
ι :
Type*
K :
Number of the penultimate iterate used as the approximation.
steps :
Interval table for iterates zero through `steps + 1`.
table :
Fin (steps + 2) → IntervalVector ι
The first interval row contains the exact rational initial distribution.
initial_checked :
∀ i, (RatInterval.point (p0.value i)).Subinterval (table 0 i)
Every next row contains the interval row-vector recurrence from its predecessor.
recurrence_checked :
∀ k : Fin (steps + 1),
VectorSubinterval (intervalVecMul (table k.castSucc) K) (table k.succ)
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.FiniteIterateCertificate · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/FiniteKernel.lean:108 · uses IntervalMatrix , RationalProbabilityVector
def terminal reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.FiniteIterateCertificate

The penultimate stored interval vector is the finite-iterate approximation used for the stationary enclosure.

Definition (Lean source)
terminal c :
c.table (castSucc (last c.steps))
def next reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.FiniteIterateCertificate

The final stored interval vector encloses one further Markov step and is used to certify the finite-iterate residual.

Definition (Lean source)
next c :
c.table (last (c.steps + 1))
theorem contractsL1_of_rationalMinorization reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

Given a row-stochastic real transition matrix, its containment in an exact rational interval table, and a checked rational minorization certificate for that table, the kernel contracts finite probability vectors in total variation with coefficient one minus the certified minorization mass.

Formal statement
ContractsL1 P (1 - (c.epsilon : ℝ))
Proof (Lean source)
theorem contractsL1_of_rationalMinorization {ι : Type*} [Fintype ι] {P : Matrix ι ι ℝ} {K : IntervalMatrix ι ι} (hP : IsStochasticMatrix P) (hK : ContainsMatrix K P) (c : RationalMinorizationCertificate K) : ContractsL1 P (1 - (c.epsilon : ℝ)) := by exact contractsL1_of_minorization hP (c.sound hK)
8 supporting declarations (lemmas, instances)
Stationary 11 core · 13 supporting This module turns a checked interval recurrence into an a posteriori fixed-point certificate. ★ stationaryRewardInterval_sound★ stationaryRewardInterval_sound_of_chunked

Finite-iterate enclosures of stationary distributions and rewards

This module turns a checked interval recurrence into an a posteriori fixed-point certificate. An ℓ¹ contraction coefficient converts the last one-step residual into a stationary-distribution radius; a certified reward bound then converts that radius into a stationary-expectation interval.

def rewardExpectation reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

The expectation of a finite reward vector under a real mass vector.

Definition (Lean source)
ι :
Type*
p reward :
ι → ℝ
rewardExpectation p reward :
∑ i, p i * reward i
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.rewardExpectation · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/Stationary.lean:18
structure BoundedRewardCertificate reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

A bounded reward certificate gives entrywise rational enclosures and an exact rational uniform absolute bound on all their endpoints.

Definition (Lean source)
ι :
Type*
reward :
ι → ℝ
Rational interval enclosure for each reward coordinate.
intervals :
Each real reward is contained in its coordinate interval.
contains :
ContainsVector intervals reward
Exact rational uniform absolute reward bound.
bound :
The uniform bound is nonnegative.
bound_nonneg :
0 ≤ bound
Every interval endpoint has absolute value at most the uniform bound.
endpoints_bounded :
∀ i, (intervals i).maxAbs ≤ bound
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.BoundedRewardCertificate · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/Stationary.lean:23
def finiteIterateResidualBound reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

The rational residual bound sums the maximum absolute endpoint of the difference between the terminal interval row and its certified successor.

Definition (Lean source)
finiteIterateResidualBound c :
∑ i, ((c.terminal i).sub (c.next i)).maxAbs
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.finiteIterateResidualBound · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/Stationary.lean:37 · uses FiniteIterateCertificate , IntervalMatrix , RationalProbabilityVector
def stationaryErrorRadius reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

The a posteriori stationary radius is the residual bound divided by one minus the supplied exact rational contraction coefficient. It is a valid radius only for a coefficient strictly below one, as assumed by the enclosure results; at coefficient one the division by zero gives zero by convention.

Definition (Lean source)
stationaryErrorRadius c rho :
def stationaryDistributionInterval reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

The certified stationary-distribution enclosure expands each terminal coordinate interval by the common a posteriori ℓ¹ radius.

Definition (Lean source)
rho :
hrho0 :
0 ≤ rho
hrho1 :
rho < 1
stationaryDistributionInterval c rho hrho0 hrho1 :
fun i
=> (c.terminal i).expand (stationaryErrorRadius c rho) (stationaryErrorRadius_nonneg c rho hrho0 hrho1)
def stationaryRewardInterval reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

The stationary reward interval is the terminal interval expectation widened by the reward bound times the a posteriori stationary radius.

Definition (Lean source)
ι :
rho :
hrho0 :
0 ≤ rho
hrho1 :
rho < 1
stationaryRewardInterval c r rho hrho0 hrho1 :
(intervalExpectation c.terminal r.intervals).expand (r.bound * stationaryErrorRadius c rho) (mul_nonneg r.bound_nonneg (stationaryErrorRadius_nonneg c rho hrho0 hrho1))
theorem stationaryRewardInterval_sound reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

Given a certified finite transition kernel, a checked finite interval recurrence, a certified bounded reward vector, a rational contraction coefficient, its nonnegativity, its strict upper bound by one, the corresponding contraction guarantee, and a stationary distribution, the computed rational interval contains that distribution's stationary reward expectation.

Formal statement
ι :
Type*
Matrix ι ι ℝ
ι → ℝ
kernel :
c :
FiniteIterateCertificate kernel.intervals p0
rho :
hrho0 :
0 ≤ rho
hrho1 :
rho < 1
hcontract :
ContractsL1 P (rho : ℝ)
π :
ι → ℝ
:
(stationaryRewardInterval c r rho hrho0 hrho1).Contains (rewardExpectation π reward)
Proof (Lean source)
theorem stationaryRewardInterval_sound {ι : Type*} [Fintype ι] {P : Matrix ι ι ℝ} {p0 : RationalProbabilityVector ι} {reward : ι → ℝ} (kernel : CertifiedKernel P) (c : FiniteIterateCertificate kernel.intervals p0) (r : BoundedRewardCertificate reward) (rho : ℚ) (hrho0 : 0 ≤ rho) (hrho1 : rho < 1) (hcontract : ContractsL1 P (rho : ℝ)) {π : ι → ℝ} (hπ : IsStationary P π) : (stationaryRewardInterval c r rho hrho0 hrho1).Contains (rewardExpectation π reward) := by let p := markovIterate P p0.toReal c.steps have hterminal : ContainsVector c.terminal p := c.terminal_sound kernel.contains have hbase : (intervalExpectation c.terminal r.intervals).Contains (rewardExpectation p reward) := intervalDot_sound hterminal r.contains have hl1 : l1Distance p π ≤ (stationaryErrorRadius c rho : ℝ) := finiteIterate_stationary_l1_le kernel c rho hrho0 hrho1 hcontract hπ have hperturb : |rewardExpectation π reward - rewardExpectation p reward| ≤ (r.bound : ℝ) * (stationaryErrorRadius c rho : ℝ) := (by rw [abs_sub_comm] exact (abs_rewardExpectation_sub_le (by exact_mod_cast r.bound_nonneg) r.bound_sound).trans (mul_le_mul_of_nonneg_left hl1 (by exact_mod_cast r.bound_nonneg))) change ((((intervalExpectation c.terminal r.intervals).lo - r.bound * stationaryErrorRadius c rho : ℚ) : ℝ) ≤ rewardExpectation π reward ∧ rewardExpectation π reward ≤ (((intervalExpectation c.terminal r.intervals).hi + r.bound * stationaryErrorRadius c rho : ℚ) : ℝ)) norm_num only [Rat.cast_sub, Rat.cast_add, Rat.cast_mul] rcases hbase with ⟨hbase_lo, hbase_hi⟩ rcases abs_le.mp hperturb with ⟨hperturb_lo, hperturb_hi⟩ constructor <;> linarith
structure CoordinateRecurrenceCertificate reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

A coordinate recurrence certificate records, for an interval transition matrix, a current interval vector, a next interval vector, and a chunk-size bound, one chunked dot-product certificate for each output coordinate.

Definition (Lean source)
ι :
K :
current next :
chunkSize :
Chunked certificate for the dot product producing each next coordinate.
coordinate :
∀ j, ChunkedDotCertificate current (fun i => K i j) chunkSize (next j)
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.CoordinateRecurrenceCertificate · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/Stationary.lean:307 · uses IntervalMatrix , IntervalVector
structure ChunkedFiniteIterateCertificate reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

A chunked finite-iterate certificate stores a recurrence trace for an interval transition matrix from an exact rational initial distribution, using a number of approximation steps, a positive chunk-size bound and its positivity proof, the interval rows, initial coordinate checks, and bounded coordinate recurrence checks.

Definition (Lean source)
ι :
K :
Number of the penultimate iterate used by stationary enclosures.
steps :
Maximum number of scalar products checked by any chunk leaf.
chunkSize :
A chunk must contain at least one permitted slot.
chunkSize_pos :
0 < chunkSize
Interval vectors for iterates zero through `steps + 1`.
table :
Fin (steps + 2) → IntervalVector ι
Independently checked initial coordinate inclusions.
initial_checked :
∀ i, (RatInterval.point (p0.value i)).Subinterval (table 0 i)
Every recurrence step is certified coordinatewise with bounded chunks.
recurrence :
∀ k : Fin (steps + 1),
CoordinateRecurrenceCertificate K (table k.castSucc) (table k.succ) chunkSize
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.ChunkedFiniteIterateCertificate · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/Stationary.lean:324 · uses IntervalMatrix , RationalProbabilityVector
def toFiniteIterateCertificate reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.ChunkedFiniteIterateCertificate

Given a chunked finite-iterate certificate, the corresponding established finite-iterate certificate is the same trace with each opaque coordinate proof composed into its recurrence field.

Definition (Lean source)
toFiniteIterateCertificate c :
clause 1
steps := c.steps
clause 2
table := c.table
clause 3
initial_checked := c.initial_checked
clause 4
recurrence_checked := by intro k exact (c.recurrence k).sound
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.ChunkedFiniteIterateCertificate.toFiniteIterateCertificate · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/Stationary.lean:341 · uses ChunkedFiniteIterateCertificate , FiniteIterateCertificate , IntervalMatrix , RationalProbabilityVector
theorem stationaryRewardInterval_sound_of_chunked reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

Given a certified real kernel, a chunked finite-iterate certificate, a bounded reward certificate, a rational contraction coefficient that is nonnegative and strictly below one, the contraction property, and a stationary distribution, the stationary-reward interval obtained through the adapter contains the stationary reward expectation.

Formal statement
ι :
Type*
Matrix ι ι ℝ
ι → ℝ
kernel :
c :
rho :
hrho0 :
0 ≤ rho
hrho1 :
rho < 1
hcontract :
ContractsL1 P (rho : ℝ)
π :
ι → ℝ
:
(stationaryRewardInterval c.toFiniteIterateCertificate r rho hrho0 hrho1).Contains (rewardExpectation π reward)
Proof (Lean source)
theorem stationaryRewardInterval_sound_of_chunked {ι : Type*} [Fintype ι] [DecidableEq ι] {P : Matrix ι ι ℝ} {p0 : RationalProbabilityVector ι} {reward : ι → ℝ} (kernel : CertifiedKernel P) (c : ChunkedFiniteIterateCertificate kernel.intervals p0) (r : BoundedRewardCertificate reward) (rho : ℚ) (hrho0 : 0 ≤ rho) (hrho1 : rho < 1) (hcontract : ContractsL1 P (rho : ℝ)) {π : ι → ℝ} (hπ : IsStationary P π) : (stationaryRewardInterval c.toFiniteIterateCertificate r rho hrho0 hrho1).Contains (rewardExpectation π reward) := by exact stationaryRewardInterval_sound kernel c.toFiniteIterateCertificate r rho hrho0 hrho1 hcontract hπ
13 supporting declarations (lemmas, instances)
Comparison 2 core · 3 supporting This module provides the final order-theoretic comparison step. ★ stationaryExpectation_lt_of_certified_intervals

Strict comparison of certified stationary expectations

This module provides the final order-theoretic comparison step. Disjoint rational enclosures for two stationary expectations certify a strict ordering, and subtracting a common benchmark turns the same ordering into a strict bias comparison between two policies.

def stationaryBias reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

The stationary bias of a reward process relative to a benchmark is the reward expectation under a supplied weight vector minus that benchmark. No condition is imposed on the vector; it is the bias of the stationary reward when the vector is the stationary distribution.

Definition (Lean source)
ι :
Type*
π reward :
ι → ℝ
benchmark :
stationaryBias π reward benchmark :
rewardExpectation π reward - benchmark
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.stationaryBias · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/Comparison.lean:16
theorem stationaryExpectation_lt_of_certified_intervals reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

Given the first certified policy kernel, the second certified policy kernel, their checked finite interval recurrences, a certified bounded reward vector, their rational contraction coefficients, the first coefficient's nonnegativity and strict upper bound, the second coefficient's nonnegativity and strict upper bound, the two contraction guarantees, their stationary distributions, and strictly separated computed reward intervals, the first stationary reward expectation is strictly smaller than the second.

Formal statement
ι :
Type*
Matrix ι ι ℝ
ι → ℝ
kernelP :
kernelQ :
iterateP :
FiniteIterateCertificate kernelP.intervals p0P
iterateQ :
FiniteIterateCertificate kernelQ.intervals p0Q
rewardCert :
rhoP rhoQ :
hrhoP0 :
0 ≤ rhoP
hrhoP1 :
rhoP < 1
hrhoQ0 :
0 ≤ rhoQ
hrhoQ1 :
rhoQ < 1
hcontractP :
ContractsL1 P (rhoP : ℝ)
hcontractQ :
ContractsL1 Q (rhoQ : ℝ)
πP πQ :
ι → ℝ
hπP :
hπQ :
hsep :
(stationaryRewardInterval iterateP rewardCert rhoP hrhoP0 hrhoP1).hi < (stationaryRewardInterval iterateQ rewardCert rhoQ hrhoQ0 hrhoQ1).lo
rewardExpectation πP reward < rewardExpectation πQ reward
Proof (Lean source)
theorem stationaryExpectation_lt_of_certified_intervals {ι : Type*} [Fintype ι] {P Q : Matrix ι ι ℝ} {p0P p0Q : RationalProbabilityVector ι} {reward : ι → ℝ} (kernelP : CertifiedKernel P) (kernelQ : CertifiedKernel Q) (iterateP : FiniteIterateCertificate kernelP.intervals p0P) (iterateQ : FiniteIterateCertificate kernelQ.intervals p0Q) (rewardCert : BoundedRewardCertificate reward) (rhoP rhoQ : ℚ) (hrhoP0 : 0 ≤ rhoP) (hrhoP1 : rhoP < 1) (hrhoQ0 : 0 ≤ rhoQ) (hrhoQ1 : rhoQ < 1) (hcontractP : ContractsL1 P (rhoP : ℝ)) (hcontractQ : ContractsL1 Q (rhoQ : ℝ)) {πP πQ : ι → ℝ} (hπP : IsStationary P πP) (hπQ : IsStationary Q πQ) (hsep : (stationaryRewardInterval iterateP rewardCert rhoP hrhoP0 hrhoP1).hi < (stationaryRewardInterval iterateQ rewardCert rhoQ hrhoQ0 hrhoQ1).lo) : rewardExpectation πP reward < rewardExpectation πQ reward := by -- Obtain both semantic containment facts from `stationaryRewardInterval_sound`, -- then apply `lt_of_disjoint_enclosures` to the checked endpoint separation. apply lt_of_disjoint_enclosures · exact stationaryRewardInterval_sound kernelP iterateP rewardCert rhoP hrhoP0 hrhoP1 hcontractP hπP · exact stationaryRewardInterval_sound kernelQ iterateQ rewardCert rhoQ hrhoQ0 hrhoQ1 hcontractQ hπQ · exact hsep
3 supporting declarations (lemmas, instances)
Existence 1 core · 2 supporting This module isolates the topological fixed-point argument for finite stochastic kernels. ★ existsUnique_stationary_of_contractsL1

Existence and uniqueness of finite stationary distributions

This module isolates the topological fixed-point argument for finite stochastic kernels. Existence uses compactness of the finite probability simplex, while strict ℓ¹ contraction supplies uniqueness. It also records the bridges from this library's probability-vector and row-stochastic predicates to Mathlib's standard simplex and Matrix.rowStochastic.

theorem existsUnique_stationary_of_contractsL1 reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

On a nonempty finite state space, given a row-stochastic transition matrix, a nonnegative contraction coefficient, the fact that the coefficient is strictly below one, and a total-variation contraction bound, there is exactly one stationary probability distribution.

Formal statement
ι :
Type*
Nonempty ι
Matrix ι ι ℝ
rho :
hrho0 :
0 ≤ rho
hrho1 :
rho < 1
hcontract :
∃! π : ι → ℝ, IsStationary P π
Proof (Lean source)
theorem existsUnique_stationary_of_contractsL1 {ι : Type*} [Fintype ι] [Nonempty ι] {P : Matrix ι ι ℝ} {rho : ℝ} (hP : IsStochasticMatrix P) (hrho0 : 0 ≤ rho) (hrho1 : rho < 1) (hcontract : ContractsL1 P rho) : ∃! π : ι → ℝ, IsStationary P π := by classical let i₀ : ι := Classical.choice inferInstance let p₀ : ι → ℝ := single i₀ 1 have hp₀ : IsProbabilityVector p₀ := by change p₀ ∈ stdSimplex ℝ ι simpa only [p₀] using single_mem_stdSimplex ℝ i₀ let p : ℕ → (ι → ℝ) := markovIterate P p₀ have hp (n : ℕ) : IsProbabilityVector (p n) := hP.iterate_probability hp₀ n have hl1_nonneg (q r : ι → ℝ) : 0 ≤ l1Distance q r := by exact sum_nonneg fun _ _ => abs_nonneg _ let d : ℕ → ℝ := fun n => l1Distance (p (n + 1)) (p n) have hd_le (n : ℕ) : d n ≤ rho ^ n * d 0 := by induction n with | zero => simp | succ n ih => calc d (n + 1) = l1Distance (markovStep (p (n + 1)) P) (markovStep (p n) P) := by simp only [d, p, markovIterate] _ ≤ rho * l1Distance (p (n + 1)) (p n) := hcontract _ _ (hp (n + 1)) (hp n) _ = rho * d n := rfl _ ≤ rho * (rho ^ n * d 0) := mul_le_mul_of_nonneg_left ih hrho0 _ = rho ^ (n + 1) * d 0 := by rw [pow_succ]; ring have hd_tendsto : Tendsto d atTop (nhds 0) := by have hu : Tendsto (fun n => rho ^ n * d 0) atTop (nhds 0) := by simpa using (tendsto_pow_atTop_nhds_zero_of_lt_one hrho0 hrho1).mul_const (d 0) apply tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds hu · exact Filter.Eventually.of_forall fun n => hl1_nonneg _ _ · exact Filter.Eventually.of_forall hd_le have hp_simplex (n : ℕ) : p n ∈ stdSimplex ℝ ι := hp n obtain ⟨π, hπ_prob, φ, hφ, hφ_tendsto⟩ := (isCompact_stdSimplex ℝ ι).tendsto_subseq hp_simplex have hd_subseq : Tendsto (fun n => d (φ n)) atTop (nhds 0) := hd_tendsto.comp hφ.tendsto_atTop have hshift : Tendsto (fun n => p (φ n + 1)) atTop (nhds π) := by rw [tendsto_pi_nhds] intro i have habs (n : ℕ) : |p (φ n + 1) i - p (φ n) i| ≤ d (φ n) := by apply Finset.single_le_sum (fun j _ => abs_nonneg (p (φ n + 1) j - p (φ n) j)) exact Finset.mem_univ i have hdiff : Tendsto (fun n => p (φ n + 1) i - p (φ n) i) atTop (nhds 0) := by have hneg : Tendsto (fun n => -d (φ n)) atTop (nhds 0) := by simpa using hd_subseq.neg apply tendsto_of_tendsto_of_tendsto_of_le_of_le' hneg hd_subseq · exact Filter.Eventually.of_forall fun n => (neg_le_of_abs_le (habs n)) · exact Filter.Eventually.of_forall fun n => (le_of_abs_le (habs n)) convert (hφ_tendsto.apply_nhds i).add hdiff using 1 <;> simp have hstep : Tendsto (fun n => markovStep (p (φ n)) P) atTop (nhds (markovStep π P)) := by rw [tendsto_pi_nhds] intro j unfold markovStep vecMul dotProduct apply tendsto_finsetSum intro i hi exact (hφ_tendsto.apply_nhds i).mul tendsto_const_nhds have hshift_step : Tendsto (fun n => p (φ n + 1)) atTop (nhds (markovStep π P)) := by convert hstep using 1 funext n simp only [p, markovIterate] have hfixed : markovStep π P = π := tendsto_nhds_unique hshift_step hshift refine ⟨π, ⟨hπ_prob, hfixed⟩, ?_⟩ intro π' hπ' have hdist_le : l1Distance π' π ≤ rho * l1Distance π' π := by calc l1Distance π' π = l1Distance (markovStep π' P) (markovStep π P) := by rw [hπ'.2, hfixed] _ ≤ rho * l1Distance π' π := hcontract _ _ hπ'.1 hπ_prob have hdist_zero : l1Distance π' π = 0 := by nlinarith [hl1_nonneg π' π] funext i have hi : |π' i - π i| ≤ l1Distance π' π := by apply Finset.single_le_sum (fun j _ => abs_nonneg (π' j - π j)) exact Finset.mem_univ i rw [hdist_zero] at hi exact sub_eq_zero.mp (abs_eq_zero.mp (le_antisymm hi (abs_nonneg _)))
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.existsUnique_stationary_of_contractsL1 · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/Existence.lean:32 · uses ContractsL1 , IsStationary , IsStochasticMatrix
2 supporting declarations (lemmas, instances)
Normal­CDF 9 core · 7 supporting This module gives an executable, exact-rational checker for standard-normal CDF values at rational endpoints. ★ sound

Certified rational enclosures for the standard normal CDF

This module gives an executable, exact-rational checker for standard-normal CDF values at rational endpoints. It combines Causalean's certified Machin enclosure for π, Newton square-root enclosure, exponential enclosure, and a rigorously widened trapezoidal rule. A caller may enlarge the computed result, but cannot introduce a decimal endpoint without proving an exact rational subinterval check.

Scaling limitation — read before instantiating

The trapezoidal rule here uses a UNIFORM mesh, so the node count is set by the worst-behaved part of the interval rather than by local curvature. Away from the origin this is severe: at endpoint 193/5 with target width 1e-12 the mesh floor forces more than 5.7e16 exact-rational nodes, which is sound but not computable in practice. The checker is therefore usable for narrow targets near the origin and unusable for tight enclosures at large endpoints.

A caller needing the latter wants a symmetry + central-series + Mills-tail construction instead, which spends nodes only where the integrand is hard. Nothing here is wrong; it is a question of which regime applies.

def twoPiInterval reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

The interval enclosing at a chosen exact arithmetic fuel level.

Definition (Lean source)
fuel :
twoPiInterval fuel :
(RatInterval.point 2).mul (Complex.Transcendental.piInterval fuel)
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.twoPiInterval · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/NormalCDF.lean:37 · uses RatInterval
structure NormalCDFSchedule reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

A normal-CDF schedule records a positive mesh and the exact rational side conditions needed to invert the computed enclosure of sqrt (2π).

Definition (Lean source)
Precision used by the π, square-root, and exponential interval evaluators.
fuel :
Number of cells in the certified trapezoidal quadrature.
mesh :
The quadrature mesh is nonempty.
mesh_pos :
0 < mesh
The computed lower endpoint for `2π` is nonnegative.
twoPi_nonneg :
0 ≤ (twoPiInterval fuel).lo
The computed square-root interval excludes zero, so its reciprocal is sound.
sqrt_away :
(RatInterval.sqrtInterval (twoPiInterval fuel) twoPi_nonneg fuel).AwayFromZero
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.NormalCDFSchedule · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/NormalCDF.lean:42
def normalDensityScaleInterval reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

The certified rational enclosure of the standard-normal density's scale factor 1 / sqrt (2π) for a schedule.

Definition (Lean source)
normalDensityScaleInterval s :
root :
RatInterval.sqrtInterval (twoPiInterval s.fuel) s.twoPi_nonneg s.fuel
root.inv s.sqrt_away
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.normalDensityScaleInterval · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/NormalCDF.lean:57 · uses RatInterval , NormalCDFSchedule
def normalDensityNode reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

For a rational endpoint q, a schedule, and a natural node index k, this interval encloses the rescaled Gaussian integrand at the point q k / mesh used for CDF quadrature. The quadrature applies it to nonnegative endpoints and node indices up to the mesh size; no such restriction is imposed here.

Definition (Lean source)
q :
k :
normalDensityNode q s k :
x :
q * k / s.mesh (: ℚ)
exponent :
-(x ^ 2) / 2 (: ℚ)
((RatInterval.point q).mul (normalDensityScaleInterval s)).mul (Transcendental.expInterval (RatInterval.point exponent) s.fuel)
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.normalDensityNode · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/NormalCDF.lean:63 · uses RatInterval , NormalCDFSchedule
def normalDensityComplexNode reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

The complex rectangle obtained from a real Gaussian quadrature node by adjoining the point interval at zero as imaginary coordinate.

Definition (Lean source)
q :
k :
normalDensityComplexNode q s k :
⟨normalDensityNode q s k, RatInterval.point 0⟩
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.normalDensityComplexNode · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/NormalCDF.lean:73 · uses ComplexRatInterval , NormalCDFSchedule
def nonnegativeNormalIntegralInterval reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

For a nonnegative rational endpoint, the computed interval encloses the integral of the standard-normal density from zero to that endpoint.

Definition (Lean source)
q :
hq :
0 ≤ q
nonnegativeNormalIntegralInterval q hq s :
(CircleMesh.integralEnclosure (normalDensityComplexNode q s) (q ^ 3) (pow_nonneg hq 3) s.mesh s.mesh_pos).re
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.nonnegativeNormalIntegralInterval · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/NormalCDF.lean:79 · uses RatInterval , NormalCDFSchedule
def normalCDFInterval reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

The internally computed rational enclosure of the standard-normal CDF at any rational endpoint, using symmetry for negative endpoints.

Definition (Lean source)
q :
normalCDFInterval q s :
positive :
(RatInterval.point (1 / 2)).add (nonnegativeNormalIntegralInterval |q| (abs_nonneg q) s)
if 0 ≤ q then positive else (RatInterval.point 1).sub positive
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.normalCDFInterval · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/NormalCDF.lean:87 · uses RatInterval , NormalCDFSchedule
structure NormalCDFCertificate reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation

A standard-normal CDF certificate consists of a checked internal schedule, a caller-facing rational interval, and an exact proof that the internally computed interval refines the caller-facing one.

Definition (Lean source)
q :
Internal exact-arithmetic evaluation schedule.
schedule :
Rational interval reported in the caller's endpoint table.
enclosure :
Exact rational refinement check connecting the reported interval to the evaluator.
checked :
(normalCDFInterval q schedule).Subinterval enclosure
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.NormalCDFCertificate · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/NormalCDF.lean:94
theorem sound reviewed
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.NormalCDFCertificate

Given a checked rational certificate at a rational endpoint, the certificate's reported interval contains the true standard-normal cumulative probability at that endpoint.

Formal statement
q :
c :
NormalCDFCertificate q
c.enclosure.Contains (stdNormalCDF (q : ℝ))
Proof (Lean source)
theorem NormalCDFCertificate.sound {q : ℚ} (c : NormalCDFCertificate q) : c.enclosure.Contains (stdNormalCDF (q : ℝ)) := by exact (normalCDFInterval_sound q c.schedule).mono c.checked
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.NormalCDFCertificate.sound · Causalean/Mathlib/Probability/CertifiedFiniteMarkovExpectation/NormalCDF.lean:295 · uses Contains , NormalCDFCertificate , stdNormalCDF
7 supporting declarations (lemmas, instances)