Lean 4 · Mathlib · formalisation

The Ring of
Uniform Tightness

Asymptotic statistics has an algebraic structure nobody was using. OP(1) is a commutative ring, oP(1) is an ideal inside it, and every “= … + oP(1)” in a statistics paper is an equality in the quotient ring. This library makes that literal, and machine-checks an M-estimator theorem with it.

0 sorry 87 declarations Mathlib master · Lean 4.34.0-rc1 axioms: propext, Classical.choice, Quot.sound
What the formalisation found

A gap in a standard textbook proof

van de Geer's Lemma 10.2.1 absorbs the remainder term into oP(1) at a point where √n(θ̂−θ₀) ∈ OP(1) is not yet available — it is precisely what the argument is deriving. The published proof reads:

0 = oP(n−1/2) + V(θ̂−θ₀) + o(|θ̂−θ₀|) + Pnψθ₀

and reads the conclusion off. Our own paper draft has the same step, phrased as “but θn − θ₀ ∈ I, so multiplying both sides by its norm”. Lean refused it.

The library does not patch the hole by assuming √n-consistency. It derives the rate: rewrite condition b as an exact factorisation √n Pψθ̂ = √n(θ̂−θ₀)·(V + u) with u ∈ oP(1), then observe that on the event |u| ≤ |V|/2 the factor is bounded away from zero. Conditions b and c alone suffice, as originally claimed.

The thesis

Three lines of Lean that carry the whole idea

The eight ring axioms are free — ℕ → Ω → ℝ is already a commutative ring in Mathlib. What has to be proved is closure, and closure is exactly the familiar calculus of stochastic order symbols.

A = OP(1)subring

Uniformly tight sequences of random variables, a subring of the ring of all sequences. Membership is closed under +, ×, .

def OP1 (Ω) [MeasureSpace Ω] : Subring (ℕ → Ω → ℝ) where carrier := {X | IsBigOP X} add_mem' := IsBigOP.add -- O_P(1) + O_P(1) = O_P(1) mul_mem' := IsBigOP.mul -- O_P(1) · O_P(1) = O_P(1)
I = oP(1)ideal

Sequences converging to zero in probability. Additive closure is Slutsky; absorption A · I ⊆ I is what makes it an ideal rather than a mere subgroup.

def oP1 (Ω) [MeasureSpace Ω] : Ideal (OP1 Ω) where carrier := {X | IsLittleOP (X : ℕ → Ω → ℝ)} add_mem' := fun hx hy => IsLittleOP.add hx hy smul_mem' := fun c _ hx => IsLittleOP.bigOP_mul c.2 hx
A ⧸ Iquotient ring — the payoff

Because Mathlib knows oP1 is an Ideal, the quotient is a CommRing for free, and asymptotic equality becomes ordinary equality.

theorem asympEq_iff_quotient_eq (X Y : OP1 Ω) : (X : ℕ → Ω → ℝ) ≃ₚ (Y : ℕ → Ω → ℝ) ↔ Ideal.Quotient.mk (oP1 Ω) X = Ideal.Quotient.mk (oP1 Ω) Y
OP(1) = tightnessgrounded in Mathlib

This is not a private definition. A sequence converging in distribution has laws which, together with the limit, form a compact set in the space of probability measures — so isTightMeasureSet_of_isCompact_closure applies and Prokhorov's theorem hands back tightness. IsBigOP is therefore literally Mathlib's IsTightMeasureSet, read along a sequence.

The one difference is the ∃ N. Tightness of a family asks for a single compact set carrying every measure at once; asymptotic tightness of a sequence only asks for it eventually. That quantifier is exactly what makes OP(1) closed under the ring operations, and it is the whole reason a ring exists here rather than merely a tight family.

theorem IsBigOP.of_tendstoInDistribution (h : TendstoInDistribution X atTop Z (fun _ => ℙ) μ') : IsBigOP X
Why no measurability hypotheses? Mathlib measures are outer measures defined on every set, so measure_mono and measure_union_le hold unconditionally. Every closure proof routes through one union-bound lemma, meas_lt_norm_le_add, which turns a pointwise bound into a probabilistic one.
Closure

The calculus rules, as ring laws

Each rule textbooks state as a separate fact is one closure obligation of the algebraic structure. Nothing else needs proving — associativity, distributivity and the rest are inherited.

ring
OP(1) + OP(1) = OP(1)

Split ε in half, bound each term past its own index, union bound.

IsBigOP.add
ring
OP(1) · OP(1) = OP(1)

Same shape with thresholds M₁M₂ instead of M₁+M₂.

IsBigOP.mul
ideal
oP(1) + oP(1) = oP(1)

Slutsky. Gives the additive subgroup.

IsLittleOP.add
absorption
OP(1) · oP(1) = oP(1)

The load-bearing one. Threshold δ/M on the small factor; this single law is what kills every remainder term downstream.

IsLittleOP.bigOP_mul
ideal
oP(1) ⊆ OP(1)

Take threshold 1. Puts the ideal inside the ring.

IsLittleOP.isBigOP
rates
oP(Rn) ⊆ oP(1)

One line once the ideal exists: an ideal absorbs multiplication.

littleOPIdeal_le
Application

Asymptotic linearity, step by step

van de Geer's Lemma 10.2.1 in the scalar case. Select a step to see what it establishes and which algebraic law does the work. Two steps use absorption; that is the entire content of the “remainder is negligible” hand-wave.

What the formalisation caught. Both van de Geer's published proof and our own paper draft absorb the remainder before √n(θ̂−θ₀) ∈ OP(1) is available — it is what the argument is deriving. Lean refused the step. Rather than assume √n-consistency, the library derives it at step 6 from an approximate factorisation, so conditions b and c alone suffice, as claimed.
Interface

Finite-sample bounds compose as ideal arithmetic

Concentration theory delivers bounds of the shape “with probability at least 1−δ, ‖Xn‖ ≤ C(δ)·Rn”. Written as HasRate X R — that is, membership in the ideal generated by R — combining them stops being fresh ε–δ work.

composition
OP(R) + OP(S) ⊆ OP(R+S)

Two bounds add. One proof, reused forever.

HasRate.add
composition
OP(R) · OP(S) ⊆ OP(R·S)

Two bounds multiply — the step behind the product-rate condition.

HasRate.mul
collapse
Rn → 0 ⟹ OP(R) ⊆ oP(1)

Consistency falls out of any vanishing rate, with no argument repeated.

HasRate.isLittleOP
Worked composition 1 — the ERM oracle inequality
One uniform deviation bound, used on both sides of the empirical optimality inequality. The excess risk of an empirical risk minimiser inherits the deviation rate, and consistency is then a single call rather than a new proof.
theorem excessRisk_hasRate (hdev : ∀ n ω h, |Lhat n ω h - L h| ≤ D n ω) -- a Rademacher/chaining bound (hopt : ∀ n ω, Lhat n ω (hhat n ω) ≤ Lhat n ω h₀) (hmin : ∀ h, L h₀ ≤ L h) (hD : HasRate D R) : HasRate (fun n ω => L (hhat n ω) - L h₀) (fun n => 2 * R n)
Worked composition 2 — the product-rate condition
Two different nuisance bounds, at rates from any finite-sample theory, combining multiplicatively. This is the double machine learning requirement: the product of the rates must be o(n−1/2), which neither rate need satisfy alone. Everything after the two input bounds is ideal arithmetic.
theorem isLittleOP_sqrt_mul_of_product_rate (h₁ : HasRate E₁ R₁) (h₂ : HasRate E₂ R₂) (hbias : ∀ n ω, ‖B n ω‖ ≤ ‖E₁ n ω‖ * ‖E₂ n ω‖) (hprod : Tendsto (fun n => √n * (R₁ n * R₂ n)) atTop (𝓝 0)) : IsLittleOP (fun n ω => √n * B n ω)
holds for nₙ^(−α), n^(−β) whenever α + β > 1/2 — sqrt_mul_polynomial_rate_tendsto_zero
Reference

Every result in the library

Filter by algebraic role, or search names and statements.

DeclarationStatementRole
Interoperation

Plugging in without forking anything

Every 2026 Lean statistics development works on a triangular array: the sample of size n lives in Fin n → Ω under a product measure that changes with n. A ring fixed to a single Ω cannot plug into that. So the ring was rebuilt over an arbitrary family μ : ∀ n, Measure (α n) — same closure proofs, same subring, same ideal — and the original library is recovered as the constant array.

Same ring, any arrayInterop.lean

The fixed-space library is definitionally the special case, so nothing is duplicated and nothing downstream breaks.

def OP1A (μ : ∀ n, Measure (α n)) : Subring (∀ n, α n → ℝ) def oP1A (μ : ∀ n, Measure (α n)) : Ideal (OP1A μ) theorem isBigOPA_const_space_iff : IsBigOPA (fun _ => ℙ) X ↔ IsBigOP X
Their predicate, our idealto Wei–Zheng–Fang–Lu

Their AsymptoticallyLinearAt unfolds to convergence in probability of the linearisation residual over Measure.pi. That is exactly membership in our ideal — so anything the calculus proves negligible discharges the field they currently assume and document as “not proved here”.

theorem tendstoInProbArray_iff_isLittleOPA : TendstoInProbArray μ X ↔ IsLittleOPA μ X theorem asymptoticallyLinearAt_of_isLittleOPA (h : IsLittleOPA μ (fun n x => √n * (T n x - c) - lin n x)) : TendstoInProbArray μ (fun n x => √n * (T n x - c) - lin n x)
Their bound, our ratefrom lean-rademacher

A concentration theorem concludes “with probability at least 1−δ, the deviation is at most b(δ,n)”. Whenever that profile factors as C(δ)·Rₙ — which the √(log(1/δ)/n), √(d/n) and entropy-integral shapes all do — it is a rate, and the rest is ideal arithmetic.

theorem HasRateA.of_tailBound (hb : HasTailBoundA μ X b) (hfac : ∀ δ, 0 < δ → δ < 1 → ∃ C > 0, ∀ n, b δ n ≤ C * R n) : HasRateA μ X R
End to end

A finite-sample bound becomes an asymptotic hypothesis

The composite runs from the shape group 1 proves to the shape group 3 consumes, with our ideal arithmetic in between. Neither development is edited.

theorem asymptoticallyLinearAt_of_tailBound (htail : HasTailBoundA μ (fun n x => √n * (T n x - c) - lin n x) b) (hfac : ∀ δ, 0 < δ → δ < 1 → ∃ C > 0, ∀ n, b δ n ≤ C * R n) (hR : Tendsto R atTop (𝓝 0)) : TendstoInProbArray μ (fun n x => √n * (T n x - c) - lin n x)

And the M-estimator argument itself now runs on arrays too, so the chain is complete: the same conditions a, b, c deliver the linearisation residual in the influence-function format the efficiency developments expect, with φ = −V⁻¹ψθ₀.

theorem tendstoInProbArray_m_estimator … : TendstoInProbArray μ (fun n x => √n * (θ n x - θ₀) - (√n)⁻¹ * ∑ i : Fin n, (-(V⁻¹) * ψ θ₀ (obs n x i)))

Taking α n = Fin n → Ω and μ n = Measure.pi (fun _ => P) is literally their setting. What remains is to prove condition c from a chaining bound rather than assume it — the one genuine mathematical gap left in the chain.

What actually blocks a real require today. Nothing mathematical — only version skew. lean-rademacher pins Lean v4.27.0-rc1, Lean-Asymptotic-Statistical-Theory pins v4.29.1, this library is on v4.34.0-rc1. The bridges above are written so that once the toolchains agree, discharging them is an exact.
Where this sits

Three Lean groups, one missing layer

Formalised statistical learning theory arrived in force in 2026. Two groups built the finite-sample machinery; one built the asymptotic superstructure. None built the algebra in between, and none can currently state the conclusion that motivates the whole subject.

DevelopmentWhat it givesOP/oP calculusRing / ideal
Sonoda et al.ITP 2026 · lean-rademacher · MIT Rademacher complexity, symmetrization, McDiarmid, Dudley entropy integral, chaining, ℓ₁/ℓ₂ predictor bounds nonenone
Zhang, Lee, LiuarXiv 2602.02285 Gaussian Lipschitz concentration, Dudley for sub-Gaussian processes, sparse least-squares at a sharp rate nonenone
Wei, Zheng, Fang, LuarXiv 2606.20642 · 154 files LAN, Hájek–Le Cam convolution, Donsker via bracketing, semiparametric efficiency, Z-estimators, one-step estimators ad-hoc Slutsky lemmas; oP appears only in docstrings none
This libraryOpRing · MEstimator · Rates Asymptotic linearity derived from conditions a, b, c; rate composition; adapters into all three the calculus, proved once Subring, Ideal, quotient
The missing sentence

None of the finite-sample work can state √n(θ̂−θ₀) ⇝ N(0, Σ)

Not “has not yet proved” — cannot express. High-probability bounds at fixed n have no vocabulary for a limit in distribution of a rescaled estimation error. That sentence is what applied statisticians and ML theorists actually quote, and getting to it from a concentration bound is exactly the oP/OP bookkeeping this library performs.

Two kinds of hidden hypothesis. Sonoda et al. describe their real mathematical contribution as isolating the measurability side-conditions that are “routinely implicit in empirical-process arguments but not presented as a single textbook lemma”. This library does the same for asymptotic remainders. The two omissions have different histories: classically, and especially when proving central limit theorems, working statisticians pressed on consistency, rates and remainder terms and treated measurability as a technicality to be waved through — and that is precisely the style of proof found throughout the machine learning literature. Formalisation refuses both kinds of hand-wave, which is why the two efforts uncover complementary gaps.
The join. Condition c, asymptotic equicontinuity, is still a hypothesis here. It is exactly what chaining and entropy bounds deliver. Discharging it from the Dudley machinery would give the first machine-checked asymptotic normality theorem for a nontrivial M-estimator. Note also that Wei et al. assume asymptotic linearity — their asympLinear_25_54 field is explicitly “not proved here” — and then derive efficiency from it. That is precisely what this library produces.
Status

Proved, assumed, and next

Machine-checked

  • Ring and ideal structure, quotient bridge
  • All four calculus rules
  • Ideal is proper and not prime
  • Weak LLN via Mathlib's strong_law_ae_real
  • M-estimator asymptotic linearity, scalar case
  • √n-consistency derived, not assumed
  • OP(1) ⟺ tightness of the laws (Prokhorov)
  • Convergence in distribution ⟹ OP(1)
  • The CLT hypothesis discharged from Mathlib's CLT
  • The ring and ideal on arbitrary triangular arrays
  • The M-estimator theorem on arrays, in influence-function format
  • Rate composition: sums, products, and collapse to o_P(1)
  • ERM oracle inequality and the product-rate condition
  • Hypotheses shown satisfiable via the sample mean

Still hypotheses

  • Asymptotic equicontinuity (condition c) — supplied as hc; the only hypothesis in the chain that is not yet a theorem somewhere
  • Scalar parameter only; ℝp is additive, and the scalar case stays
  • Mutual independence required by the CLT route, versus pairwise for the LLN

Next

  • Discharge condition c from lean-rademacher's chaining bounds — the last real gap
  • Vectorise to ℝp as an A-module, keeping the scalar case
  • Rename and refile to Mathlib conventions, then upstream the tightness API
  • Asymptotic relative efficiency as a statement about the quotient ring