Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

§6 — summands BtB_tBt​, Newey–West HAC estimator, Assumptions 2–3, modes of convergence, mixing σ\sigmaσ-algebras

Definition
TPG_Inference

by Wenqian Xing · Oct 12, 2026 · Mathlib 0df444a (Lean v4.33.1)

causal-inferencemarkov-chainnonstationaritypolicy-gradienttreatment-effect

Objects of §6 (central limit theorem and variance estimation) and of Appendix A.4 of the source. Time is t=0,…,T−1t=0,\dots,T-1t=0,…,T−1 (the source's t+1t+1t+1); the data are generated under the experimental policy π1/2\pi_{1/2}π1/2​ unless stated otherwise.

  1. Reward-time summands (ipw, Bt, Bbar): with wtIPW=2(2Zt−1)w_t^{\mathrm{IPW}}=2(2Z_t-1)wtIPW​=2(2Zt​−1),
Bt=∑i=max⁡(0,t−k)twiIPW Yt,Bˉ=1T∑t<TBt,B_t=\sum_{i=\max(0,t-k)}^{t}w_i^{\mathrm{IPW}}\,Y_t,\qquad \bar B=\frac1T\sum_{t<T}B_t ,Bt​=i=max(0,t−k)∑t​wiIPW​Yt​,Bˉ=T1​t<T∑​Bt​,

so that Bˉ=τ^k\bar B=\widehat\tau_kBˉ=τk​.

  1. HAC estimator (GammaHat, nwWeight, hacEst): for a bandwidth LLL,
Γ^ℓ=1T∑t+ℓ<T(Bt−Bˉ)(Bt+ℓ−Bˉ),wℓNW=1−ℓL+1,Ω^T=Γ^0+2∑ℓ=1LwℓNW Γ^ℓ.\widehat\Gamma_\ell=\frac1T\sum_{t+\ell<T}(B_t-\bar B)(B_{t+\ell}-\bar B),\qquad w_\ell^{\mathrm{NW}}=1-\frac{\ell}{L+1},\qquad \widehat\Omega_T=\widehat\Gamma_0+2\sum_{\ell=1}^{L}w_\ell^{\mathrm{NW}}\,\widehat\Gamma_\ell .Γℓ​=T1​t+ℓ<T∑​(Bt​−Bˉ)(Bt+ℓ​−Bˉ),wℓNW​=1−L+1ℓ​,ΩT​=Γ0​+2ℓ=1∑L​wℓNW​Γℓ​.
  1. Ideal HAC estimator (Env.meanB, Env.GammaIdeal, Env.hacIdeal): the same construction with Bt−BˉB_t-\bar BBt​−Bˉ replaced by Vt=Bt−μtV_t=B_t-\mu_tVt​=Bt​−μt​, μt=E[Bt]\mu_t=\mathbb E[B_t]μt​=E[Bt​], giving Γ~ℓ\widetilde\Gamma_\ellΓℓ​ and Ω~T\widetilde\Omega_TΩT​.

  2. Assumption 2, asymptotic variance (Env.normVar, Env.AsymptoticVariance k v): 1TVar⁡(∑t<TBt)→v\frac1T\operatorname{Var}\bigl(\sum_{t<T}B_t\bigr)\to vT1​Var(∑t<T​Bt​)→v as T→∞T\to\inftyT→∞, and v>0v>0v>0. The number vvv is the source's σk2\sigma_k^2σk2​.

  3. Assumption 3, Cesàro-L2L^2L2 mean stability (Env.cesaroDevSq, Env.MeanStability k): with μˉT=1T∑t<Tμt\bar\mu_T=\frac1T\sum_{t<T}\mu_tμˉ​T​=T1​∑t<T​μt​,

ΔT2=1T∑t<T(μt−μˉT)2=o(T−2/3)as T→∞.\Delta_T^2=\frac1T\sum_{t<T}(\mu_t-\bar\mu_T)^2=o\bigl(T^{-2/3}\bigr)\quad\text{as }T\to\infty .ΔT2​=T1​t<T∑​(μt​−μˉ​T​)2=o(T−2/3)as T→∞.
  1. Bandwidth conditions (IsBandwidth L): LT<TL_T<TLT​<T for all T≥1T\ge1T≥1, LT→∞L_T\to\inftyLT​→∞, and LT=O(T1/3)L_T=O(T^{1/3})LT​=O(T1/3).

  2. Modes of convergence as T→∞T\to\inftyT→∞ for statistics WTW_TWT​ of the horizon-TTT trajectory. Convergence in distribution to N(0,v)\mathcal N(0,v)N(0,v) (Env.TendstoNormal): E[f(WT)]→∫f dN(0,v)\mathbb E[f(W_T)]\to\int f\,d\mathcal N(0,v)E[f(WT​)]→∫fdN(0,v) for every bounded continuous f:R→Rf:\mathbb R\to\mathbb Rf:R→R. Convergence in probability to a constant ccc (Env.TendstoInProb): P(∣WT−c∣≥ε)→0\mathbb P(|W_T-c|\ge\varepsilon)\to0P(∣WT​−c∣≥ε)→0 for every ε>0\varepsilon>0ε>0.

  3. σ\sigmaσ-algebras for strong mixing (sigmaWindow, GammaTerm, sigmaGamma): Fab=σ((Xt,Zt,Yt):a≤t≤b)\mathcal F_a^b=\sigma\bigl((X_t,Z_t,Y_t):a\le t\le b\bigr)Fab​=σ((Xt​,Zt​,Yt​):a≤t≤b), the local summand Γt=2(2Zt−1)∑u=tmin⁡(t+k, T−1)Yu\Gamma_t=2(2Z_t-1)\sum_{u=t}^{\min(t+k,\,T-1)}Y_uΓt​=2(2Zt​−1)∑u=tmin(t+k,T−1)​Yu​, and σ(Γt:a≤t≤b)\sigma(\Gamma_t:a\le t\le b)σ(Γt​:a≤t≤b).

These objects are used in Theorem 2, Lemmas 2–5 and Corollary 1.

Formalization Note For each TTT the statistics are random variables on the horizon-TTT trajectory space with its own law; the laws for different TTT are consistent with one another, and both modes of convergence in item 7 involve only the law of WTW_TWT​ for each TTT. In Assumption 2 the limit is a parameter vvv of the predicate. The normal law is taken with variance max⁡(v,0)\max(v,0)max(v,0).

Definition code
import Mathlib
import Definitions.Def_TPG_Model
import Definitions.Def_TPG_Estimators

open MeasureTheory ProbabilityTheory
open scoped BigOperators ENNReal

namespace TPG

variable {S : Type} [Fintype S]

/-- Inverse-propensity weight `w^IPW = 2 (2 Z - 1)` under balanced randomization. -/
noncomputable def ipw (z : Bool) : ℝ :=
  2 * (2 * (if z then (1 : ℝ) else 0) - 1)

/-- Reward-time summand `B_t = ∑_{max(0, t - k) ≤ i ≤ t} w_i^IPW Y_t`. -/
noncomputable def Bt {T : ℕ} (k : ℕ) (t : Fin T) (ω : Traj S T) : ℝ :=
  ∑ i : Fin T, if (i : ℕ) ≤ (t : ℕ) ∧ (t : ℕ) ≤ (i : ℕ) + k then ipw (Z i ω) * Y t ω else 0

/-- Sample mean `B̄ = (1/T) ∑_{t < T} B_t`. -/
noncomputable def Bbar (T k : ℕ) (ω : Traj S T) : ℝ :=
  (1 / (T : ℝ)) * ∑ t : Fin T, Bt k t ω

/-- Lag-`ℓ` sample autocovariance centered at the sample mean,
`Γ̂_ℓ = (1/T) ∑_{t + ℓ < T} (B_t - B̄)(B_{t+ℓ} - B̄)`. -/
noncomputable def GammaHat (T k ℓ : ℕ) (ω : Traj S T) : ℝ :=
  (1 / (T : ℝ)) * ∑ t : Fin T, ∑ t' : Fin T,
    if (t : ℕ) + ℓ = (t' : ℕ) then (Bt k t ω - Bbar T k ω) * (Bt k t' ω - Bbar T k ω) else 0

/-- Newey–West (Bartlett) weight `w_ℓ^NW = 1 - ℓ / (L + 1)`. -/
noncomputable def nwWeight (L ℓ : ℕ) : ℝ :=
  1 - (ℓ : ℝ) / ((L : ℝ) + 1)

/-- Nonstationary HAC variance estimator with bandwidth `L`,
`Ω̂_T = Γ̂_0 + 2 ∑_{ℓ=1}^{L} w_ℓ^NW Γ̂_ℓ`. -/
noncomputable def hacEst (T k L : ℕ) (ω : Traj S T) : ℝ :=
  GammaHat T k 0 ω + 2 * ∑ ℓ ∈ Finset.Icc 1 L, nwWeight L ℓ * GammaHat T k ℓ ω

/-- Time-specific mean `μ_t = E[B_t]` under the experimental policy `π_{1/2}`. -/
noncomputable def Env.meanB [MeasurableSpace S] (E : Env S) (T k : ℕ) (t : Fin T) : ℝ :=
  ∫ ω, Bt k t ω ∂(E.expLaw T (1 / 2))

/-- Lag-`ℓ` sample autocovariance centered at the time-specific means,
`Γ̃_ℓ = (1/T) ∑_{t + ℓ < T} (B_t - μ_t)(B_{t+ℓ} - μ_{t+ℓ})`. -/
noncomputable def Env.GammaIdeal [MeasurableSpace S] (E : Env S) (T k ℓ : ℕ)
    (ω : Traj S T) : ℝ :=
  (1 / (T : ℝ)) * ∑ t : Fin T, ∑ t' : Fin T,
    if (t : ℕ) + ℓ = (t' : ℕ) then
      (Bt k t ω - E.meanB T k t) * (Bt k t' ω - E.meanB T k t') else 0

/-- Ideal HAC estimator `Ω̃_T = Γ̃_0 + 2 ∑_{ℓ=1}^{L} w_ℓ^NW Γ̃_ℓ`. -/
noncomputable def Env.hacIdeal [MeasurableSpace S] (E : Env S) (T k L : ℕ)
    (ω : Traj S T) : ℝ :=
  E.GammaIdeal T k 0 ω + 2 * ∑ ℓ ∈ Finset.Icc 1 L, nwWeight L ℓ * E.GammaIdeal T k ℓ ω

/-- Normalized variance `(1/T) Var(∑_{t < T} B_t)` under `π_{1/2}`. -/
noncomputable def Env.normVar [MeasurableSpace S] (E : Env S) (T k : ℕ) : ℝ :=
  (1 / (T : ℝ)) * variance (fun ω : Traj S T => ∑ t : Fin T, Bt k t ω) (E.expLaw T (1 / 2))

/-- Cesàro-`L²` deviation of the means,
`Δ_T² = (1/T) ∑_{t < T} (μ_t - μ̄_T)²` with `μ̄_T = (1/T) ∑_{t < T} μ_t`. -/
noncomputable def Env.cesaroDevSq [MeasurableSpace S] (E : Env S) (T k : ℕ) : ℝ :=
  (1 / (T : ℝ)) * ∑ t : Fin T,
    (E.meanB T k t - (1 / (T : ℝ)) * ∑ s : Fin T, E.meanB T k s) ^ 2

/-- The sigma-algebra `F_a^b = σ((X_t, Z_t, Y_t) : a ≤ t ≤ b)` on trajectories. -/
@[instance_reducible]
def sigmaWindow [MeasurableSpace S] (T a b : ℕ) : MeasurableSpace (Traj S T) :=
  ⨆ t : Fin T, ⨆ _ : a ≤ (t : ℕ) ∧ (t : ℕ) ≤ b,
    MeasurableSpace.comap (fun ω : Traj S T => ω t) inferInstance

/-- Local summand `Γ_t = 2 (2 Z_t - 1) ∑_{t ≤ u ≤ t + k, u < T} Y_u`. -/
noncomputable def GammaTerm {T : ℕ} (k : ℕ) (t : Fin T) (ω : Traj S T) : ℝ :=
  ipw (Z t ω) * ∑ u : Fin T, if (t : ℕ) ≤ (u : ℕ) ∧ (u : ℕ) ≤ (t : ℕ) + k then Y u ω else 0

/-- The sigma-algebra `σ(Γ_t : a ≤ t ≤ b)` on trajectories. -/
@[instance_reducible]
noncomputable def sigmaGamma (S : Type) (T k a b : ℕ) : MeasurableSpace (Traj S T) :=
  ⨆ t : Fin T, ⨆ _ : a ≤ (t : ℕ) ∧ (t : ℕ) ≤ b,
    MeasurableSpace.comap (fun ω : Traj S T => GammaTerm k t ω) inferInstance

/-- Assumption 2 (asymptotic variance) with limit `v`: the normalized variances
`(1/T) Var(∑_{t < T} B_t)` converge to `v` as `T → ∞`, and `0 < v`. -/
def Env.AsymptoticVariance [MeasurableSpace S] (E : Env S) (k : ℕ) (v : ℝ) : Prop :=
  0 < v ∧ Filter.Tendsto (fun T : ℕ => E.normVar T k) Filter.atTop (nhds v)

/-- Assumption 3 (Cesàro-`L²` mean stability): `Δ_T² = o(T^{-2/3})` as `T → ∞`. -/
def Env.MeanStability [MeasurableSpace S] (E : Env S) (k : ℕ) : Prop :=
  Asymptotics.IsLittleO Filter.atTop
    (fun T : ℕ => E.cesaroDevSq T k) (fun T : ℕ => (T : ℝ) ^ (-(2 / 3) : ℝ))

/-- Bandwidth conditions on the deterministic integer sequence `L_T`:
`0 ≤ L_T < T` for every `T ≥ 1`, `L_T → ∞`, and `L_T = O(T^{1/3})`. -/
def IsBandwidth (L : ℕ → ℕ) : Prop :=
  (∀ T : ℕ, 0 < T → L T < T)
    ∧ Filter.Tendsto L Filter.atTop Filter.atTop
    ∧ Asymptotics.IsBigO Filter.atTop
        (fun T : ℕ => (L T : ℝ)) (fun T : ℕ => (T : ℝ) ^ ((1 : ℝ) / 3))

/-- Convergence in distribution, as the horizon `T → ∞`, of the statistics `W T` computed on a
trajectory of length `T` generated under `π_{1/2}`, to the centered normal law with variance `v`:
`E[f(W_T)] → ∫ f dN(0, v)` for every bounded continuous `f : ℝ → ℝ`. -/
def Env.TendstoNormal [MeasurableSpace S] (E : Env S) (W : (T : ℕ) → Traj S T → ℝ)
    (v : ℝ) : Prop :=
  ∀ f : BoundedContinuousFunction ℝ ℝ,
    Filter.Tendsto (fun T : ℕ => ∫ ω, f (W T ω) ∂(E.expLaw T (1 / 2))) Filter.atTop
      (nhds (∫ x, f x ∂(gaussianReal 0 (Real.toNNReal v))))

/-- Convergence in probability, as the horizon `T → ∞`, of the statistics `W T` computed on a
trajectory of length `T` generated under `π_{1/2}`, to the constant `c`:
`P(|W_T - c| ≥ ε) → 0` for every `ε > 0`. -/
def Env.TendstoInProb [MeasurableSpace S] (E : Env S) (W : (T : ℕ) → Traj S T → ℝ)
    (c : ℝ) : Prop :=
  ∀ ε : ℝ, 0 < ε →
    Filter.Tendsto (fun T : ℕ => (E.expLaw T (1 / 2)) {ω | ε ≤ |W T ω - c|}) Filter.atTop
      (nhds 0)

end TPG
Source
Johari, Peng, Xing, Estimation of Treatment Effects Under Nonstationarity via the Truncated Policy Gradient Estimator, revised manuscript of October 2026 (revision of arXiv:2506.05308v3, https://arxiv.org/abs/2506.05308); numbering follows the revised manuscript. §6, p. 17: definitions of w^IPW, B_t, B̄, Assumption 2, Assumption 3, Theorem 2 (Γ̂_ℓ, w^NW_ℓ, L_T, Ω̂_T); Appendix A.4, pp. 28–29: Lemma 2 (F_a^b), Corollary 1 (Γ_t); Appendix F.2, p. 42: Lemma 4 (ideal HAC estimator).
Read-back

What the Lean code literally says, in plain math · claude-opus-5-5

Read-back: definition file TPG_Inference

One entry per declaration, in file order. Each entry is written to be read on its own, so the shared background (trajectories, the environment, the measure μT\mu_TμT​, the quantities Bt(k)B^{(k)}_tBt(k)​) is restated wherever it is used.


ipw — Takes a single argument, a flag z∈{true,false}z\in\lbrace\mathsf{true},\mathsf{false}\rbracez∈{true,false}, and returns the real number

ι(z)=2⋅(2⋅1[z]−1),\iota(z)=2\cdot\big(2\cdot\mathbf 1[z]-1\big),ι(z)=2⋅(2⋅1[z]−1),

where 1[true]=1\mathbf 1[\mathsf{true}]=11[true]=1 and 1[false]=0\mathbf 1[\mathsf{false}]=01[false]=0. So ι(true)=2\iota(\mathsf{true})=2ι(true)=2 and ι(false)=−2\iota(\mathsf{false})=-2ι(false)=−2. There is no other argument: the value does not depend on any probability parameter, on a state space, or on a horizon.


Bt — Arguments: a type SSS; a natural number TTT (implicit, read off from the other arguments); a natural number kkk; an index t∈{0,1,…,T−1}t\in\lbrace 0,1,\dots,T-1\rbracet∈{0,1,…,T−1} (indices are zero-based); and a trajectory ω\omegaω of length TTT, meaning a function that assigns to each index i∈{0,1,…,T−1}i\in\lbrace 0,1,\dots,T-1\rbracei∈{0,1,…,T−1} a triple ωi=(Xi(ω),Zi(ω),Yi(ω))\omega_i=(X_i(\omega),Z_i(\omega),Y_i(\omega))ωi​=(Xi​(ω),Zi​(ω),Yi​(ω)) with Xi(ω)∈SX_i(\omega)\in SXi​(ω)∈S, Zi(ω)∈{true,false}Z_i(\omega)\in\lbrace\mathsf{true},\mathsf{false}\rbraceZi​(ω)∈{true,false} and Yi(ω)∈RY_i(\omega)\in\mathbb RYi​(ω)∈R. (The file's standing declarations also supply a finite-type structure on SSS; this definition uses neither finiteness of SSS nor any σ-algebra on SSS, and the components Xi(ω)X_i(\omega)Xi​(ω) do not enter.) The output is the real number

Bt(k)(ω)=∑i=0T−11[i≤t and t≤i+k]⋅ι(Zi(ω))⋅Yt(ω),B^{(k)}_t(\omega)=\sum_{i=0}^{T-1}\mathbf 1\big[i\le t\ \text{and}\ t\le i+k\big]\cdot\iota(Z_i(\omega))\cdot Y_t(\omega),Bt(k)​(ω)=i=0∑T−1​1[i≤t and t≤i+k]⋅ι(Zi​(ω))⋅Yt​(ω),

where 1[⋅]\mathbf 1[\cdot]1[⋅] is 111 if the condition holds and 000 otherwise, and ι(true)=2\iota(\mathsf{true})=2ι(true)=2, ι(false)=−2\iota(\mathsf{false})=-2ι(false)=−2 (in the code, ι(z)=2⋅(2⋅1[z]−1)\iota(z)=2\cdot(2\cdot\mathbf 1[z]-1)ι(z)=2⋅(2⋅1[z]−1)). Equivalently,

Bt(k)(ω)=Yt(ω)⋅∑i=max⁡(t−k,0)tι(Zi(ω)):B^{(k)}_t(\omega)=Y_t(\omega)\cdot\sum_{i=\max(t-k,0)}^{t}\iota(Z_i(\omega)):Bt(k)​(ω)=Yt​(ω)⋅i=max(t−k,0)∑t​ι(Zi​(ω)):

the real entry at index ttt multiplied by the sum of the values ±2\pm 2±2 attached to the flags at the indices iii with t−k≤i≤tt-k\le i\le tt−k≤i≤t. That window has min⁡(t,k)+1\min(t,k)+1min(t,k)+1 indices; it is cut off at index 000 when t<kt<kt<k. For k=0k=0k=0 the value is ι(Zt(ω))⋅Yt(ω)\iota(Z_t(\omega))\cdot Y_t(\omega)ι(Zt​(ω))⋅Yt​(ω). For T=0T=0T=0 there is no index ttt, so the function has empty domain.


Bbar — Arguments: a type SSS; natural numbers TTT and kkk; and a trajectory ω\omegaω of length TTT, meaning a function that assigns to each index t∈{0,1,…,T−1}t\in\lbrace 0,1,\dots,T-1\rbracet∈{0,1,…,T−1} a triple ωt=(Xt(ω),Zt(ω),Yt(ω))\omega_t=(X_t(\omega),Z_t(\omega),Y_t(\omega))ωt​=(Xt​(ω),Zt​(ω),Yt​(ω)) with Xt(ω)∈SX_t(\omega)\in SXt​(ω)∈S, Zt(ω)∈{true,false}Z_t(\omega)\in\lbrace\mathsf{true},\mathsf{false}\rbraceZt​(ω)∈{true,false} and Yt(ω)∈RY_t(\omega)\in\mathbb RYt​(ω)∈R. (The file's standing declarations also supply a finite-type structure on SSS; this definition uses neither finiteness of SSS nor any σ-algebra on SSS.) The output is the real number

BˉT,k(ω)=1T∑t=0T−1Bt(k)(ω),Bt(k)(ω)=∑i=0T−11[i≤t and t≤i+k]⋅ι(Zi(ω))⋅Yt(ω)=Yt(ω)⋅∑i=max⁡(t−k,0)tι(Zi(ω)),\bar B_{T,k}(\omega)=\frac1T\sum_{t=0}^{T-1}B^{(k)}_t(\omega),\qquad B^{(k)}_t(\omega)=\sum_{i=0}^{T-1}\mathbf 1\big[i\le t\ \text{and}\ t\le i+k\big]\cdot\iota(Z_i(\omega))\cdot Y_t(\omega)=Y_t(\omega)\cdot\sum_{i=\max(t-k,0)}^{t}\iota(Z_i(\omega)),BˉT,k​(ω)=T1​t=0∑T−1​Bt(k)​(ω),Bt(k)​(ω)=i=0∑T−1​1[i≤t and t≤i+k]⋅ι(Zi​(ω))⋅Yt​(ω)=Yt​(ω)⋅i=max(t−k,0)∑t​ι(Zi​(ω)),

with ι(true)=2\iota(\mathsf{true})=2ι(true)=2 and ι(false)=−2\iota(\mathsf{false})=-2ι(false)=−2. The factor 1/T1/T1/T is a division of real numbers; by the proof assistant's convention 1/0=01/0=01/0=0, so for T=0T=0T=0 the value is 000 (and the sum is empty).


GammaHat — Arguments: a type SSS; natural numbers TTT, kkk and ℓ\ellℓ; and a trajectory ω\omegaω of length TTT, meaning a function that assigns to each index t∈{0,1,…,T−1}t\in\lbrace 0,1,\dots,T-1\rbracet∈{0,1,…,T−1} a triple ωt=(Xt(ω),Zt(ω),Yt(ω))\omega_t=(X_t(\omega),Z_t(\omega),Y_t(\omega))ωt​=(Xt​(ω),Zt​(ω),Yt​(ω)) with Xt(ω)∈SX_t(\omega)\in SXt​(ω)∈S, Zt(ω)∈{true,false}Z_t(\omega)\in\lbrace\mathsf{true},\mathsf{false}\rbraceZt​(ω)∈{true,false} and Yt(ω)∈RY_t(\omega)\in\mathbb RYt​(ω)∈R. (The file's standing declarations also supply a finite-type structure on SSS; this definition uses neither finiteness of SSS nor any σ-algebra on SSS.) Put ι(true)=2\iota(\mathsf{true})=2ι(true)=2, ι(false)=−2\iota(\mathsf{false})=-2ι(false)=−2,

Bt=Bt(k)(ω)=∑i=0T−11[i≤t and t≤i+k]⋅ι(Zi(ω))⋅Yt(ω)=Yt(ω)⋅∑i=max⁡(t−k,0)tι(Zi(ω)),Bˉ=1T∑t=0T−1Bt.B_t=B^{(k)}_t(\omega)=\sum_{i=0}^{T-1}\mathbf 1\big[i\le t\ \text{and}\ t\le i+k\big]\cdot\iota(Z_i(\omega))\cdot Y_t(\omega)=Y_t(\omega)\cdot\sum_{i=\max(t-k,0)}^{t}\iota(Z_i(\omega)),\qquad \bar B=\frac1T\sum_{t=0}^{T-1}B_t .Bt​=Bt(k)​(ω)=i=0∑T−1​1[i≤t and t≤i+k]⋅ι(Zi​(ω))⋅Yt​(ω)=Yt​(ω)⋅i=max(t−k,0)∑t​ι(Zi​(ω)),Bˉ=T1​t=0∑T−1​Bt​.

The output is the real number

Γ^T,k,ℓ(ω)=1T∑t=0T−1∑t′=0T−11[t+ℓ=t′]⋅(Bt−Bˉ)(Bt′−Bˉ),\widehat\Gamma_{T,k,\ell}(\omega)=\frac1T\sum_{t=0}^{T-1}\sum_{t'=0}^{T-1}\mathbf 1\big[t+\ell=t'\big]\cdot\big(B_t-\bar B\big)\big(B_{t'}-\bar B\big),ΓT,k,ℓ​(ω)=T1​t=0∑T−1​t′=0∑T−1​1[t+ℓ=t′]⋅(Bt​−Bˉ)(Bt′​−Bˉ),

that is, 1T\frac1TT1​ times the sum of (Bt−Bˉ)(Bt+ℓ−Bˉ)(B_t-\bar B)(B_{t+\ell}-\bar B)(Bt​−Bˉ)(Bt+ℓ​−Bˉ) over those t≥0t\ge 0t≥0 with t+ℓ≤T−1t+\ell\le T-1t+ℓ≤T−1. Both factors are centred by the same number Bˉ\bar BBˉ, the average over all TTT indices. The normalising factor is 1/T1/T1/T for every ℓ\ellℓ (not one over the number of terms, which is T−ℓT-\ellT−ℓ when ℓ<T\ell<Tℓ<T). For ℓ=0\ell=0ℓ=0 the value is 1T∑t(Bt−Bˉ)2\frac1T\sum_t(B_t-\bar B)^2T1​∑t​(Bt​−Bˉ)2. For ℓ≥T\ell\ge Tℓ≥T no pair (t,t′)(t,t')(t,t′) qualifies and the value is 000. For T=0T=0T=0 the value is 000 (empty sums, and 1/0=01/0=01/0=0 by the proof assistant's convention).


nwWeight — Takes two natural numbers LLL and ℓ\ellℓ and returns the real number

wL(ℓ)=1−ℓL+1,w_L(\ell)=1-\frac{\ell}{L+1},wL​(ℓ)=1−L+1ℓ​,

where ℓ\ellℓ and LLL are converted to real numbers before the division and subtraction (so there is no truncation). The denominator L+1L+1L+1 is at least 111 and is never zero. No relation between ℓ\ellℓ and LLL is required: wL(0)=1w_L(0)=1wL​(0)=1, wL(L)=1L+1w_L(L)=\frac{1}{L+1}wL​(L)=L+11​, wL(L+1)=0w_L(L+1)=0wL​(L+1)=0, and wL(ℓ)<0w_L(\ell)<0wL​(ℓ)<0 for ℓ>L+1\ell>L+1ℓ>L+1.


hacEst — Arguments: a type SSS; natural numbers TTT, kkk and LLL; and a trajectory ω\omegaω of length TTT, meaning a function that assigns to each index t∈{0,1,…,T−1}t\in\lbrace 0,1,\dots,T-1\rbracet∈{0,1,…,T−1} a triple ωt=(Xt(ω),Zt(ω),Yt(ω))\omega_t=(X_t(\omega),Z_t(\omega),Y_t(\omega))ωt​=(Xt​(ω),Zt​(ω),Yt​(ω)) with Xt(ω)∈SX_t(\omega)\in SXt​(ω)∈S, Zt(ω)∈{true,false}Z_t(\omega)\in\lbrace\mathsf{true},\mathsf{false}\rbraceZt​(ω)∈{true,false} and Yt(ω)∈RY_t(\omega)\in\mathbb RYt​(ω)∈R. (The file's standing declarations also supply a finite-type structure on SSS; this definition uses neither finiteness of SSS nor any σ-algebra on SSS.) Put ι(true)=2\iota(\mathsf{true})=2ι(true)=2, ι(false)=−2\iota(\mathsf{false})=-2ι(false)=−2,

Bt=∑i=0T−11[i≤t and t≤i+k]⋅ι(Zi(ω))⋅Yt(ω)=Yt(ω)⋅∑i=max⁡(t−k,0)tι(Zi(ω)),Bˉ=1T∑t=0T−1Bt,B_t=\sum_{i=0}^{T-1}\mathbf 1\big[i\le t\ \text{and}\ t\le i+k\big]\cdot\iota(Z_i(\omega))\cdot Y_t(\omega)=Y_t(\omega)\cdot\sum_{i=\max(t-k,0)}^{t}\iota(Z_i(\omega)),\qquad \bar B=\frac1T\sum_{t=0}^{T-1}B_t,Bt​=i=0∑T−1​1[i≤t and t≤i+k]⋅ι(Zi​(ω))⋅Yt​(ω)=Yt​(ω)⋅i=max(t−k,0)∑t​ι(Zi​(ω)),Bˉ=T1​t=0∑T−1​Bt​,

and, for each natural number ℓ\ellℓ,

Γ^ℓ=1T∑t=0T−1∑t′=0T−11[t+ℓ=t′]⋅(Bt−Bˉ)(Bt′−Bˉ)\widehat\Gamma_\ell=\frac1T\sum_{t=0}^{T-1}\sum_{t'=0}^{T-1}\mathbf 1\big[t+\ell=t'\big]\cdot\big(B_t-\bar B\big)\big(B_{t'}-\bar B\big)Γℓ​=T1​t=0∑T−1​t′=0∑T−1​1[t+ℓ=t′]⋅(Bt​−Bˉ)(Bt′​−Bˉ)

(the sum of (Bt−Bˉ)(Bt+ℓ−Bˉ)(B_t-\bar B)(B_{t+\ell}-\bar B)(Bt​−Bˉ)(Bt+ℓ​−Bˉ) over ttt with t+ℓ≤T−1t+\ell\le T-1t+ℓ≤T−1, always divided by TTT). The output is the real number

hacEstT,k,L(ω)=Γ^0+2∑ℓ=1L(1−ℓL+1)⋅Γ^ℓ,\mathrm{hacEst}_{T,k,L}(\omega)=\widehat\Gamma_0+2\sum_{\ell=1}^{L}\Big(1-\frac{\ell}{L+1}\Big)\cdot\widehat\Gamma_\ell ,hacEstT,k,L​(ω)=Γ0​+2ℓ=1∑L​(1−L+1ℓ​)⋅Γℓ​,

where the sum runs over the natural numbers ℓ\ellℓ with 1≤ℓ≤L1\le\ell\le L1≤ℓ≤L and the weight 1−ℓL+11-\frac{\ell}{L+1}1−L+1ℓ​ is computed in the real numbers. No relation between LLL and TTT is assumed: terms with ℓ≥T\ell\ge Tℓ≥T are present but equal to 000. For L=0L=0L=0 the sum is empty and the value is Γ^0\widehat\Gamma_0Γ0​. For T=0T=0T=0 the value is 000 (by the convention 1/0=01/0=01/0=0).


Env.meanB — Arguments: a finite type SSS carrying a given σ-algebra, which is arbitrary (it is not assumed to be discrete, nor that singletons are measurable); an environment EEE on SSS; natural numbers TTT and kkk; and an index t∈{0,1,…,T−1}t\in\lbrace 0,1,\dots,T-1\rbracet∈{0,1,…,T−1}. An environment consists of exactly the following data: (i) for every natural number sss (all of N\mathbb NN, not only s<Ts<Ts<T) and every flag z∈{true,false}z\in\lbrace\mathsf{true},\mathsf{false}\rbracez∈{true,false}, a real S×SS\times SS×S matrix PszP^{z}_{s}Psz​ whose entries are all ≥0\ge 0≥0 and each of whose rows sums to 111; (ii) a function ρ:S→R\rho:S\to\mathbb Rρ:S→R with all values ≥0\ge 0≥0 and ∑x∈Sρ(x)=1\sum_{x\in S}\rho(x)=1∑x∈S​ρ(x)=1; (iii) for every x∈Sx\in Sx∈S and every flag zzz, a probability measure Rx,zR_{x,z}Rx,z​ on the Borel sets of R\mathbb RR, with no boundedness or moment assumption.

A trajectory of length TTT is a function ω\omegaω assigning to each index u∈{0,1,…,T−1}u\in\lbrace 0,1,\dots,T-1\rbraceu∈{0,1,…,T−1} a triple ωu=(Xu(ω),Zu(ω),Yu(ω))∈S×{true,false}×R\omega_u=(X_u(\omega),Z_u(\omega),Y_u(\omega))\in S\times\lbrace\mathsf{true},\mathsf{false}\rbrace\times\mathbb Rωu​=(Xu​(ω),Zu​(ω),Yu​(ω))∈S×{true,false}×R; the set ΩT\Omega_TΩT​ of all of them carries the product σ-algebra (the given σ-algebra on SSS, all subsets of {true,false}\lbrace\mathsf{true},\mathsf{false}\rbrace{true,false}, the Borel sets of R\mathbb RR). The measure μT\mu_TμT​ on ΩT\Omega_TΩT​ is the finite sum over all pairs (x,z)(x,z)(x,z) of a state path x:{0,…,T−1}→Sx:\lbrace 0,\dots,T-1\rbrace\to Sx:{0,…,T−1}→S and a flag path z:{0,…,T−1}→{true,false}z:\lbrace 0,\dots,T-1\rbrace\to\lbrace\mathsf{true},\mathsf{false}\rbracez:{0,…,T−1}→{true,false}:

μT=∑(x,z)max⁡(wT(x,z),0)⋅⨂u=0T−1(δxu⊗δzu⊗Rxu,zu),wT(x,z)=ρ(x0)⋅∏s=0T−2Pszs(xs,xs+1)⋅(12)T,\mu_T=\sum_{(x,z)}\max\big(w_T(x,z),0\big)\cdot\bigotimes_{u=0}^{T-1}\Big(\delta_{x_u}\otimes\delta_{z_u}\otimes R_{x_u,z_u}\Big),\qquad w_T(x,z)=\rho(x_0)\cdot\prod_{s=0}^{T-2}P^{z_s}_{s}(x_s,x_{s+1})\cdot\Big(\frac12\Big)^{T},μT​=(x,z)∑​max(wT​(x,z),0)⋅u=0⨂T−1​(δxu​​⊗δzu​​⊗Rxu​,zu​​),wT​(x,z)=ρ(x0​)⋅s=0∏T−2​Pszs​​(xs​,xs+1​)⋅(21​)T,

where δ\deltaδ is a Dirac mass and ⨂\bigotimes⨂ is the product measure over the TTT indices. (The code builds wTw_TwT​ as a product over all indices: a factor ρ(xu)\rho(x_u)ρ(xu​) for the index u=0u=0u=0; a factor Pszs(xs,xu)P^{z_s}_{s}(x_s,x_u)Pszs​​(xs​,xu​) for every pair of indices with s+1=us+1=us+1=u; and for every uuu a factor equal to qqq if zu=truez_u=\mathsf{true}zu​=true and 1−q1-q1−q if zu=falsez_u=\mathsf{false}zu​=false, with the constant q=12q=\frac12q=21​ fixed by this definition. Negative weights would be replaced by 000; here every factor is ≥0\ge 0≥0 and the weights sum to 111. For T=0T=0T=0 all products are empty, w0=1w_0=1w0​=1, and μ0\mu_0μ0​ is the unit mass on the one-point set Ω0\Omega_0Ω0​.)

The output is the real number

mT,k,t=∫ΩTBt(k)(ω) dμT(ω),Bt(k)(ω)=∑i=0T−11[i≤t and t≤i+k]⋅ι(Zi(ω))⋅Yt(ω)=Yt(ω)⋅∑i=max⁡(t−k,0)tι(Zi(ω)),m_{T,k,t}=\int_{\Omega_T}B^{(k)}_t(\omega)\ d\mu_T(\omega),\qquad B^{(k)}_t(\omega)=\sum_{i=0}^{T-1}\mathbf 1\big[i\le t\ \text{and}\ t\le i+k\big]\cdot\iota(Z_i(\omega))\cdot Y_t(\omega)=Y_t(\omega)\cdot\sum_{i=\max(t-k,0)}^{t}\iota(Z_i(\omega)),mT,k,t​=∫ΩT​​Bt(k)​(ω) dμT​(ω),Bt(k)​(ω)=i=0∑T−1​1[i≤t and t≤i+k]⋅ι(Zi​(ω))⋅Yt​(ω)=Yt​(ω)⋅i=max(t−k,0)∑t​ι(Zi​(ω)),

with ι(true)=2\iota(\mathsf{true})=2ι(true)=2 and ι(false)=−2\iota(\mathsf{false})=-2ι(false)=−2. The integral is a Bochner integral, which by the library's convention equals 000 when the integrand is not μT\mu_TμT​-integrable; no integrability is assumed. For T=0T=0T=0 there is no index ttt, so the function has empty domain.


Env.GammaIdeal — Arguments: a finite type SSS carrying a given σ-algebra, which is arbitrary (it is not assumed to be discrete, nor that singletons are measurable); an environment EEE on SSS; natural numbers TTT, kkk and ℓ\ellℓ; and a trajectory ω∈ΩT\omega\in\Omega_Tω∈ΩT​. An environment consists of exactly the following data: (i) for every natural number sss (all of N\mathbb NN, not only s<Ts<Ts<T) and every flag z∈{true,false}z\in\lbrace\mathsf{true},\mathsf{false}\rbracez∈{true,false}, a real S×SS\times SS×S matrix PszP^{z}_{s}Psz​ whose entries are all ≥0\ge 0≥0 and each of whose rows sums to 111; (ii) a function ρ:S→R\rho:S\to\mathbb Rρ:S→R with all values ≥0\ge 0≥0 and ∑x∈Sρ(x)=1\sum_{x\in S}\rho(x)=1∑x∈S​ρ(x)=1; (iii) for every x∈Sx\in Sx∈S and every flag zzz, a probability measure Rx,zR_{x,z}Rx,z​ on the Borel sets of R\mathbb RR, with no boundedness or moment assumption.

A trajectory of length TTT is a function ω\omegaω assigning to each index t∈{0,1,…,T−1}t\in\lbrace 0,1,\dots,T-1\rbracet∈{0,1,…,T−1} a triple ωt=(Xt(ω),Zt(ω),Yt(ω))∈S×{true,false}×R\omega_t=(X_t(\omega),Z_t(\omega),Y_t(\omega))\in S\times\lbrace\mathsf{true},\mathsf{false}\rbrace\times\mathbb Rωt​=(Xt​(ω),Zt​(ω),Yt​(ω))∈S×{true,false}×R; the set ΩT\Omega_TΩT​ of all of them carries the product σ-algebra (the given σ-algebra on SSS, all subsets of {true,false}\lbrace\mathsf{true},\mathsf{false}\rbrace{true,false}, the Borel sets of R\mathbb RR). The measure μT\mu_TμT​ on ΩT\Omega_TΩT​ is the finite sum over all pairs (x,z)(x,z)(x,z) of a state path x:{0,…,T−1}→Sx:\lbrace 0,\dots,T-1\rbrace\to Sx:{0,…,T−1}→S and a flag path z:{0,…,T−1}→{true,false}z:\lbrace 0,\dots,T-1\rbrace\to\lbrace\mathsf{true},\mathsf{false}\rbracez:{0,…,T−1}→{true,false}:

μT=∑(x,z)max⁡(wT(x,z),0)⋅⨂t=0T−1(δxt⊗δzt⊗Rxt,zt),wT(x,z)=ρ(x0)⋅∏s=0T−2Pszs(xs,xs+1)⋅(12)T,\mu_T=\sum_{(x,z)}\max\big(w_T(x,z),0\big)\cdot\bigotimes_{t=0}^{T-1}\Big(\delta_{x_t}\otimes\delta_{z_t}\otimes R_{x_t,z_t}\Big),\qquad w_T(x,z)=\rho(x_0)\cdot\prod_{s=0}^{T-2}P^{z_s}_{s}(x_s,x_{s+1})\cdot\Big(\frac12\Big)^{T},μT​=(x,z)∑​max(wT​(x,z),0)⋅t=0⨂T−1​(δxt​​⊗δzt​​⊗Rxt​,zt​​),wT​(x,z)=ρ(x0​)⋅s=0∏T−2​Pszs​​(xs​,xs+1​)⋅(21​)T,

where δ\deltaδ is a Dirac mass and ⨂\bigotimes⨂ is the product measure over the TTT indices. (The code builds wTw_TwT​ as a product over all indices: a factor ρ(xt)\rho(x_t)ρ(xt​) for the index t=0t=0t=0; a factor Pszs(xs,xt)P^{z_s}_{s}(x_s,x_t)Pszs​​(xs​,xt​) for every pair of indices with s+1=ts+1=ts+1=t; and for every ttt a factor equal to qqq if zt=truez_t=\mathsf{true}zt​=true and 1−q1-q1−q if zt=falsez_t=\mathsf{false}zt​=false, with the constant q=12q=\frac12q=21​ fixed by this definition. Negative weights would be replaced by 000; here every factor is ≥0\ge 0≥0 and the weights sum to 111. For T=0T=0T=0 all products are empty, w0=1w_0=1w0​=1, and μ0\mu_0μ0​ is the unit mass on the one-point set Ω0\Omega_0Ω0​.)

Put ι(true)=2\iota(\mathsf{true})=2ι(true)=2, ι(false)=−2\iota(\mathsf{false})=-2ι(false)=−2, and for t∈{0,…,T−1}t\in\lbrace 0,\dots,T-1\rbracet∈{0,…,T−1}

Bt(ω)=∑i=0T−11[i≤t and t≤i+k]⋅ι(Zi(ω))⋅Yt(ω)=Yt(ω)⋅∑i=max⁡(t−k,0)tι(Zi(ω)),mt=∫ΩTBt dμT,B_t(\omega)=\sum_{i=0}^{T-1}\mathbf 1\big[i\le t\ \text{and}\ t\le i+k\big]\cdot\iota(Z_i(\omega))\cdot Y_t(\omega)=Y_t(\omega)\cdot\sum_{i=\max(t-k,0)}^{t}\iota(Z_i(\omega)),\qquad m_t=\int_{\Omega_T}B_t\ d\mu_T,Bt​(ω)=i=0∑T−1​1[i≤t and t≤i+k]⋅ι(Zi​(ω))⋅Yt​(ω)=Yt​(ω)⋅i=max(t−k,0)∑t​ι(Zi​(ω)),mt​=∫ΩT​​Bt​ dμT​,

the integral being a Bochner integral (equal to 000 by convention if BtB_tBt​ is not μT\mu_TμT​-integrable; no integrability is assumed). The output is the real number

ΓT,k,ℓE(ω)=1T∑t=0T−1∑t′=0T−11[t+ℓ=t′]⋅(Bt(ω)−mt)(Bt′(ω)−mt′),\Gamma^{E}_{T,k,\ell}(\omega)=\frac1T\sum_{t=0}^{T-1}\sum_{t'=0}^{T-1}\mathbf 1\big[t+\ell=t'\big]\cdot\big(B_t(\omega)-m_t\big)\big(B_{t'}(\omega)-m_{t'}\big),ΓT,k,ℓE​(ω)=T1​t=0∑T−1​t′=0∑T−1​1[t+ℓ=t′]⋅(Bt​(ω)−mt​)(Bt′​(ω)−mt′​),

that is, 1T\frac1TT1​ times the sum of (Bt(ω)−mt)(Bt+ℓ(ω)−mt+ℓ)(B_t(\omega)-m_t)(B_{t+\ell}(\omega)-m_{t+\ell})(Bt​(ω)−mt​)(Bt+ℓ​(ω)−mt+ℓ​) over those t≥0t\ge 0t≥0 with t+ℓ≤T−1t+\ell\le T-1t+ℓ≤T−1. Each factor is centred by the number mmm attached to its own index. The normalising factor is 1/T1/T1/T for every ℓ\ellℓ. For ℓ≥T\ell\ge Tℓ≥T the value is 000; for T=0T=0T=0 the value is 000 (empty sums, and 1/0=01/0=01/0=0 by the proof assistant's convention). The trajectory ω\omegaω is an arbitrary element of ΩT\Omega_TΩT​; the measure μT\mu_TμT​ enters only through the constants mtm_tmt​.


Env.hacIdeal — Arguments: a finite type SSS carrying a given σ-algebra, which is arbitrary (it is not assumed to be discrete, nor that singletons are measurable); an environment EEE on SSS; natural numbers TTT, kkk and LLL; and a trajectory ω∈ΩT\omega\in\Omega_Tω∈ΩT​. An environment consists of exactly the following data: (i) for every natural number sss (all of N\mathbb NN, not only s<Ts<Ts<T) and every flag z∈{true,false}z\in\lbrace\mathsf{true},\mathsf{false}\rbracez∈{true,false}, a real S×SS\times SS×S matrix PszP^{z}_{s}Psz​ whose entries are all ≥0\ge 0≥0 and each of whose rows sums to 111; (ii) a function ρ:S→R\rho:S\to\mathbb Rρ:S→R with all values ≥0\ge 0≥0 and ∑x∈Sρ(x)=1\sum_{x\in S}\rho(x)=1∑x∈S​ρ(x)=1; (iii) for every x∈Sx\in Sx∈S and every flag zzz, a probability measure Rx,zR_{x,z}Rx,z​ on the Borel sets of R\mathbb RR, with no boundedness or moment assumption.

A trajectory of length TTT is a function ω\omegaω assigning to each index t∈{0,1,…,T−1}t\in\lbrace 0,1,\dots,T-1\rbracet∈{0,1,…,T−1} a triple ωt=(Xt(ω),Zt(ω),Yt(ω))∈S×{true,false}×R\omega_t=(X_t(\omega),Z_t(\omega),Y_t(\omega))\in S\times\lbrace\mathsf{true},\mathsf{false}\rbrace\times\mathbb Rωt​=(Xt​(ω),Zt​(ω),Yt​(ω))∈S×{true,false}×R; the set ΩT\Omega_TΩT​ of all of them carries the product σ-algebra (the given σ-algebra on SSS, all subsets of {true,false}\lbrace\mathsf{true},\mathsf{false}\rbrace{true,false}, the Borel sets of R\mathbb RR). The measure μT\mu_TμT​ on ΩT\Omega_TΩT​ is the finite sum over all pairs (x,z)(x,z)(x,z) of a state path x:{0,…,T−1}→Sx:\lbrace 0,\dots,T-1\rbrace\to Sx:{0,…,T−1}→S and a flag path z:{0,…,T−1}→{true,false}z:\lbrace 0,\dots,T-1\rbrace\to\lbrace\mathsf{true},\mathsf{false}\rbracez:{0,…,T−1}→{true,false}:

μT=∑(x,z)max⁡(wT(x,z),0)⋅⨂t=0T−1(δxt⊗δzt⊗Rxt,zt),wT(x,z)=ρ(x0)⋅∏s=0T−2Pszs(xs,xs+1)⋅(12)T,\mu_T=\sum_{(x,z)}\max\big(w_T(x,z),0\big)\cdot\bigotimes_{t=0}^{T-1}\Big(\delta_{x_t}\otimes\delta_{z_t}\otimes R_{x_t,z_t}\Big),\qquad w_T(x,z)=\rho(x_0)\cdot\prod_{s=0}^{T-2}P^{z_s}_{s}(x_s,x_{s+1})\cdot\Big(\frac12\Big)^{T},μT​=(x,z)∑​max(wT​(x,z),0)⋅t=0⨂T−1​(δxt​​⊗δzt​​⊗Rxt​,zt​​),wT​(x,z)=ρ(x0​)⋅s=0∏T−2​Pszs​​(xs​,xs+1​)⋅(21​)T,

where δ\deltaδ is a Dirac mass and ⨂\bigotimes⨂ is the product measure over the TTT indices. (The code builds wTw_TwT​ as a product over all indices: a factor ρ(xt)\rho(x_t)ρ(xt​) for the index t=0t=0t=0; a factor Pszs(xs,xt)P^{z_s}_{s}(x_s,x_t)Pszs​​(xs​,xt​) for every pair of indices with s+1=ts+1=ts+1=t; and for every ttt a factor equal to qqq if zt=truez_t=\mathsf{true}zt​=true and 1−q1-q1−q if zt=falsez_t=\mathsf{false}zt​=false, with the constant q=12q=\frac12q=21​ fixed by this definition. Negative weights would be replaced by 000; here every factor is ≥0\ge 0≥0 and the weights sum to 111. For T=0T=0T=0 all products are empty, w0=1w_0=1w0​=1, and μ0\mu_0μ0​ is the unit mass on the one-point set Ω0\Omega_0Ω0​.)

Put ι(true)=2\iota(\mathsf{true})=2ι(true)=2, ι(false)=−2\iota(\mathsf{false})=-2ι(false)=−2, and for t∈{0,…,T−1}t\in\lbrace 0,\dots,T-1\rbracet∈{0,…,T−1}

Bt(ω)=∑i=0T−11[i≤t and t≤i+k]⋅ι(Zi(ω))⋅Yt(ω)=Yt(ω)⋅∑i=max⁡(t−k,0)tι(Zi(ω)),mt=∫ΩTBt dμT,B_t(\omega)=\sum_{i=0}^{T-1}\mathbf 1\big[i\le t\ \text{and}\ t\le i+k\big]\cdot\iota(Z_i(\omega))\cdot Y_t(\omega)=Y_t(\omega)\cdot\sum_{i=\max(t-k,0)}^{t}\iota(Z_i(\omega)),\qquad m_t=\int_{\Omega_T}B_t\ d\mu_T,Bt​(ω)=i=0∑T−1​1[i≤t and t≤i+k]⋅ι(Zi​(ω))⋅Yt​(ω)=Yt​(ω)⋅i=max(t−k,0)∑t​ι(Zi​(ω)),mt​=∫ΩT​​Bt​ dμT​,

the integral being a Bochner integral (equal to 000 by convention if BtB_tBt​ is not μT\mu_TμT​-integrable; no integrability is assumed). For each natural number ℓ\ellℓ put

Γℓ(ω)=1T∑t=0T−1∑t′=0T−11[t+ℓ=t′]⋅(Bt(ω)−mt)(Bt′(ω)−mt′)\Gamma_\ell(\omega)=\frac1T\sum_{t=0}^{T-1}\sum_{t'=0}^{T-1}\mathbf 1\big[t+\ell=t'\big]\cdot\big(B_t(\omega)-m_t\big)\big(B_{t'}(\omega)-m_{t'}\big)Γℓ​(ω)=T1​t=0∑T−1​t′=0∑T−1​1[t+ℓ=t′]⋅(Bt​(ω)−mt​)(Bt′​(ω)−mt′​)

(the sum of (Bt(ω)−mt)(Bt+ℓ(ω)−mt+ℓ)(B_t(\omega)-m_t)(B_{t+\ell}(\omega)-m_{t+\ell})(Bt​(ω)−mt​)(Bt+ℓ​(ω)−mt+ℓ​) over ttt with t+ℓ≤T−1t+\ell\le T-1t+ℓ≤T−1, always divided by TTT). The output is the real number

HT,k,LE(ω)=Γ0(ω)+2∑ℓ=1L(1−ℓL+1)⋅Γℓ(ω),H^{E}_{T,k,L}(\omega)=\Gamma_0(\omega)+2\sum_{\ell=1}^{L}\Big(1-\frac{\ell}{L+1}\Big)\cdot\Gamma_\ell(\omega),HT,k,LE​(ω)=Γ0​(ω)+2ℓ=1∑L​(1−L+1ℓ​)⋅Γℓ​(ω),

where the sum runs over the natural numbers ℓ\ellℓ with 1≤ℓ≤L1\le\ell\le L1≤ℓ≤L and the weight 1−ℓL+11-\frac{\ell}{L+1}1−L+1ℓ​ is computed in the real numbers. No relation between LLL and TTT is assumed: terms with ℓ≥T\ell\ge Tℓ≥T are present but equal to 000. For L=0L=0L=0 the value is Γ0(ω)\Gamma_0(\omega)Γ0​(ω). For T=0T=0T=0 the value is 000 (by the convention 1/0=01/0=01/0=0).


Env.normVar — Arguments: a finite type SSS carrying a given σ-algebra, which is arbitrary (it is not assumed to be discrete, nor that singletons are measurable); an environment EEE on SSS; and natural numbers TTT and kkk. An environment consists of exactly the following data: (i) for every natural number sss (all of N\mathbb NN, not only s<Ts<Ts<T) and every flag z∈{true,false}z\in\lbrace\mathsf{true},\mathsf{false}\rbracez∈{true,false}, a real S×SS\times SS×S matrix PszP^{z}_{s}Psz​ whose entries are all ≥0\ge 0≥0 and each of whose rows sums to 111; (ii) a function ρ:S→R\rho:S\to\mathbb Rρ:S→R with all values ≥0\ge 0≥0 and ∑x∈Sρ(x)=1\sum_{x\in S}\rho(x)=1∑x∈S​ρ(x)=1; (iii) for every x∈Sx\in Sx∈S and every flag zzz, a probability measure Rx,zR_{x,z}Rx,z​ on the Borel sets of R\mathbb RR, with no boundedness or moment assumption.

A trajectory of length TTT is a function ω\omegaω assigning to each index t∈{0,1,…,T−1}t\in\lbrace 0,1,\dots,T-1\rbracet∈{0,1,…,T−1} a triple ωt=(Xt(ω),Zt(ω),Yt(ω))∈S×{true,false}×R\omega_t=(X_t(\omega),Z_t(\omega),Y_t(\omega))\in S\times\lbrace\mathsf{true},\mathsf{false}\rbrace\times\mathbb Rωt​=(Xt​(ω),Zt​(ω),Yt​(ω))∈S×{true,false}×R; the set ΩT\Omega_TΩT​ of all of them carries the product σ-algebra (the given σ-algebra on SSS, all subsets of {true,false}\lbrace\mathsf{true},\mathsf{false}\rbrace{true,false}, the Borel sets of R\mathbb RR). The measure μT\mu_TμT​ on ΩT\Omega_TΩT​ is the finite sum over all pairs (x,z)(x,z)(x,z) of a state path x:{0,…,T−1}→Sx:\lbrace 0,\dots,T-1\rbrace\to Sx:{0,…,T−1}→S and a flag path z:{0,…,T−1}→{true,false}z:\lbrace 0,\dots,T-1\rbrace\to\lbrace\mathsf{true},\mathsf{false}\rbracez:{0,…,T−1}→{true,false}:

μT=∑(x,z)max⁡(wT(x,z),0)⋅⨂t=0T−1(δxt⊗δzt⊗Rxt,zt),wT(x,z)=ρ(x0)⋅∏s=0T−2Pszs(xs,xs+1)⋅(12)T,\mu_T=\sum_{(x,z)}\max\big(w_T(x,z),0\big)\cdot\bigotimes_{t=0}^{T-1}\Big(\delta_{x_t}\otimes\delta_{z_t}\otimes R_{x_t,z_t}\Big),\qquad w_T(x,z)=\rho(x_0)\cdot\prod_{s=0}^{T-2}P^{z_s}_{s}(x_s,x_{s+1})\cdot\Big(\frac12\Big)^{T},μT​=(x,z)∑​max(wT​(x,z),0)⋅t=0⨂T−1​(δxt​​⊗δzt​​⊗Rxt​,zt​​),wT​(x,z)=ρ(x0​)⋅s=0∏T−2​Pszs​​(xs​,xs+1​)⋅(21​)T,

where δ\deltaδ is a Dirac mass and ⨂\bigotimes⨂ is the product measure over the TTT indices. (The code builds wTw_TwT​ as a product over all indices: a factor ρ(xt)\rho(x_t)ρ(xt​) for the index t=0t=0t=0; a factor Pszs(xs,xt)P^{z_s}_{s}(x_s,x_t)Pszs​​(xs​,xt​) for every pair of indices with s+1=ts+1=ts+1=t; and for every ttt a factor equal to qqq if zt=truez_t=\mathsf{true}zt​=true and 1−q1-q1−q if zt=falsez_t=\mathsf{false}zt​=false, with the constant q=12q=\frac12q=21​ fixed by this definition. Negative weights would be replaced by 000; here every factor is ≥0\ge 0≥0 and the weights sum to 111. For T=0T=0T=0 all products are empty, w0=1w_0=1w0​=1, and μ0\mu_0μ0​ is the unit mass on the one-point set Ω0\Omega_0Ω0​.)

Put ι(true)=2\iota(\mathsf{true})=2ι(true)=2, ι(false)=−2\iota(\mathsf{false})=-2ι(false)=−2, and let ΣT,k:ΩT→R\Sigma_{T,k}:\Omega_T\to\mathbb RΣT,k​:ΩT​→R be the function

ΣT,k(ω)=∑t=0T−1Bt(k)(ω),Bt(k)(ω)=∑i=0T−11[i≤t and t≤i+k]⋅ι(Zi(ω))⋅Yt(ω)=Yt(ω)⋅∑i=max⁡(t−k,0)tι(Zi(ω)).\Sigma_{T,k}(\omega)=\sum_{t=0}^{T-1}B^{(k)}_t(\omega),\qquad B^{(k)}_t(\omega)=\sum_{i=0}^{T-1}\mathbf 1\big[i\le t\ \text{and}\ t\le i+k\big]\cdot\iota(Z_i(\omega))\cdot Y_t(\omega)=Y_t(\omega)\cdot\sum_{i=\max(t-k,0)}^{t}\iota(Z_i(\omega)).ΣT,k​(ω)=t=0∑T−1​Bt(k)​(ω),Bt(k)​(ω)=i=0∑T−1​1[i≤t and t≤i+k]⋅ι(Zi​(ω))⋅Yt​(ω)=Yt​(ω)⋅i=max(t−k,0)∑t​ι(Zi​(ω)).

The output is the real number

VT,kE=1T⋅Var⁡μT(ΣT,k).V^{E}_{T,k}=\frac1T\cdot\operatorname{Var}_{\mu_T}\big(\Sigma_{T,k}\big).VT,kE​=T1​⋅VarμT​​(ΣT,k​).

Here Var⁡μT\operatorname{Var}_{\mu_T}VarμT​​ is the library's real-valued variance: with Σˉ=∫ΣT,k dμT\bar\Sigma=\int\Sigma_{T,k}\ d\mu_TΣˉ=∫ΣT,k​ dμT​ (a Bochner integral, equal to 000 by convention if ΣT,k\Sigma_{T,k}ΣT,k​ is not μT\mu_TμT​-integrable), it is the [0,∞][0,\infty][0,∞]-valued integral ∫ΩT∣ΣT,k(ω)−Σˉ∣2 dμT(ω)\int_{\Omega_T}\lvert\Sigma_{T,k}(\omega)-\bar\Sigma\rvert^2\ d\mu_T(\omega)∫ΩT​​∣ΣT,k​(ω)−Σˉ∣2 dμT​(ω) converted to a real number, with the value +∞+\infty+∞ converted to 000. No moment assumption is made, so both conventions can be active. The sum ΣT,k\Sigma_{T,k}ΣT,k​ is not divided by TTT before taking the variance; the variance of the sum is divided by TTT once. For T=0T=0T=0 the value is 000 (by the proof assistant's convention 1/0=01/0=01/0=0).


Env.cesaroDevSq — Arguments: a finite type SSS carrying a given σ-algebra, which is arbitrary (it is not assumed to be discrete, nor that singletons are measurable); an environment EEE on SSS; and natural numbers TTT and kkk. An environment consists of exactly the following data: (i) for every natural number sss (all of N\mathbb NN, not only s<Ts<Ts<T) and every flag z∈{true,false}z\in\lbrace\mathsf{true},\mathsf{false}\rbracez∈{true,false}, a real S×SS\times SS×S matrix PszP^{z}_{s}Psz​ whose entries are all ≥0\ge 0≥0 and each of whose rows sums to 111; (ii) a function ρ:S→R\rho:S\to\mathbb Rρ:S→R with all values ≥0\ge 0≥0 and ∑x∈Sρ(x)=1\sum_{x\in S}\rho(x)=1∑x∈S​ρ(x)=1; (iii) for every x∈Sx\in Sx∈S and every flag zzz, a probability measure Rx,zR_{x,z}Rx,z​ on the Borel sets of R\mathbb RR, with no boundedness or moment assumption.

A trajectory of length TTT is a function ω\omegaω assigning to each index t∈{0,1,…,T−1}t\in\lbrace 0,1,\dots,T-1\rbracet∈{0,1,…,T−1} a triple ωt=(Xt(ω),Zt(ω),Yt(ω))∈S×{true,false}×R\omega_t=(X_t(\omega),Z_t(\omega),Y_t(\omega))\in S\times\lbrace\mathsf{true},\mathsf{false}\rbrace\times\mathbb Rωt​=(Xt​(ω),Zt​(ω),Yt​(ω))∈S×{true,false}×R; the set ΩT\Omega_TΩT​ of all of them carries the product σ-algebra (the given σ-algebra on SSS, all subsets of {true,false}\lbrace\mathsf{true},\mathsf{false}\rbrace{true,false}, the Borel sets of R\mathbb RR). The measure μT\mu_TμT​ on ΩT\Omega_TΩT​ is the finite sum over all pairs (x,z)(x,z)(x,z) of a state path x:{0,…,T−1}→Sx:\lbrace 0,\dots,T-1\rbrace\to Sx:{0,…,T−1}→S and a flag path z:{0,…,T−1}→{true,false}z:\lbrace 0,\dots,T-1\rbrace\to\lbrace\mathsf{true},\mathsf{false}\rbracez:{0,…,T−1}→{true,false}:

μT=∑(x,z)max⁡(wT(x,z),0)⋅⨂t=0T−1(δxt⊗δzt⊗Rxt,zt),wT(x,z)=ρ(x0)⋅∏s=0T−2Pszs(xs,xs+1)⋅(12)T,\mu_T=\sum_{(x,z)}\max\big(w_T(x,z),0\big)\cdot\bigotimes_{t=0}^{T-1}\Big(\delta_{x_t}\otimes\delta_{z_t}\otimes R_{x_t,z_t}\Big),\qquad w_T(x,z)=\rho(x_0)\cdot\prod_{s=0}^{T-2}P^{z_s}_{s}(x_s,x_{s+1})\cdot\Big(\frac12\Big)^{T},μT​=(x,z)∑​max(wT​(x,z),0)⋅t=0⨂T−1​(δxt​​⊗δzt​​⊗Rxt​,zt​​),wT​(x,z)=ρ(x0​)⋅s=0∏T−2​Pszs​​(xs​,xs+1​)⋅(21​)T,

where δ\deltaδ is a Dirac mass and ⨂\bigotimes⨂ is the product measure over the TTT indices. (The code builds wTw_TwT​ as a product over all indices: a factor ρ(xt)\rho(x_t)ρ(xt​) for the index t=0t=0t=0; a factor Pszs(xs,xt)P^{z_s}_{s}(x_s,x_t)Pszs​​(xs​,xt​) for every pair of indices with s+1=ts+1=ts+1=t; and for every ttt a factor equal to qqq if zt=truez_t=\mathsf{true}zt​=true and 1−q1-q1−q if zt=falsez_t=\mathsf{false}zt​=false, with the constant q=12q=\frac12q=21​ fixed by this definition. Negative weights would be replaced by 000; here every factor is ≥0\ge 0≥0 and the weights sum to 111. For T=0T=0T=0 all products are empty, w0=1w_0=1w0​=1, and μ0\mu_0μ0​ is the unit mass on the one-point set Ω0\Omega_0Ω0​.)

Put ι(true)=2\iota(\mathsf{true})=2ι(true)=2, ι(false)=−2\iota(\mathsf{false})=-2ι(false)=−2, and for t∈{0,…,T−1}t\in\lbrace 0,\dots,T-1\rbracet∈{0,…,T−1}

mt=∫ΩTBt(k) dμT,Bt(k)(ω)=∑i=0T−11[i≤t and t≤i+k]⋅ι(Zi(ω))⋅Yt(ω)=Yt(ω)⋅∑i=max⁡(t−k,0)tι(Zi(ω)),m_t=\int_{\Omega_T}B^{(k)}_t\ d\mu_T,\qquad B^{(k)}_t(\omega)=\sum_{i=0}^{T-1}\mathbf 1\big[i\le t\ \text{and}\ t\le i+k\big]\cdot\iota(Z_i(\omega))\cdot Y_t(\omega)=Y_t(\omega)\cdot\sum_{i=\max(t-k,0)}^{t}\iota(Z_i(\omega)),mt​=∫ΩT​​Bt(k)​ dμT​,Bt(k)​(ω)=i=0∑T−1​1[i≤t and t≤i+k]⋅ι(Zi​(ω))⋅Yt​(ω)=Yt​(ω)⋅i=max(t−k,0)∑t​ι(Zi​(ω)),

the integral being a Bochner integral (equal to 000 by convention if Bt(k)B^{(k)}_tBt(k)​ is not μT\mu_TμT​-integrable; no integrability is assumed). The output is the real number

DT,kE=1T∑t=0T−1(mt−1T∑s=0T−1ms)2,D^{E}_{T,k}=\frac1T\sum_{t=0}^{T-1}\Big(m_t-\frac1T\sum_{s=0}^{T-1}m_s\Big)^{2},DT,kE​=T1​t=0∑T−1​(mt​−T1​s=0∑T−1​ms​)2,

the average over the TTT indices of the squared difference between mtm_tmt​ and the average of all the msm_sms​. It is a deterministic number (no trajectory argument). For T=0T=0T=0 the value is 000 (empty sums, and 1/0=01/0=01/0=0 by the proof assistant's convention).


sigmaWindow — Arguments: a type SSS carrying a given σ-algebra, which is arbitrary; and natural numbers TTT, aaa and bbb. (The file's standing declarations also supply a finite-type structure on SSS, which this definition does not use.) Let ΩT\Omega_TΩT​ be the set of trajectories of length TTT: functions ω\omegaω assigning to each index t∈{0,1,…,T−1}t\in\lbrace 0,1,\dots,T-1\rbracet∈{0,1,…,T−1} a triple ωt∈S×{true,false}×R\omega_t\in S\times\lbrace\mathsf{true},\mathsf{false}\rbrace\times\mathbb Rωt​∈S×{true,false}×R. The output is a σ-algebra on ΩT\Omega_TΩT​:

Fa,bT=σ(ω↦ωt : t∈{0,…,T−1}, a≤t and t≤b),\mathcal F^{T}_{a,b}=\sigma\Big(\omega\mapsto\omega_t\ :\ t\in\lbrace 0,\dots,T-1\rbrace,\ a\le t\ \text{and}\ t\le b\Big),Fa,bT​=σ(ω↦ωt​ : t∈{0,…,T−1}, a≤t and t≤b),

the smallest σ-algebra on ΩT\Omega_TΩT​ containing every set {ω:ωt∈A}\lbrace\omega:\omega_t\in A\rbrace{ω:ωt​∈A} where ttt is an index with a≤t≤ba\le t\le ba≤t≤b (both ends included) and AAA is a measurable subset of S×{true,false}×RS\times\lbrace\mathsf{true},\mathsf{false}\rbrace\times\mathbb RS×{true,false}×R for the product σ-algebra (the given σ-algebra on SSS, all subsets of {true,false}\lbrace\mathsf{true},\mathsf{false}\rbrace{true,false}, the Borel sets of R\mathbb RR). In the code it is the supremum, over those ttt, of the pull-back σ-algebras of the whole-triple coordinate maps. Only indices below TTT exist, so the effective range is a≤t≤min⁡(b,T−1)a\le t\le\min(b,T-1)a≤t≤min(b,T−1); bbb may exceed T−1T-1T−1. If no index qualifies (for instance a>ba>ba>b, or a≥Ta\ge Ta≥T, or T=0T=0T=0), the result is the trivial σ-algebra {∅,ΩT}\lbrace\emptyset,\Omega_T\rbrace{∅,ΩT​}. (The declaration also carries a reducibility attribute for the proof assistant's instance mechanism, which has no mathematical content.)


GammaTerm — Arguments: a type SSS; a natural number TTT (implicit, read off from the other arguments); a natural number kkk; an index t∈{0,1,…,T−1}t\in\lbrace 0,1,\dots,T-1\rbracet∈{0,1,…,T−1} (indices are zero-based); and a trajectory ω\omegaω of length TTT, meaning a function that assigns to each index u∈{0,1,…,T−1}u\in\lbrace 0,1,\dots,T-1\rbraceu∈{0,1,…,T−1} a triple ωu=(Xu(ω),Zu(ω),Yu(ω))\omega_u=(X_u(\omega),Z_u(\omega),Y_u(\omega))ωu​=(Xu​(ω),Zu​(ω),Yu​(ω)) with Xu(ω)∈SX_u(\omega)\in SXu​(ω)∈S, Zu(ω)∈{true,false}Z_u(\omega)\in\lbrace\mathsf{true},\mathsf{false}\rbraceZu​(ω)∈{true,false} and Yu(ω)∈RY_u(\omega)\in\mathbb RYu​(ω)∈R. (The file's standing declarations also supply a finite-type structure on SSS; this definition uses neither finiteness of SSS nor any σ-algebra on SSS, and the components Xu(ω)X_u(\omega)Xu​(ω) do not enter.) The output is the real number

Gt(k)(ω)=ι(Zt(ω))⋅∑u=0T−11[t≤u and u≤t+k]⋅Yu(ω)=ι(Zt(ω))⋅∑u=tmin⁡(t+k,T−1)Yu(ω),G^{(k)}_t(\omega)=\iota(Z_t(\omega))\cdot\sum_{u=0}^{T-1}\mathbf 1\big[t\le u\ \text{and}\ u\le t+k\big]\cdot Y_u(\omega)=\iota(Z_t(\omega))\cdot\sum_{u=t}^{\min(t+k,T-1)}Y_u(\omega),Gt(k)​(ω)=ι(Zt​(ω))⋅u=0∑T−1​1[t≤u and u≤t+k]⋅Yu​(ω)=ι(Zt​(ω))⋅u=t∑min(t+k,T−1)​Yu​(ω),

where 1[⋅]\mathbf 1[\cdot]1[⋅] is 111 if the condition holds and 000 otherwise, and ι(true)=2\iota(\mathsf{true})=2ι(true)=2, ι(false)=−2\iota(\mathsf{false})=-2ι(false)=−2 (in the code, ι(z)=2⋅(2⋅1[z]−1)\iota(z)=2\cdot(2\cdot\mathbf 1[z]-1)ι(z)=2⋅(2⋅1[z]−1)). That is: the value ±2\pm 2±2 attached to the flag at index ttt, multiplied by the sum of the real entries at the indices uuu with t≤u≤t+kt\le u\le t+kt≤u≤t+k. The window is cut off at the last index T−1T-1T−1, so it has min⁡(k,T−1−t)+1\min(k,T-1-t)+1min(k,T−1−t)+1 terms. For k=0k=0k=0 the value is ι(Zt(ω))⋅Yt(ω)\iota(Z_t(\omega))\cdot Y_t(\omega)ι(Zt​(ω))⋅Yt​(ω). For T=0T=0T=0 there is no index ttt, so the function has empty domain.


sigmaGamma — Arguments: a type SSS, here given explicitly and with no further structure (no finiteness and no σ-algebra on SSS is assumed or used); and natural numbers TTT, kkk, aaa and bbb. Let ΩT\Omega_TΩT​ be the set of trajectories of length TTT: functions ω\omegaω assigning to each index u∈{0,1,…,T−1}u\in\lbrace 0,1,\dots,T-1\rbraceu∈{0,1,…,T−1} a triple ωu=(Xu(ω),Zu(ω),Yu(ω))∈S×{true,false}×R\omega_u=(X_u(\omega),Z_u(\omega),Y_u(\omega))\in S\times\lbrace\mathsf{true},\mathsf{false}\rbrace\times\mathbb Rωu​=(Xu​(ω),Zu​(ω),Yu​(ω))∈S×{true,false}×R. For each index t∈{0,…,T−1}t\in\lbrace 0,\dots,T-1\rbracet∈{0,…,T−1} let Gt(k):ΩT→RG^{(k)}_t:\Omega_T\to\mathbb RGt(k)​:ΩT​→R be

Gt(k)(ω)=ι(Zt(ω))⋅∑u=0T−11[t≤u and u≤t+k]⋅Yu(ω)=ι(Zt(ω))⋅∑u=tmin⁡(t+k,T−1)Yu(ω),ι(true)=2,ι(false)=−2.G^{(k)}_t(\omega)=\iota(Z_t(\omega))\cdot\sum_{u=0}^{T-1}\mathbf 1\big[t\le u\ \text{and}\ u\le t+k\big]\cdot Y_u(\omega)=\iota(Z_t(\omega))\cdot\sum_{u=t}^{\min(t+k,T-1)}Y_u(\omega),\qquad \iota(\mathsf{true})=2,\quad \iota(\mathsf{false})=-2 .Gt(k)​(ω)=ι(Zt​(ω))⋅u=0∑T−1​1[t≤u and u≤t+k]⋅Yu​(ω)=ι(Zt​(ω))⋅u=t∑min(t+k,T−1)​Yu​(ω),ι(true)=2,ι(false)=−2.

The output is a σ-algebra on ΩT\Omega_TΩT​:

Ga,bT,k=σ(Gt(k) : t∈{0,…,T−1}, a≤t and t≤b),\mathcal G^{T,k}_{a,b}=\sigma\Big(G^{(k)}_t\ :\ t\in\lbrace 0,\dots,T-1\rbrace,\ a\le t\ \text{and}\ t\le b\Big),Ga,bT,k​=σ(Gt(k)​ : t∈{0,…,T−1}, a≤t and t≤b),

the smallest σ-algebra on ΩT\Omega_TΩT​ containing every set {ω:Gt(k)(ω)∈A}\lbrace\omega:G^{(k)}_t(\omega)\in A\rbrace{ω:Gt(k)​(ω)∈A} where ttt is an index with a≤t≤ba\le t\le ba≤t≤b (both ends included) and AAA is a Borel subset of R\mathbb RR. In the code it is the supremum, over those ttt, of the pull-backs of the Borel σ-algebra of R\mathbb RR along the real-valued functions Gt(k)G^{(k)}_tGt(k)​. Only indices below TTT exist, so the effective range is a≤t≤min⁡(b,T−1)a\le t\le\min(b,T-1)a≤t≤min(b,T−1). If no index qualifies (for instance a>ba>ba>b, or a≥Ta\ge Ta≥T, or T=0T=0T=0), the result is the trivial σ-algebra {∅,ΩT}\lbrace\emptyset,\Omega_T\rbrace{∅,ΩT​}. (The declaration also carries a reducibility attribute for the proof assistant's instance mechanism, which has no mathematical content.)


Env.AsymptoticVariance — This is a property (true or false) of: a finite type SSS carrying a given σ-algebra, which is arbitrary (it is not assumed to be discrete, nor that singletons are measurable); an environment EEE on SSS; a natural number kkk; and a real number vvv. An environment consists of exactly the following data: (i) for every natural number sss and every flag z∈{true,false}z\in\lbrace\mathsf{true},\mathsf{false}\rbracez∈{true,false}, a real S×SS\times SS×S matrix PszP^{z}_{s}Psz​ whose entries are all ≥0\ge 0≥0 and each of whose rows sums to 111; (ii) a function ρ:S→R\rho:S\to\mathbb Rρ:S→R with all values ≥0\ge 0≥0 and ∑x∈Sρ(x)=1\sum_{x\in S}\rho(x)=1∑x∈S​ρ(x)=1; (iii) for every x∈Sx\in Sx∈S and every flag zzz, a probability measure Rx,zR_{x,z}Rx,z​ on the Borel sets of R\mathbb RR, with no boundedness or moment assumption.

For each natural number TTT, a trajectory of length TTT is a function ω\omegaω assigning to each index t∈{0,1,…,T−1}t\in\lbrace 0,1,\dots,T-1\rbracet∈{0,1,…,T−1} a triple ωt=(Xt(ω),Zt(ω),Yt(ω))∈S×{true,false}×R\omega_t=(X_t(\omega),Z_t(\omega),Y_t(\omega))\in S\times\lbrace\mathsf{true},\mathsf{false}\rbrace\times\mathbb Rωt​=(Xt​(ω),Zt​(ω),Yt​(ω))∈S×{true,false}×R; the set ΩT\Omega_TΩT​ of all of them carries the product σ-algebra (the given σ-algebra on SSS, all subsets of {true,false}\lbrace\mathsf{true},\mathsf{false}\rbrace{true,false}, the Borel sets of R\mathbb RR). The measure μT\mu_TμT​ on ΩT\Omega_TΩT​ is the finite sum over all pairs (x,z)(x,z)(x,z) of a state path x:{0,…,T−1}→Sx:\lbrace 0,\dots,T-1\rbrace\to Sx:{0,…,T−1}→S and a flag path z:{0,…,T−1}→{true,false}z:\lbrace 0,\dots,T-1\rbrace\to\lbrace\mathsf{true},\mathsf{false}\rbracez:{0,…,T−1}→{true,false}:

μT=∑(x,z)max⁡(wT(x,z),0)⋅⨂t=0T−1(δxt⊗δzt⊗Rxt,zt),wT(x,z)=ρ(x0)⋅∏s=0T−2Pszs(xs,xs+1)⋅(12)T,\mu_T=\sum_{(x,z)}\max\big(w_T(x,z),0\big)\cdot\bigotimes_{t=0}^{T-1}\Big(\delta_{x_t}\otimes\delta_{z_t}\otimes R_{x_t,z_t}\Big),\qquad w_T(x,z)=\rho(x_0)\cdot\prod_{s=0}^{T-2}P^{z_s}_{s}(x_s,x_{s+1})\cdot\Big(\frac12\Big)^{T},μT​=(x,z)∑​max(wT​(x,z),0)⋅t=0⨂T−1​(δxt​​⊗δzt​​⊗Rxt​,zt​​),wT​(x,z)=ρ(x0​)⋅s=0∏T−2​Pszs​​(xs​,xs+1​)⋅(21​)T,

where δ\deltaδ is a Dirac mass and ⨂\bigotimes⨂ is the product measure over the TTT indices. (The code builds wTw_TwT​ as a product over all indices: a factor ρ(xt)\rho(x_t)ρ(xt​) for the index t=0t=0t=0; a factor Pszs(xs,xt)P^{z_s}_{s}(x_s,x_t)Pszs​​(xs​,xt​) for every pair of indices with s+1=ts+1=ts+1=t; and for every ttt a factor equal to qqq if zt=truez_t=\mathsf{true}zt​=true and 1−q1-q1−q if zt=falsez_t=\mathsf{false}zt​=false, with the constant q=12q=\frac12q=21​ fixed by this definition. Negative weights would be replaced by 000; here every factor is ≥0\ge 0≥0 and the weights sum to 111. For T=0T=0T=0, μ0\mu_0μ0​ is the unit mass on the one-point set Ω0\Omega_0Ω0​.)

Put ι(true)=2\iota(\mathsf{true})=2ι(true)=2, ι(false)=−2\iota(\mathsf{false})=-2ι(false)=−2, and for each TTT

VT=1T⋅Var⁡μT(∑t=0T−1Bt(k)),Bt(k)(ω)=∑i=0T−11[i≤t and t≤i+k]⋅ι(Zi(ω))⋅Yt(ω)=Yt(ω)⋅∑i=max⁡(t−k,0)tι(Zi(ω)),V_{T}=\frac1T\cdot\operatorname{Var}_{\mu_T}\Big(\sum_{t=0}^{T-1}B^{(k)}_t\Big),\qquad B^{(k)}_t(\omega)=\sum_{i=0}^{T-1}\mathbf 1\big[i\le t\ \text{and}\ t\le i+k\big]\cdot\iota(Z_i(\omega))\cdot Y_t(\omega)=Y_t(\omega)\cdot\sum_{i=\max(t-k,0)}^{t}\iota(Z_i(\omega)),VT​=T1​⋅VarμT​​(t=0∑T−1​Bt(k)​),Bt(k)​(ω)=i=0∑T−1​1[i≤t and t≤i+k]⋅ι(Zi​(ω))⋅Yt​(ω)=Yt​(ω)⋅i=max(t−k,0)∑t​ι(Zi​(ω)),

where Var⁡μT(Σ)\operatorname{Var}_{\mu_T}(\Sigma)VarμT​​(Σ) is the library's real-valued variance: the [0,∞][0,\infty][0,∞]-valued integral ∫∣Σ−Σˉ∣2 dμT\int\lvert\Sigma-\bar\Sigma\rvert^2\ d\mu_T∫∣Σ−Σˉ∣2 dμT​, with Σˉ=∫Σ dμT\bar\Sigma=\int\Sigma\ d\mu_TΣˉ=∫Σ dμT​ a Bochner integral (equal to 000 by convention if Σ\SigmaΣ is not integrable), converted to a real number with +∞+\infty+∞ converted to 000; and V0=0V_0=0V0​=0 by the convention 1/0=01/0=01/0=0.

The property holds exactly when both of the following hold:

0<vandlim⁡T→∞VT=v,0<v\qquad\text{and}\qquad \lim_{T\to\infty}V_T=v,0<vandT→∞lim​VT​=v,

the limit being taken along the natural numbers TTT with kkk held fixed. Strict positivity of vvv is part of the property itself.


Env.MeanStability — This is a property (true or false) of: a finite type SSS carrying a given σ-algebra, which is arbitrary (it is not assumed to be discrete, nor that singletons are measurable); an environment EEE on SSS; and a natural number kkk. An environment consists of exactly the following data: (i) for every natural number sss and every flag z∈{true,false}z\in\lbrace\mathsf{true},\mathsf{false}\rbracez∈{true,false}, a real S×SS\times SS×S matrix PszP^{z}_{s}Psz​ whose entries are all ≥0\ge 0≥0 and each of whose rows sums to 111; (ii) a function ρ:S→R\rho:S\to\mathbb Rρ:S→R with all values ≥0\ge 0≥0 and ∑x∈Sρ(x)=1\sum_{x\in S}\rho(x)=1∑x∈S​ρ(x)=1; (iii) for every x∈Sx\in Sx∈S and every flag zzz, a probability measure Rx,zR_{x,z}Rx,z​ on the Borel sets of R\mathbb RR, with no boundedness or moment assumption.

For each natural number TTT, a trajectory of length TTT is a function ω\omegaω assigning to each index t∈{0,1,…,T−1}t\in\lbrace 0,1,\dots,T-1\rbracet∈{0,1,…,T−1} a triple ωt=(Xt(ω),Zt(ω),Yt(ω))∈S×{true,false}×R\omega_t=(X_t(\omega),Z_t(\omega),Y_t(\omega))\in S\times\lbrace\mathsf{true},\mathsf{false}\rbrace\times\mathbb Rωt​=(Xt​(ω),Zt​(ω),Yt​(ω))∈S×{true,false}×R; the set ΩT\Omega_TΩT​ of all of them carries the product σ-algebra (the given σ-algebra on SSS, all subsets of {true,false}\lbrace\mathsf{true},\mathsf{false}\rbrace{true,false}, the Borel sets of R\mathbb RR). The measure μT\mu_TμT​ on ΩT\Omega_TΩT​ is the finite sum over all pairs (x,z)(x,z)(x,z) of a state path x:{0,…,T−1}→Sx:\lbrace 0,\dots,T-1\rbrace\to Sx:{0,…,T−1}→S and a flag path z:{0,…,T−1}→{true,false}z:\lbrace 0,\dots,T-1\rbrace\to\lbrace\mathsf{true},\mathsf{false}\rbracez:{0,…,T−1}→{true,false}:

μT=∑(x,z)max⁡(wT(x,z),0)⋅⨂t=0T−1(δxt⊗δzt⊗Rxt,zt),wT(x,z)=ρ(x0)⋅∏s=0T−2Pszs(xs,xs+1)⋅(12)T,\mu_T=\sum_{(x,z)}\max\big(w_T(x,z),0\big)\cdot\bigotimes_{t=0}^{T-1}\Big(\delta_{x_t}\otimes\delta_{z_t}\otimes R_{x_t,z_t}\Big),\qquad w_T(x,z)=\rho(x_0)\cdot\prod_{s=0}^{T-2}P^{z_s}_{s}(x_s,x_{s+1})\cdot\Big(\frac12\Big)^{T},μT​=(x,z)∑​max(wT​(x,z),0)⋅t=0⨂T−1​(δxt​​⊗δzt​​⊗Rxt​,zt​​),wT​(x,z)=ρ(x0​)⋅s=0∏T−2​Pszs​​(xs​,xs+1​)⋅(21​)T,

where δ\deltaδ is a Dirac mass and ⨂\bigotimes⨂ is the product measure over the TTT indices. (The code builds wTw_TwT​ as a product over all indices: a factor ρ(xt)\rho(x_t)ρ(xt​) for the index t=0t=0t=0; a factor Pszs(xs,xt)P^{z_s}_{s}(x_s,x_t)Pszs​​(xs​,xt​) for every pair of indices with s+1=ts+1=ts+1=t; and for every ttt a factor equal to qqq if zt=truez_t=\mathsf{true}zt​=true and 1−q1-q1−q if zt=falsez_t=\mathsf{false}zt​=false, with the constant q=12q=\frac12q=21​ fixed by this definition. Negative weights would be replaced by 000; here every factor is ≥0\ge 0≥0 and the weights sum to 111. For T=0T=0T=0, μ0\mu_0μ0​ is the unit mass on the one-point set Ω0\Omega_0Ω0​.)

Put ι(true)=2\iota(\mathsf{true})=2ι(true)=2, ι(false)=−2\iota(\mathsf{false})=-2ι(false)=−2, and for each TTT and each t∈{0,…,T−1}t\in\lbrace 0,\dots,T-1\rbracet∈{0,…,T−1}

mT,t=∫ΩTBt(k) dμT,Bt(k)(ω)=∑i=0T−11[i≤t and t≤i+k]⋅ι(Zi(ω))⋅Yt(ω)=Yt(ω)⋅∑i=max⁡(t−k,0)tι(Zi(ω)),m_{T,t}=\int_{\Omega_T}B^{(k)}_t\ d\mu_T,\qquad B^{(k)}_t(\omega)=\sum_{i=0}^{T-1}\mathbf 1\big[i\le t\ \text{and}\ t\le i+k\big]\cdot\iota(Z_i(\omega))\cdot Y_t(\omega)=Y_t(\omega)\cdot\sum_{i=\max(t-k,0)}^{t}\iota(Z_i(\omega)),mT,t​=∫ΩT​​Bt(k)​ dμT​,Bt(k)​(ω)=i=0∑T−1​1[i≤t and t≤i+k]⋅ι(Zi​(ω))⋅Yt​(ω)=Yt​(ω)⋅i=max(t−k,0)∑t​ι(Zi​(ω)),

the integral being a Bochner integral (equal to 000 by convention if the integrand is not μT\mu_TμT​-integrable), and

DT=1T∑t=0T−1(mT,t−1T∑s=0T−1mT,s)2(D0=0 by the convention 1/0=0).D_T=\frac1T\sum_{t=0}^{T-1}\Big(m_{T,t}-\frac1T\sum_{s=0}^{T-1}m_{T,s}\Big)^{2}\qquad(D_0=0\ \text{by the convention}\ 1/0=0).DT​=T1​t=0∑T−1​(mT,t​−T1​s=0∑T−1​mT,s​)2(D0​=0 by the convention 1/0=0).

The property holds exactly when DT=o(T−2/3)D_T=o\big(T^{-2/3}\big)DT​=o(T−2/3) as T→∞T\to\inftyT→∞ along the natural numbers, in the following precise sense: for every real c>0c>0c>0 there is a natural number T0T_0T0​ such that for all T≥T0T\ge T_0T≥T0​,

∣DT∣≤c⋅∣T−2/3∣.\lvert D_T\rvert\le c\cdot\big\lvert T^{-2/3}\big\rvert .∣DT​∣≤c⋅​T−2/3​.

Here T−2/3T^{-2/3}T−2/3 is the real power of the real number TTT with real exponent −23-\frac23−32​ (at T=0T=0T=0 the library's value of 0−2/30^{-2/3}0−2/3 is 000, which does not affect a statement about all sufficiently large TTT). The parameter kkk is held fixed.


IsBandwidth — This is a property (true or false) of a single argument, a function L:N→NL:\mathbb N\to\mathbb NL:N→N. It holds exactly when all three of the following hold:

  1. for every natural number TTT with 0<T0<T0<T, one has L(T)<TL(T)<TL(T)<T (strict; nothing is required of L(0)L(0)L(0); for T=1T=1T=1 this forces L(1)=0L(1)=0L(1)=0);
  2. L(T)→∞L(T)\to\inftyL(T)→∞ as T→∞T\to\inftyT→∞, meaning: for every natural number NNN there is a natural number T0T_0T0​ such that L(T)≥NL(T)\ge NL(T)≥N for all T≥T0T\ge T_0T≥T0​;
  3. L(T)=O(T1/3)L(T)=O\big(T^{1/3}\big)L(T)=O(T1/3) as T→∞T\to\inftyT→∞, meaning: there exist a real number CCC and a natural number T0T_0T0​ such that ∣L(T)∣≤C⋅∣T1/3∣\lvert L(T)\rvert\le C\cdot\big\lvert T^{1/3}\big\rvert∣L(T)∣≤C⋅​T1/3​ for all T≥T0T\ge T_0T≥T0​, where L(T)L(T)L(T) and TTT are regarded as real numbers and T1/3T^{1/3}T1/3 is the real power with real exponent 13\frac1331​.

No monotonicity of LLL is required, and the property does not mention any state space, environment or measure.


Env.TendstoNormal — This is a property (true or false) of: a finite type SSS carrying a given σ-algebra, which is arbitrary (it is not assumed to be discrete, nor that singletons are measurable); an environment EEE on SSS; a family W=(WT)T∈NW=(W_T)_{T\in\mathbb N}W=(WT​)T∈N​ in which, for each natural number TTT, WTW_TWT​ is an arbitrary real-valued function on the set ΩT\Omega_TΩT​ of trajectories of length TTT (no measurability is assumed); and a real number vvv of either sign. An environment consists of exactly the following data: (i) for every natural number sss and every flag z∈{true,false}z\in\lbrace\mathsf{true},\mathsf{false}\rbracez∈{true,false}, a real S×SS\times SS×S matrix PszP^{z}_{s}Psz​ whose entries are all ≥0\ge 0≥0 and each of whose rows sums to 111; (ii) a function ρ:S→R\rho:S\to\mathbb Rρ:S→R with all values ≥0\ge 0≥0 and ∑x∈Sρ(x)=1\sum_{x\in S}\rho(x)=1∑x∈S​ρ(x)=1; (iii) for every x∈Sx\in Sx∈S and every flag zzz, a probability measure Rx,zR_{x,z}Rx,z​ on the Borel sets of R\mathbb RR, with no boundedness or moment assumption.

A trajectory of length TTT is a function ω\omegaω assigning to each index t∈{0,1,…,T−1}t\in\lbrace 0,1,\dots,T-1\rbracet∈{0,1,…,T−1} a triple ωt=(Xt(ω),Zt(ω),Yt(ω))∈S×{true,false}×R\omega_t=(X_t(\omega),Z_t(\omega),Y_t(\omega))\in S\times\lbrace\mathsf{true},\mathsf{false}\rbrace\times\mathbb Rωt​=(Xt​(ω),Zt​(ω),Yt​(ω))∈S×{true,false}×R; the set ΩT\Omega_TΩT​ of all of them carries the product σ-algebra (the given σ-algebra on SSS, all subsets of {true,false}\lbrace\mathsf{true},\mathsf{false}\rbrace{true,false}, the Borel sets of R\mathbb RR). The measure μT\mu_TμT​ on ΩT\Omega_TΩT​ is the finite sum over all pairs (x,z)(x,z)(x,z) of a state path x:{0,…,T−1}→Sx:\lbrace 0,\dots,T-1\rbrace\to Sx:{0,…,T−1}→S and a flag path z:{0,…,T−1}→{true,false}z:\lbrace 0,\dots,T-1\rbrace\to\lbrace\mathsf{true},\mathsf{false}\rbracez:{0,…,T−1}→{true,false}:

μT=∑(x,z)max⁡(wT(x,z),0)⋅⨂t=0T−1(δxt⊗δzt⊗Rxt,zt),wT(x,z)=ρ(x0)⋅∏s=0T−2Pszs(xs,xs+1)⋅(12)T,\mu_T=\sum_{(x,z)}\max\big(w_T(x,z),0\big)\cdot\bigotimes_{t=0}^{T-1}\Big(\delta_{x_t}\otimes\delta_{z_t}\otimes R_{x_t,z_t}\Big),\qquad w_T(x,z)=\rho(x_0)\cdot\prod_{s=0}^{T-2}P^{z_s}_{s}(x_s,x_{s+1})\cdot\Big(\frac12\Big)^{T},μT​=(x,z)∑​max(wT​(x,z),0)⋅t=0⨂T−1​(δxt​​⊗δzt​​⊗Rxt​,zt​​),wT​(x,z)=ρ(x0​)⋅s=0∏T−2​Pszs​​(xs​,xs+1​)⋅(21​)T,

where δ\deltaδ is a Dirac mass and ⨂\bigotimes⨂ is the product measure over the TTT indices. (The code builds wTw_TwT​ as a product over all indices: a factor ρ(xt)\rho(x_t)ρ(xt​) for the index t=0t=0t=0; a factor Pszs(xs,xt)P^{z_s}_{s}(x_s,x_t)Pszs​​(xs​,xt​) for every pair of indices with s+1=ts+1=ts+1=t; and for every ttt a factor equal to qqq if zt=truez_t=\mathsf{true}zt​=true and 1−q1-q1−q if zt=falsez_t=\mathsf{false}zt​=false, with the constant q=12q=\frac12q=21​ fixed by this definition. Negative weights would be replaced by 000; here every factor is ≥0\ge 0≥0 and the weights sum to 111. For T=0T=0T=0, μ0\mu_0μ0​ is the unit mass on the one-point set Ω0\Omega_0Ω0​.)

The property holds exactly when, for every bounded continuous function f:R→Rf:\mathbb R\to\mathbb Rf:R→R,

lim⁡T→∞∫ΩTf(WT(ω)) dμT(ω)=∫Rf(x) dγv(x),\lim_{T\to\infty}\int_{\Omega_T}f\big(W_T(\omega)\big)\ d\mu_T(\omega)=\int_{\mathbb R}f(x)\ d\gamma_{v}(x),T→∞lim​∫ΩT​​f(WT​(ω)) dμT​(ω)=∫R​f(x) dγv​(x),

the limit being along the natural numbers TTT. Here γv\gamma_vγv​ is the Gaussian measure on R\mathbb RR with mean 000 and variance max⁡(v,0)\max(v,0)max(v,0): the value vvv is clipped below at 000, and when the clipped variance is 000 (that is, when v≤0v\le 0v≤0) γv\gamma_vγv​ is the Dirac mass at 000, so the right-hand side is f(0)f(0)f(0). The integrals on the left are Bochner integrals, equal to 000 by convention when f∘WTf\circ W_Tf∘WT​ is not μT\mu_TμT​-integrable (which can happen only through failure of measurability, since fff is bounded). The measure is always the one built with the constant 12\frac1221​; the property has no other probability parameter. No positivity of vvv is required here.


Env.TendstoInProb — This is a property (true or false) of: a finite type SSS carrying a given σ-algebra, which is arbitrary (it is not assumed to be discrete, nor that singletons are measurable); an environment EEE on SSS; a family W=(WT)T∈NW=(W_T)_{T\in\mathbb N}W=(WT​)T∈N​ in which, for each natural number TTT, WTW_TWT​ is an arbitrary real-valued function on the set ΩT\Omega_TΩT​ of trajectories of length TTT (no measurability is assumed); and a real number ccc. An environment consists of exactly the following data: (i) for every natural number sss and every flag z∈{true,false}z\in\lbrace\mathsf{true},\mathsf{false}\rbracez∈{true,false}, a real S×SS\times SS×S matrix PszP^{z}_{s}Psz​ whose entries are all ≥0\ge 0≥0 and each of whose rows sums to 111; (ii) a function ρ:S→R\rho:S\to\mathbb Rρ:S→R with all values ≥0\ge 0≥0 and ∑x∈Sρ(x)=1\sum_{x\in S}\rho(x)=1∑x∈S​ρ(x)=1; (iii) for every x∈Sx\in Sx∈S and every flag zzz, a probability measure Rx,zR_{x,z}Rx,z​ on the Borel sets of R\mathbb RR, with no boundedness or moment assumption.

A trajectory of length TTT is a function ω\omegaω assigning to each index t∈{0,1,…,T−1}t\in\lbrace 0,1,\dots,T-1\rbracet∈{0,1,…,T−1} a triple ωt=(Xt(ω),Zt(ω),Yt(ω))∈S×{true,false}×R\omega_t=(X_t(\omega),Z_t(\omega),Y_t(\omega))\in S\times\lbrace\mathsf{true},\mathsf{false}\rbrace\times\mathbb Rωt​=(Xt​(ω),Zt​(ω),Yt​(ω))∈S×{true,false}×R; the set ΩT\Omega_TΩT​ of all of them carries the product σ-algebra (the given σ-algebra on SSS, all subsets of {true,false}\lbrace\mathsf{true},\mathsf{false}\rbrace{true,false}, the Borel sets of R\mathbb RR). The measure μT\mu_TμT​ on ΩT\Omega_TΩT​ is the finite sum over all pairs (x,z)(x,z)(x,z) of a state path x:{0,…,T−1}→Sx:\lbrace 0,\dots,T-1\rbrace\to Sx:{0,…,T−1}→S and a flag path z:{0,…,T−1}→{true,false}z:\lbrace 0,\dots,T-1\rbrace\to\lbrace\mathsf{true},\mathsf{false}\rbracez:{0,…,T−1}→{true,false}:

μT=∑(x,z)max⁡(wT(x,z),0)⋅⨂t=0T−1(δxt⊗δzt⊗Rxt,zt),wT(x,z)=ρ(x0)⋅∏s=0T−2Pszs(xs,xs+1)⋅(12)T,\mu_T=\sum_{(x,z)}\max\big(w_T(x,z),0\big)\cdot\bigotimes_{t=0}^{T-1}\Big(\delta_{x_t}\otimes\delta_{z_t}\otimes R_{x_t,z_t}\Big),\qquad w_T(x,z)=\rho(x_0)\cdot\prod_{s=0}^{T-2}P^{z_s}_{s}(x_s,x_{s+1})\cdot\Big(\frac12\Big)^{T},μT​=(x,z)∑​max(wT​(x,z),0)⋅t=0⨂T−1​(δxt​​⊗δzt​​⊗Rxt​,zt​​),wT​(x,z)=ρ(x0​)⋅s=0∏T−2​Pszs​​(xs​,xs+1​)⋅(21​)T,

where δ\deltaδ is a Dirac mass and ⨂\bigotimes⨂ is the product measure over the TTT indices. (The code builds wTw_TwT​ as a product over all indices: a factor ρ(xt)\rho(x_t)ρ(xt​) for the index t=0t=0t=0; a factor Pszs(xs,xt)P^{z_s}_{s}(x_s,x_t)Pszs​​(xs​,xt​) for every pair of indices with s+1=ts+1=ts+1=t; and for every ttt a factor equal to qqq if zt=truez_t=\mathsf{true}zt​=true and 1−q1-q1−q if zt=falsez_t=\mathsf{false}zt​=false, with the constant q=12q=\frac12q=21​ fixed by this definition. Negative weights would be replaced by 000; here every factor is ≥0\ge 0≥0 and the weights sum to 111. For T=0T=0T=0, μ0\mu_0μ0​ is the unit mass on the one-point set Ω0\Omega_0Ω0​.)

The property holds exactly when, for every real number ε\varepsilonε with 0<ε0<\varepsilon0<ε,

lim⁡T→∞μT({ω∈ΩT: ε≤∣WT(ω)−c∣})=0,\lim_{T\to\infty}\mu_T\Big(\big\lbrace\omega\in\Omega_T:\ \varepsilon\le\lvert W_T(\omega)-c\rvert\big\rbrace\Big)=0,T→∞lim​μT​({ω∈ΩT​: ε≤∣WT​(ω)−c∣})=0,

the limit being along the natural numbers TTT, of a sequence of elements of [0,∞][0,\infty][0,∞]. The inequality inside the set is non-strict (ε≤∣WT−c∣\varepsilon\le\lvert W_T-c\rvertε≤∣WT​−c∣). The set is not required to be measurable; the proof assistant's measure assigns a value to every set (for a non-measurable set, the infimum of the measures of the measurable sets containing it). The limit ccc is a constant real number, and the measure is always the one built with the constant 12\frac1221​; the property has no other probability parameter.

Human review
  • Endorsed by tianyipeng · Oct 12, 2026

  • Endorsed by Wenqian Xing · Oct 12, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me