Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Theorem 1 (proof), eqs. (12)-(14): coverage conditionally on the proper training set

Proved
ConformalizedQuantileRegression.cqr_conditional_coverage

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

conformal-predictiondistribution-freeexchangeabilityprediction-intervalsquantile-regression

Let (Xi,Yi)∈Rp×R(X_i,Y_i)\in\mathbb{R}^p\times\mathbb{R}(Xi​,Yi​)∈Rp×R, i=1,…,n+1i=1,\dots,n+1i=1,…,n+1, be exchangeable. Partition {1,…,n}\{1,\dots,n\}{1,…,n} into disjoint sets I1,I2\mathcal I_1,\mathcal I_2I1​,I2​ with I1∪I2={1,…,n}\mathcal I_1\cup\mathcal I_2=\{1,\dots,n\}I1​∪I2​={1,…,n} and I2≠∅\mathcal I_2\neq\emptysetI2​=∅, fit q^lo,q^hi\hat q_{\mathrm{lo}},\hat q_{\mathrm{hi}}q^​lo​,q^​hi​ with a measurable quantile regression algorithm A\mathcal AA on {(Xi,Yi):i∈I1}\{(X_i,Y_i):i\in\mathcal I_1\}{(Xi​,Yi​):i∈I1​}, let α∈(0,1)\alpha\in(0,1)α∈(0,1) and let CCC be the CQR interval (10)-(11). Then, almost surely,

P{Yn+1∈C(Xn+1)∣(Xi,Yi):i∈I1}≥1−α.\mathbb{P}\{Y_{n+1}\in C(X_{n+1})\mid(X_i,Y_i):i\in\mathcal I_1\}\ge1-\alpha.P{Yn+1​∈C(Xn+1​)∣(Xi​,Yi​):i∈I1​}≥1−α.

If moreover the conformity scores EiE_iEi​, i∈I2∪{n+1}i\in\mathcal I_2\cup\{n+1\}i∈I2​∪{n+1}, are almost surely distinct, then, almost surely,

P{Yn+1∈C(Xn+1)∣(Xi,Yi):i∈I1}≤1−α+1∣I2∣+1.\mathbb{P}\{Y_{n+1}\in C(X_{n+1})\mid(X_i,Y_i):i\in\mathcal I_1\}\le1-\alpha+\frac{1}{|\mathcal I_2|+1}.P{Yn+1​∈C(Xn+1​)∣(Xi​,Yi​):i∈I1​}≤1−α+∣I2​∣+11​.

This is the conditional form of Theorem 1 that the paper proves; Theorem 1 follows by taking expectations.

Formalization Note The conditional probability is the conditional expectation of the indicator of the coverage event given the σ-algebra generated by the proper training samples. The split is fixed (deterministic); a random split drawn independently of the data is covered by conditioning on it. The paper's "the conformity scores EiE_iEi​ are almost surely distinct" is read as the scores of the calibration points and the test point, the variables to which Lemma 2 is applied.

Preamble
import Mathlib
import Definitions.Def_ConformalizedQuantileRegression_Basic

open MeasureTheory ProbabilityTheory
Formal statement
namespace ConformalizedQuantileRegression

theorem cqr_conditional_coverage {Ω : Type*} [MeasurableSpace Ω] (P : Measure Ω)
    [IsProbabilityMeasure P] {p n : ℕ} (Z : Fin (n + 1) → Ω → Sample p) (hZ : IsExchangeable P Z)
    (I₁ I₂ : Finset (Fin n)) (hdisj : Disjoint I₁ I₂) (hsplit : I₁ ∪ I₂ = Finset.univ)
    (hI₂ : I₂.Nonempty) (A : QRAlgorithm p I₁) (hA : IsMeasurableAlgorithm A)
    (α : ℝ) (hα0 : 0 < α) (hα1 : α < 1) :
    (∀ᵐ ω ∂P, 1 - α ≤
      (P[Set.indicator {ω' | (Z (Fin.last n) ω').2 ∈
          cqrInterval A I₂ α (fun i => Z i.castSucc ω') (Z (Fin.last n) ω').1} (fun _ => (1 : ℝ)) |
        MeasurableSpace.comap (fun ω' (i : ↥I₁) => Z (Fin.castSucc i.1) ω') inferInstance]) ω) ∧
    ((∀ᵐ ω ∂P, Set.InjOn
        (fun j => conformityScore (fitQR A (fun i => Z i.castSucc ω)).1
          (fitQR A (fun i => Z i.castSucc ω)).2 (Z j ω))
        (↑(I₂.map Fin.castSuccEmb ∪ {Fin.last n}) : Set (Fin (n + 1)))) →
      ∀ᵐ ω ∂P,
        (P[Set.indicator {ω' | (Z (Fin.last n) ω').2 ∈
            cqrInterval A I₂ α (fun i => Z i.castSucc ω') (Z (Fin.last n) ω').1} (fun _ => (1 : ℝ)) |
          MeasurableSpace.comap (fun ω' (i : ↥I₁) => Z (Fin.castSucc i.1) ω') inferInstance]) ω ≤
          1 - α + 1 / ((I₂.card : ℝ) + 1)) := by sorry

end ConformalizedQuantileRegression
Source
Romano, Patterson and Candès, Conformalized Quantile Regression, arXiv:1905.03222v1 (2019), Section 4, proof of Theorem 1, eqs. (12)-(14), p. 6
Read-back

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

Let (Ω,F,P)(\Omega, \mathcal F, \mathbb P)(Ω,F,P) be a probability space. Fix natural numbers ppp (the feature dimension) and nnn. A sample is a pair (x,y)∈Rp×R(x, y) \in \mathbb R^p \times \mathbb R(x,y)∈Rp×R.

Random samples. Let Z1,…,Zn+1:Ω→Rp×RZ_1, \dots, Z_{n+1} : \Omega \to \mathbb R^p \times \mathbb RZ1​,…,Zn+1​:Ω→Rp×R be random samples, written Zi=(Xi,Yi)Z_i = (X_i, Y_i)Zi​=(Xi​,Yi​). They are assumed exchangeable, which means two things:

  • each ZiZ_iZi​ is measurable, using the Borel structure on Rp×R\mathbb R^p \times \mathbb RRp×R;
  • for every permutation σ\sigmaσ of {1,…,n+1}\{1, \dots, n+1\}{1,…,n+1}, the joint law of (Zσ(1),…,Zσ(n+1))(Z_{\sigma(1)}, \dots, Z_{\sigma(n+1)})(Zσ(1)​,…,Zσ(n+1)​) under P\mathbb PP equals the joint law of (Z1,…,Zn+1)(Z_1, \dots, Z_{n+1})(Z1​,…,Zn+1​).

The first nnn samples are the data, and Zn+1=(Xn+1,Yn+1)Z_{n+1} = (X_{n+1}, Y_{n+1})Zn+1​=(Xn+1​,Yn+1​) is the test point.

Data split. Let I1,I2⊆{1,…,n}I_1, I_2 \subseteq \{1, \dots, n\}I1​,I2​⊆{1,…,n} satisfy:

  • I1∩I2=∅I_1 \cap I_2 = \emptysetI1​∩I2​=∅;
  • I1∪I2={1,…,n}I_1 \cup I_2 = \{1, \dots, n\}I1​∪I2​={1,…,n};
  • I2≠∅I_2 \neq \emptysetI2​=∅, which forces n≥1n \ge 1n≥1.

I1I_1I1​ may be empty.

Algorithm. Let AAA be any map sending a family of samples indexed by I1I_1I1​ to a pair of functions (q^lo,q^hi)(\hat q_{\mathrm{lo}}, \hat q_{\mathrm{hi}})(q^​lo​,q^​hi​), each from Rp\mathbb R^pRp to R\mathbb RR. AAA is assumed measurable in the following sense: both maps

(training family,x)↦q^lo(x),(training family,x)↦q^hi(x)(\text{training family}, x) \mapsto \hat q_{\mathrm{lo}}(x), \qquad (\text{training family}, x) \mapsto \hat q_{\mathrm{hi}}(x)(training family,x)↦q^​lo​(x),(training family,x)↦q^​hi​(x)

are jointly measurable. No other property is assumed. In particular, q^lo≤q^hi\hat q_{\mathrm{lo}} \le \hat q_{\mathrm{hi}}q^​lo​≤q^​hi​ is not assumed.

Miscoverage level. Let α\alphaα be a real number with 0<α<10 < \alpha < 10<α<1.

Constructed objects. For each ω\omegaω, define the following.

  • Fitted functions. (q^lo,q^hi)=A((Zi(ω))i∈I1)(\hat q_{\mathrm{lo}}, \hat q_{\mathrm{hi}}) = A\big((Z_i(\omega))_{i \in I_1}\big)(q^​lo​,q^​hi​)=A((Zi​(ω))i∈I1​​). These depend only on the training samples.
  • Conformity scores. For every index j∈{1,…,n+1}j \in \{1, \dots, n+1\}j∈{1,…,n+1},
Ej=max⁡{q^lo(Xj)−Yj,  Yj−q^hi(Xj)}.E_j = \max\{\hat q_{\mathrm{lo}}(X_j) - Y_j,\; Y_j - \hat q_{\mathrm{hi}}(X_j)\}.Ej​=max{q^​lo​(Xj​)−Yj​,Yj​−q^​hi​(Xj​)}.
  • Empirical distribution function of the calibration scores:
F^(y)=#{i∈I2:Ei≤y}∣I2∣.\hat F(y) = \frac{\#\{i \in I_2 : E_i \le y\}}{|I_2|}.F^(y)=∣I2​∣#{i∈I2​:Ei​≤y}​.
  • Level. β=(1−α)(1+1∣I2∣)\beta = (1-\alpha)\big(1 + \tfrac{1}{|I_2|}\big)β=(1−α)(1+∣I2​∣1​). Note that β>0\beta > 0β>0.
  • Correction. Q=inf⁡{y∈R:β≤F^(y)}Q = \inf\{y \in \mathbb R : \beta \le \hat F(y)\}Q=inf{y∈R:β≤F^(y)}, taken in the extended reals.
    • When β>1\beta > 1β>1, the set is empty and Q=+∞Q = +\inftyQ=+∞. This happens exactly when (1−α)(∣I2∣+1)>∣I2∣(1-\alpha)(|I_2|+1) > |I_2|(1−α)(∣I2​∣+1)>∣I2​∣.
    • Otherwise QQQ is a finite real number, and it may be negative.
  • Prediction interval.
C(x)={ y∈R:q^lo(x)−Q≤y≤q^hi(x)+Q }.C(x) = \{\, y \in \mathbb R : \hat q_{\mathrm{lo}}(x) - Q \le y \le \hat q_{\mathrm{hi}}(x) + Q \,\}.C(x)={y∈R:q^​lo​(x)−Q≤y≤q^​hi​(x)+Q}.
  • This is all of R\mathbb RR when Q=+∞Q = +\inftyQ=+∞.
  • It is empty whenever q^lo(x)−Q>q^hi(x)+Q\hat q_{\mathrm{lo}}(x) - Q > \hat q_{\mathrm{hi}}(x) + Qq^​lo​(x)−Q>q^​hi​(x)+Q.

Conditioning. Let G\mathcal GG be the σ-algebra generated by the training samples (Zi)i∈I1(Z_i)_{i \in I_1}(Zi​)i∈I1​​. When I1=∅I_1 = \emptysetI1​=∅, G\mathcal GG is trivial.

Write π(ω)\pi(\omega)π(ω) for the conditional expectation given G\mathcal GG, evaluated at ω\omegaω, of the indicator of the event

{ω′:Yn+1(ω′)∈C(Xn+1(ω′))}.\{\omega' : Y_{n+1}(\omega') \in C(X_{n+1}(\omega'))\}.{ω′:Yn+1​(ω′)∈C(Xn+1​(ω′))}.

In this event, the interval CCC is built from the fit and calibration scores of the same ω′\omega'ω′. Thus π\piπ is the conditional coverage probability given the training samples. It is defined up to a P\mathbb PP-null set. By the library's convention, it would be 000 if this indicator were not measurable.

Conclusion. The statement asserts two things.

  1. Lower bound. For P\mathbb PP-almost every ω\omegaω,
1−α≤π(ω).1 - \alpha \le \pi(\omega).1−α≤π(ω).
  1. Upper bound. Suppose that, for P\mathbb PP-almost every ω\omegaω, the scores EjE_jEj​ for j∈I2∪{n+1}j \in I_2 \cup \{n+1\}j∈I2​∪{n+1} are pairwise distinct. These are the calibration indices together with the test index, all scored with the fit from the training samples. Then, for P\mathbb PP-almost every ω\omegaω,
π(ω)≤1−α+1∣I2∣+1.\pi(\omega) \le 1 - \alpha + \frac{1}{|I_2| + 1}.π(ω)≤1−α+∣I2​∣+11​.

This distinctness assumption appears only as the premise of the second claim. It is not a hypothesis of the first claim.

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