Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Theorem 1: full and split conformal prediction under exchangeability

Proved
ConformalBeyondExchangeability.full_conformal_coverage_exchangeable

by Xeroth · Nov 24, 2026 · Mathlib 0df444a (Lean v4.33.1)

conformal-predictioncoverage-guaranteesdistribution-free-inferencejackknife-plustotal-variation

Let (X1,Y1),…,(Xn+1,Yn+1)(X_1,Y_1),\dots,(X_{n+1},Y_{n+1})(X1​,Y1​),…,(Xn+1​,Yn+1​) be exchangeable, i.e. their joint law PPP is invariant under every permutation of the n+1n+1n+1 indices. Let α∈(0,1)\alpha\in(0,1)α∈(0,1).

  1. Full conformal. Let A\mathcal AA be an algorithm that treats the data points symmetrically (eq. (6)), and suppose the residual vector z↦(∣yi−μ^(xi)∣)i≤n+1z\mapsto(|y_i-\hat\mu(x_i)|)_{i\le n+1}z↦(∣yi​−μ^​(xi​)∣)i≤n+1​, μ^=A(z1,…,zn+1)\hat\mu=\mathcal A(z_1,\dots,z_{n+1})μ^​=A(z1​,…,zn+1​), is measurable. Then the full conformal set of eq. (8),
C^n(Xn+1)={y:Rn+1y≤Q1−α(∑i=1n+11n+1δRiy)},\hat C_n(X_{n+1})=\Big\{y:R^y_{n+1}\le\mathsf Q_{1-\alpha}\Big(\sum_{i=1}^{n+1}\tfrac1{n+1}\delta_{R^y_i}\Big)\Big\},C^n​(Xn+1​)={y:Rn+1y​≤Q1−α​(i=1∑n+1​n+11​δRiy​​)},

satisfies P{Yn+1∈C^n(Xn+1)}≥1−αP\{Y_{n+1}\in\hat C_n(X_{n+1})\}\ge1-\alphaP{Yn+1​∈C^n​(Xn+1​)}≥1−α. 2. Split conformal. For every measurable pre-fitted μ^:X→R\hat\mu:\mathcal X\to\mathbb Rμ^​:X→R, the split conformal interval of eq. (5), μ^(Xn+1)±Q1−α(∑i=1n1n+1δRi+1n+1δ+∞)\hat\mu(X_{n+1})\pm\mathsf Q_{1-\alpha}(\sum_{i=1}^n\frac1{n+1}\delta_{R_i}+\frac1{n+1}\delta_{+\infty})μ^​(Xn+1​)±Q1−α​(∑i=1n​n+11​δRi​​+n+11​δ+∞​) with Ri=∣Yi−μ^(Xi)∣R_i=|Y_i-\hat\mu(X_i)|Ri​=∣Yi​−μ^​(Xi​)∣, covers Yn+1Y_{n+1}Yn+1​ with probability at least 1−α1-\alpha1−α.

This is the classical guarantee of Vovk et al. that Theorem 2 generalizes.

Formalization Note The sets of eqs. (5) and (8) are the weighted sets of eqs. (11) and (12) with w1=⋯=wn=1w_1=\dots=w_n=1w1​=⋯=wn​=1, since then w~i=1/(n+1)\tilde w_i=1/(n+1)w~i​=1/(n+1). The algorithm is deterministic; the paper's footnote 2 also allows randomized symmetric algorithms, which are not covered. Measurability of the residual map is the standing convention that makes the probabilities defined.

Preamble
import Mathlib
import Definitions.Def_ConformalBeyondExchangeability_Basic

open MeasureTheory
Formal statement
namespace ConformalBeyondExchangeability

theorem full_conformal_coverage_exchangeable {X : Type*} [MeasurableSpace X] {n : ℕ}
    (P : Measure (Fin (n + 1) → X × ℝ)) [IsProbabilityMeasure P] (hP : IsExchangeable P)
    {α : ℝ} (hα0 : 0 < α) (hα1 : α < 1) :
    (∀ alg : Alg X, IsSymmetric alg → Measurable (symResiduals (n := n) alg) →
      1 - α ≤ P.real {z | (z (Fin.last n)).2 ∈ symFullSet alg (fun _ => 1) α z}) ∧
    (∀ μ : X → ℝ, Measurable μ → 1 - α ≤ splitCoverage P μ (fun _ => 1) α) := by sorry

end ConformalBeyondExchangeability
Source
Barber, Candès, Ramdas and Tibshirani, Conformal prediction beyond exchangeability, arXiv:2202.13415v5 (2023), Section 2, Theorem 1, eqs. (5)-(8), p. 7; proof in Section 6.1, p. 29
Read-back

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

The statement is a conjunction of two coverage guarantees. They concern a random sequence of n+1n+1n+1 data points under an exchangeable law.

Setting and hypotheses.

  • X\mathcal XX is an arbitrary measurable space.
  • n≥0n \ge 0n≥0 is a natural number. The case n=0n = 0n=0, a single data point, is allowed.
  • PPP is a probability measure on (X×R)n+1(\mathcal X \times \mathbb R)^{n+1}(X×R)n+1, using the product σ\sigmaσ-algebra with the Borel σ\sigmaσ-algebra on R\mathbb RR.
  • A generic point of this space is z=(Z1,…,Zn+1)z = (Z_1,\dots,Z_{n+1})z=(Z1​,…,Zn+1​) with Zi=(Xi,Yi)Z_i = (X_i, Y_i)Zi​=(Xi​,Yi​). The last coordinate Zn+1=(Xn+1,Yn+1)Z_{n+1} = (X_{n+1}, Y_{n+1})Zn+1​=(Xn+1​,Yn+1​) plays the role of the test point.
  • PPP is assumed exchangeable: for every permutation σ\sigmaσ of {1,…,n+1}\{1,\dots,n+1\}{1,…,n+1}, the image of PPP under (z1,…,zn+1)↦(zσ(1),…,zσ(n+1))(z_1,\dots,z_{n+1}) \mapsto (z_{\sigma(1)},\dots,z_{\sigma(n+1)})(z1​,…,zn+1​)↦(zσ(1)​,…,zσ(n+1)​) equals PPP.
  • α\alphaα is a real number with 0<α<10 < \alpha < 10<α<1.

Throughout, probabilities are the real-valued measure P(⋅)P(\cdot)P(⋅) of the indicated set of zzz. Measurability of these sets is not assumed separately. If such a set were not measurable, its outer measure would be used.

Weights and quantile. Both parts use the weights obtained from w1=⋯=wn=1w_1 = \dots = w_n = 1w1​=⋯=wn​=1:

w~i=1n+1(i=1,…,n),w~n+1=1n+1.\tilde w_i = \frac{1}{n+1} \quad (i = 1,\dots,n), \qquad \tilde w_{n+1} = \frac{1}{n+1}.w~i​=n+11​(i=1,…,n),w~n+1​=n+11​.

For masses pip_ipi​ at points vi∈[−∞,+∞]v_i \in [-\infty, +\infty]vi​∈[−∞,+∞], the quantile is the smallest τ\tauτ-quantile, an infimum over the extended reals with inf⁡∅=+∞\inf \emptyset = +\inftyinf∅=+∞:

Qτ(∑ipiδvi)=inf⁡{q∈[−∞,+∞]:τ≤∑i:vi≤qpi}.Q_\tau\Big(\sum_i p_i \delta_{v_i}\Big) = \inf\Big\{ q \in [-\infty,+\infty] : \tau \le \sum_{i : v_i \le q} p_i \Big\}.Qτ​(i∑​pi​δvi​​)=inf{q∈[−∞,+∞]:τ≤i:vi​≤q∑​pi​}.

Here it is always applied with τ=1−α\tau = 1 - \alphaτ=1−α.

Part 1 (full conformal, symmetric algorithm). Let A\mathcal AA be any map that sends every finite list of points of X×R\mathcal X \times \mathbb RX×R, of any length, to a function X→R\mathcal X \to \mathbb RX→R. Assume two things about A\mathcal AA:

  • Symmetric: whenever two lists are permutations of each other, A\mathcal AA returns the same function.
  • Measurable residuals: the map z↦R(z)∈Rn+1z \mapsto R(z) \in \mathbb R^{n+1}z↦R(z)∈Rn+1 is measurable, where
R(z)i=∣yi−μ^z(xi)∣,μ^z=A((x1,y1),…,(xn+1,yn+1)).R(z)_i = \big|y_i - \hat\mu_z(x_i)\big|, \qquad \hat\mu_z = \mathcal A\big((x_1,y_1),\dots,(x_{n+1},y_{n+1})\big).R(z)i​=​yi​−μ^​z​(xi​)​,μ^​z​=A((x1​,y1​),…,(xn+1​,yn+1​)).

Then:

1−α≤P{z:Yn+1∈C^(z)}.1 - \alpha \le P\big\{ z : Y_{n+1} \in \hat C(z) \big\}.1−α≤P{z:Yn+1​∈C^(z)}.

The set C^(z)⊆R\hat C(z) \subseteq \mathbb RC^(z)⊆R consists of those yyy such that

Rn+1y≤Q1−α(∑i=1n+11n+1 δRiy).R^y_{n+1} \le Q_{1-\alpha}\Big( \sum_{i=1}^{n+1} \tfrac{1}{n+1}\, \delta_{R^y_i} \Big).Rn+1y​≤Q1−α​(i=1∑n+1​n+11​δRiy​​).

Here Ry=R(zy)R^y = R(z^y)Ry=R(zy), and zyz^yzy is zzz with Yn+1Y_{n+1}Yn+1​ replaced by yyy:

zy=((X1,Y1),…,(Xn,Yn),(Xn+1,y)).z^y = \big((X_1,Y_1),\dots,(X_n,Y_n),(X_{n+1},y)\big).zy=((X1​,Y1​),…,(Xn​,Yn​),(Xn+1​,y)).

So μ^\hat\muμ^​ is refit on the list containing (Xn+1,y)(X_{n+1}, y)(Xn+1​,y) for each candidate yyy. When y=Yn+1y = Y_{n+1}y=Yn+1​, zy=zz^y = zzy=z, so the event is R(z)n+1≤Q1−α(∑i=1n+11n+1δR(z)i)R(z)_{n+1} \le Q_{1-\alpha}\big(\sum_{i=1}^{n+1} \tfrac1{n+1}\delta_{R(z)_i}\big)R(z)n+1​≤Q1−α​(∑i=1n+1​n+11​δR(z)i​​).

Part 2 (split conformal, fixed model). Let μ^:X→R\hat\mu : \mathcal X \to \mathbb Rμ^​:X→R be any measurable function. It is fixed and does not depend on the data. Then:

1−α≤P{z:Yn+1∈C^split(z)}.1 - \alpha \le P\big\{ z : Y_{n+1} \in \hat C_{\mathrm{split}}(z) \big\}.1−α≤P{z:Yn+1​∈C^split​(z)}.

The set C^split(z)\hat C_{\mathrm{split}}(z)C^split​(z) consists of those y∈Ry \in \mathbb Ry∈R with

∣y−μ^(Xn+1)∣≤Q1−α(∑i=1n1n+1 δRi+1n+1 δ+∞),Ri=∣Yi−μ^(Xi)∣.|y - \hat\mu(X_{n+1})| \le Q_{1-\alpha}\Big( \sum_{i=1}^{n} \tfrac{1}{n+1}\, \delta_{R_i} + \tfrac{1}{n+1}\, \delta_{+\infty} \Big), \qquad R_i = |Y_i - \hat\mu(X_i)|.∣y−μ^​(Xn+1​)∣≤Q1−α​(i=1∑n​n+11​δRi​​+n+11​δ+∞​),Ri​=∣Yi​−μ^​(Xi​)∣.

Edge cases.

  • n=0n = 0n=0, Part 1: the quantile equals R1R_1R1​, so the event always holds.
  • n=0n = 0n=0, Part 2: all mass sits at +∞+\infty+∞, so the quantile is +∞+\infty+∞ and the set is all of R\mathbb RR.

In both parts the probability is then 111.

Human review
  • Endorsed by Shuze Chen · Nov 24, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Xeroth · Nov 24, 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