Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Proposition 4: quantile risk control

Proved
ConformalRiskControl.quantile_risk_control

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

conformal-predictiondistribution-free-inferenceexchangeabilityrisk-controluncertainty-quantification

Let Λ⊂R\Lambda\subset\mathbb{R}Λ⊂R be nonempty and compact with λmax⁡=max⁡Λ\lambda_{\max}=\max\Lambdaλmax​=maxΛ, let n≥1n\ge1n≥1, α<B\alpha<Bα<B and β∈(0,1]\beta\in(0,1]β∈(0,1]. Let L1,…,Ln+1L_1,\dots,L_{n+1}L1​,…,Ln+1​ be as in Theorem 1: exchangeable, with non-increasing, right-continuous realisations, and almost surely Li(λmax⁡)≤αL_i(\lambda_{\max})\le\alphaLi​(λmax​)≤α and sup⁡λLi(λ)≤B\sup_\lambda L_i(\lambda)\le Bsupλ​Li​(λ)≤B. With

λ^β=inf⁡{λ∈Λ:1n+1∑i=1n1{Li(λ)>α}+1n+1≤1−β},\hat\lambda_\beta=\inf\Big\{\lambda\in\Lambda:\frac1{n+1}\sum_{i=1}^n\mathbb{1}\{L_i(\lambda)>\alpha\}+\frac1{n+1}\le1-\beta\Big\},λ^β​=inf{λ∈Λ:n+11​i=1∑n​1{Li​(λ)>α}+n+11​≤1−β},

the β\betaβ-quantile of the test loss satisfies

Quantileβ(Ln+1(λ^β))≤α,\mathrm{Quantile}_\beta\big(L_{n+1}(\hat\lambda_\beta)\big)\le\alpha,Quantileβ​(Ln+1​(λ^β​))≤α,

where Quantileβ(X)=inf⁡{x:P(X≤x)≥β}\mathrm{Quantile}_\beta(X)=\inf\{x:\mathbb{P}(X\le x)\ge\beta\}Quantileβ​(X)=inf{x:P(X≤x)≥β}.

Formalization Note The paper does not state the range of β\betaβ. It is taken to be (0,1](0,1](0,1], where the quantile is a finite real number.

Preamble
import Mathlib
import Definitions.Def_ConformalRiskControl_Basic

open MeasureTheory ProbabilityTheory Filter
Formal statement
namespace ConformalRiskControl

theorem quantile_risk_control {Ω : Type*} [MeasurableSpace Ω] (P : Measure Ω)
    [IsProbabilityMeasure P] (n : ℕ) (hn : 0 < n) (Λ : Set ℝ) (hΛ : IsCompact Λ)
    (hΛne : Λ.Nonempty) (B α : ℝ) (hαB : α < B) (β : ℝ) (hβ₀ : 0 < β) (hβ₁ : β ≤ 1)
    (L : Fin (n + 1) → Ω → ℝ → ℝ)
    (hexch : IsExchangeable P Λ L) (hanti : ∀ i ω, AntitoneOn (L i ω) Λ)
    (hrc : ∀ i ω, IsRightContOn Λ (L i ω)) (h5 : ∀ᵐ ω ∂P, ∀ i, LossBounds Λ B α (L i ω)) :
    quantile P (fun ω =>
        L (Fin.last n) ω (lhatQuantile Λ α β (fun i : Fin n => L i.castSucc ω))) β ≤ α := by sorry

end ConformalRiskControl
Source
Angelopoulos, Bates, Fisch, Lei and Schuster, Conformal Risk Control, arXiv:2208.02814v4, Section 4.2, Proposition 4, eq. (11), p. 11; proof in Appendix B, p. 19
Read-back

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

Setting. Let (Ω,F)(\Omega, \mathcal F)(Ω,F) be a measurable space with a probability measure PPP. The theorem assumes the following data and hypotheses:

  • an integer n≥1n \ge 1n≥1;
  • a compact, nonempty set Λ⊆R\Lambda \subseteq \mathbb RΛ⊆R, with λmax⁡:=sup⁡Λ\lambda_{\max} := \sup \Lambdaλmax​:=supΛ (which lies in Λ\LambdaΛ);
  • real numbers BBB and α\alphaα with α<B\alpha < Bα<B;
  • a real number β\betaβ with 0<β≤10 < \beta \le 10<β≤1;
  • n+1n+1n+1 random functions L1,…,Ln+1L_1, \dots, L_{n+1}L1​,…,Ln+1​. For each index iii and outcome ω∈Ω\omega \in \Omegaω∈Ω, Li(ω):R→RL_i(\omega) : \mathbb R \to \mathbb RLi​(ω):R→R. The first nnn are the calibration losses and Ln+1L_{n+1}Ln+1​ is the test loss. (In the code the indices are 0,…,n0, \dots, n0,…,n, with the last one, nnn, playing the role of Ln+1L_{n+1}Ln+1​.)

Hypotheses on the losses.

  1. Exchangeability. For every iii and every λ∈Λ\lambda \in \Lambdaλ∈Λ, the map ω↦Li(ω)(λ)\omega \mapsto L_i(\omega)(\lambda)ω↦Li​(ω)(λ) is measurable. View ω↦(Li(ω)∣Λ)i=1n+1\omega \mapsto \big(L_i(\omega)|_{\Lambda}\big)_{i=1}^{n+1}ω↦(Li​(ω)∣Λ​)i=1n+1​ as a random element of (Λ→R)n+1(\Lambda \to \mathbb R)^{n+1}(Λ→R)n+1 with the product σ\sigmaσ-algebra. For every permutation σ\sigmaσ of {1,…,n+1}\{1, \dots, n+1\}{1,…,n+1}, its law under PPP equals the law of ω↦(Lσ(i)(ω)∣Λ)i=1n+1\omega \mapsto \big(L_{\sigma(i)}(\omega)|_{\Lambda}\big)_{i=1}^{n+1}ω↦(Lσ(i)​(ω)∣Λ​)i=1n+1​.

  2. Monotonicity. For every iii and every ω\omegaω (not merely almost surely), λ↦Li(ω)(λ)\lambda \mapsto L_i(\omega)(\lambda)λ↦Li​(ω)(λ) is non-increasing on Λ\LambdaΛ.

  3. Right-continuity. For every iii and every ω\omegaω, Li(ω)L_i(\omega)Li​(ω) is right-continuous on Λ\LambdaΛ. That is, at each x∈Λx \in \Lambdax∈Λ it is continuous at xxx relative to Λ∩[x,∞)\Lambda \cap [x, \infty)Λ∩[x,∞).

  4. Bounds. For PPP-almost every ω\omegaω, simultaneously for all iii:

Li(ω)(λ)≤B  for all λ∈Λ,Li(ω)(λmax⁡)≤α.L_i(\omega)(\lambda) \le B \ \text{ for all } \lambda \in \Lambda, \qquad L_i(\omega)(\lambda_{\max}) \le \alpha.Li​(ω)(λ)≤B  for all λ∈Λ,Li​(ω)(λmax​)≤α.

The α\alphaα here is the same α\alphaα that appears in the conclusion.

The parameter. For each ω\omegaω, define the set

S(ω)={λ∈Λ  :  1n+1∑i=1n1{Li(ω)(λ)>α}+1n+1≤1−β}.S(\omega) = \Big\{ \lambda \in \Lambda \;:\; \frac{1}{n+1} \sum_{i=1}^{n} \mathbf 1\{L_i(\omega)(\lambda) > \alpha\} + \frac{1}{n+1} \le 1 - \beta \Big\}.S(ω)={λ∈Λ:n+11​i=1∑n​1{Li​(ω)(λ)>α}+n+11​≤1−β}.

Note that the sum runs over the nnn calibration losses only, while the denominator is n+1n+1n+1. The parameter is then

λ^β(ω)={inf⁡S(ω)if S(ω)≠∅,λmax⁡otherwise.\hat\lambda_\beta(\omega) = \begin{cases} \inf S(\omega) & \text{if } S(\omega) \neq \emptyset, \\ \lambda_{\max} & \text{otherwise.} \end{cases}λ^β​(ω)={infS(ω)λmax​​if S(ω)=∅,otherwise.​

The constant BBB does not enter λ^β\hat\lambda_\betaλ^β​. If 1−β<1n+11 - \beta < \frac{1}{n+1}1−β<n+11​, the set S(ω)S(\omega)S(ω) is always empty and λ^β≡λmax⁡\hat\lambda_\beta \equiv \lambda_{\max}λ^β​≡λmax​; in particular, this happens whenever β=1\beta = 1β=1.

The test loss and its quantile. Let Z(ω)=Ln+1(ω)(λ^β(ω))Z(\omega) = L_{n+1}(\omega)\big(\hat\lambda_\beta(\omega)\big)Z(ω)=Ln+1​(ω)(λ^β​(ω)). The code defines the β\betaβ-quantile as

Quantileβ(Z)=inf⁡{x∈R:P(Z≤x)≥β}.\mathrm{Quantile}_\beta(Z) = \inf\{ x \in \mathbb R : P(Z \le x) \ge \beta \}.Quantileβ​(Z)=inf{x∈R:P(Z≤x)≥β}.

Two conventions apply to this definition:

  • P(Z≤x)P(Z \le x)P(Z≤x) is evaluated as the (outer) measure of the set {ω:Z(ω)≤x}\{\omega : Z(\omega) \le x\}{ω:Z(ω)≤x}. No measurability of ZZZ is assumed.
  • The infimum of a set that is empty or unbounded below is taken to be 000.

Conclusion. Under all of the above hypotheses, the theorem asserts

Quantileβ(Z)≤α.\mathrm{Quantile}_\beta(Z) \le \alpha.Quantileβ​(Z)≤α.
Human review
  • Endorsed by Shuze Chen · Nov 23, 2026

    Confirmed by the moderator at approval.

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