Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Lemma 2 (as proved): inflation of quantiles

Proved
ConformalizedQuantileRegression.quantile_inflation

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

conformal-predictiondistribution-freeexchangeabilityprediction-intervalsquantile-regression

Let n≥1n\ge1n≥1 and let Z1,…,Zn+1Z_1,\dots,Z_{n+1}Z1​,…,Zn+1​ be exchangeable real random variables. Let Q^n\hat Q_nQ^​n​ be the empirical quantile function of Z1,…,ZnZ_1,\dots,Z_nZ1​,…,Zn​. For every α∈(0,1)\alpha\in(0,1)α∈(0,1),

P{Zn+1≤Q^n((1+1n)α)}≥α.\mathbb{P}\{Z_{n+1}\le\hat Q_n((1+\tfrac1n)\alpha)\}\ge\alpha.P{Zn+1​≤Q^​n​((1+n1​)α)}≥α.

If moreover Z1,…,Zn+1Z_1,\dots,Z_{n+1}Z1​,…,Zn+1​ are almost surely distinct, then also

P{Zn+1≤Q^n((1+1n)α)}≤α+1n+1.\mathbb{P}\{Z_{n+1}\le\hat Q_n((1+\tfrac1n)\alpha)\}\le\alpha+\frac{1}{n+1}.P{Zn+1​≤Q^​n​((1+n1​)α)}≤α+n+11​.

The inflated level (1+1n)α(1+\frac1n)\alpha(1+n1​)α accounts for the unseen (n+1)(n+1)(n+1)-st variable; this lemma is what the coverage theorems apply to the conformity scores.

Formalization Note This is Lemma 2 as its proof establishes it. The printed upper bound is α+1n\alpha+\frac1nα+n1​; the proof (apply Lemma 1 with n+1n+1n+1 variables) gives the sharper α+1n+1\alpha+\frac1{n+1}α+n+11​, and the proof of Theorem 1 uses this sharper form to obtain 1−α+1∣I2∣+11-\alpha+\frac{1}{|\mathcal I_2|+1}1−α+∣I2​∣+11​. The empirical quantile at a level above 111 is +∞+\infty+∞.

Preamble
import Mathlib
import Definitions.Def_ConformalizedQuantileRegression_Basic

open MeasureTheory ProbabilityTheory
Formal statement
namespace ConformalizedQuantileRegression

theorem quantile_inflation {Ω : Type*} [MeasurableSpace Ω] (P : Measure Ω)
    [IsProbabilityMeasure P] {n : ℕ} (hn : 0 < n) (Z : Fin (n + 1) → Ω → ℝ)
    (hZ : IsExchangeable P Z) (α : ℝ) (hα0 : 0 < α) (hα1 : α < 1) :
    ENNReal.ofReal α ≤
        P {ω | (Z (Fin.last n) ω : EReal) ≤
          empQuantile (Finset.univ.map Fin.castSuccEmb) (fun i => Z i ω) ((1 + 1 / (n : ℝ)) * α)} ∧
    ((∀ᵐ ω ∂P, Function.Injective (fun i => Z i ω)) →
      P {ω | (Z (Fin.last n) ω : EReal) ≤
          empQuantile (Finset.univ.map Fin.castSuccEmb) (fun i => Z i ω) ((1 + 1 / (n : ℝ)) * α)} ≤
        ENNReal.ofReal (α + 1 / ((n : ℝ) + 1))) := by sorry

end ConformalizedQuantileRegression
Source
Romano, Patterson and Candès, Conformalized Quantile Regression, arXiv:1905.03222v1 (2019), Appendix A, Lemma 2 (Inflation of quantiles) and its proof, p. 18; upper bound α + 1/(n+1) as established by the proof (printed: α + 1/n)
Read-back

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

Let (Ω,F,P)(\Omega, \mathcal{F}, P)(Ω,F,P) be a probability space. Let n≥1n \ge 1n≥1 be a natural number, and let Z1,…,Zn+1:Ω→RZ_1, \dots, Z_{n+1} : \Omega \to \mathbb{R}Z1​,…,Zn+1​:Ω→R be real-valued functions. (In the code they are indexed 0,…,n0, \dots, n0,…,n; here they are relabelled 1,…,n+11, \dots, n+11,…,n+1, so Zn+1Z_{n+1}Zn+1​ is the last one.)

The family is assumed exchangeable in the following sense:

  • each ZiZ_iZi​ is measurable; and
  • 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 PPP equals the joint law of (Z1,…,Zn+1)(Z_1, \dots, Z_{n+1})(Z1​,…,Zn+1​), as measures on Rn+1\mathbb{R}^{n+1}Rn+1.

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

Empirical quantile. For each outcome ω\omegaω, the empirical CDF of the first nnn values is

F^ω(y)=#{ i∈{1,…,n}:Zi(ω)≤y }n,y∈R.\hat F_\omega(y) = \frac{\#\{\, i \in \{1,\dots,n\} : Z_i(\omega) \le y \,\}}{n}, \qquad y \in \mathbb{R}.F^ω​(y)=n#{i∈{1,…,n}:Zi​(ω)≤y}​,y∈R.

For a level β∈R\beta \in \mathbb{R}β∈R, the empirical quantile Q^ω(β)\hat Q_\omega(\beta)Q^​ω​(β) is defined in the extended reals [−∞,+∞][-\infty, +\infty][−∞,+∞] as

Q^ω(β)=inf⁡{ y∈R:β≤F^ω(y) }.\hat Q_\omega(\beta) = \inf\{\, y \in \mathbb{R} : \beta \le \hat F_\omega(y) \,\}.Q^​ω​(β)=inf{y∈R:β≤F^ω​(y)}.

Some features of this definition:

  • Q^ω(β)=+∞\hat Q_\omega(\beta) = +\inftyQ^​ω​(β)=+∞ when the set is empty, which happens exactly when β>1\beta > 1β>1.
  • When 0<β≤10 < \beta \le 10<β≤1, the infimum is attained and equals the ⌈nβ⌉\lceil n\beta \rceil⌈nβ⌉-th smallest of Z1(ω),…,Zn(ω)Z_1(\omega), \dots, Z_n(\omega)Z1​(ω),…,Zn​(ω), counted with multiplicity.
  • The level used throughout is the inflated level
β=(1+1n)α.\beta = \left(1 + \frac{1}{n}\right)\alpha.β=(1+n1​)α.

This is strictly positive. It exceeds 111, so that Q^ω(β)=+∞\hat Q_\omega(\beta) = +\inftyQ^​ω​(β)=+∞, precisely when α>nn+1\alpha > \frac{n}{n+1}α>n+1n​.

  • Only Z1,…,ZnZ_1, \dots, Z_nZ1​,…,Zn​ enter Q^ω\hat Q_\omegaQ^​ω​; the last variable Zn+1Z_{n+1}Zn+1​ does not.

Define the event

E={ ω:Zn+1(ω)≤Q^ω ⁣((1+1n)α)}.E = \left\{\, \omega : Z_{n+1}(\omega) \le \hat Q_\omega\!\left(\left(1 + \tfrac{1}{n}\right)\alpha\right) \right\}.E={ω:Zn+1​(ω)≤Q^​ω​((1+n1​)α)}.

The comparison is non-strict and takes place in the extended reals, so EEE contains every ω\omegaω for which the quantile is +∞+\infty+∞. Here P(E)P(E)P(E) denotes the measure PPP applied to this set; measurability of EEE is not asserted, and for a non-measurable set this value would be its outer measure.

The theorem asserts both of the following.

  1. Lower bound. With no further assumption:
α≤P(E).\alpha \le P(E).α≤P(E).
  1. Upper bound under distinctness. If, for PPP-almost every ω\omegaω, the values Z1(ω),…,Zn+1(ω)Z_1(\omega), \dots, Z_{n+1}(\omega)Z1​(ω),…,Zn+1​(ω) are pairwise distinct, then
P(E)≤α+1n+1.P(E) \le \alpha + \frac{1}{n+1}.P(E)≤α+n+11​.

This bound is stated as an inequality of non-negative extended reals. Whenever α+1n+1≥1\alpha + \frac{1}{n+1} \ge 1α+n+11​≥1, it holds automatically.

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