Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Proposition 7: U-risk control

Proved
ConformalRiskControl.u_risk_control

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

conformal-predictiondistribution-free-inferenceexchangeabilityrisk-controluncertainty-quantification

Let 1<k≤n1<k\le n1<k≤n, let Λ⊂R\Lambda\subset\mathbb{R}Λ⊂R be nonempty and compact with λmax⁡=max⁡Λ\lambda_{\max}=\max\Lambdaλmax​=maxΛ, and let α<B\alpha<Bα<B. For every kkk-subset S⊂{1,…,n+k}S\subset\{1,\dots,n+k\}S⊂{1,…,n+k} let LSL_SLS​ be a random function on Λ\LambdaΛ. Assume the family (LS)(L_S)(LS​) is exchangeable under relabelling of {1,…,n+k}\{1,\dots,n+k\}{1,…,n+k}. Assume every realisation of every LSL_SLS​ is non-increasing and right-continuous, and that almost surely

LS(λmax⁡)≤α,sup⁡λLS(λ)≤Bfor all S.L_S(\lambda_{\max})\le\alpha,\qquad\sup_\lambda L_S(\lambda)\le B\quad\text{for all }S.LS​(λmax​)≤α,λsup​LS​(λ)≤Bfor all S.

Then the parameter λ^k\hat\lambda_kλ^k​ of eq. (16) satisfies

E[L{n+1,…,n+k}(λ^k)]≤α.\mathbb{E}\big[L_{\{n+1,\dots,n+k\}}(\hat\lambda_k)\big]\le\alpha.E[L{n+1,…,n+k}​(λ^k​)]≤α.

This extends Theorem 1 to risks that are expectations of order-kkk U-statistics, as in ranking and metric learning.

Formalization Note Proposition 7 does not state exchangeability, but its proof uses it ("the same argument as in the end of the proof of Theorem 1"), and without it the claim fails. The condition k≤nk\le nk≤n is the range in which the factor (n−k)!(n-k)!(n−k)! of eq. (16) is defined.

Preamble
import Mathlib
import Definitions.Def_ConformalRiskControl_Basic

open MeasureTheory ProbabilityTheory Filter
Formal statement
namespace ConformalRiskControl

theorem u_risk_control {Ω : Type*} [MeasurableSpace Ω] (P : Measure Ω)
    [IsProbabilityMeasure P] (n k : ℕ) (hk : 1 < k) (hkn : k ≤ n) (Λ : Set ℝ)
    (hΛ : IsCompact Λ) (hΛne : Λ.Nonempty) (B α : ℝ) (hαB : α < B)
    (L : Finset (Fin (n + k)) → Ω → ℝ → ℝ) (hexch : IsExchangeableU P Λ n k L)
    (hanti : ∀ S : Finset (Fin (n + k)), S.card = k → ∀ ω, AntitoneOn (L S ω) Λ)
    (hrc : ∀ S : Finset (Fin (n + k)), S.card = k → ∀ ω, IsRightContOn Λ (L S ω))
    (h5 : ∀ᵐ ω ∂P, ∀ S : Finset (Fin (n + k)), S.card = k → LossBounds Λ B α (L S ω)) :
    upperExp P B (fun ω => L (testSubset n k) ω (lhatU Λ B α n k (fun S => L S ω)))
      ≤ (α : EReal) := by sorry

end ConformalRiskControl
Source
Angelopoulos, Bates, Fisch, Lei and Schuster, Conformal Risk Control, arXiv:2208.02814v4, Section 4.5, Proposition 7, eqs. (15)-(16), p. 12; proof in Appendix B, p. 19
Read-back

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

Fix a probability space (Ω,F,P)(\Omega,\mathcal F,P)(Ω,F,P), where PPP is a probability measure. Fix natural numbers n,kn,kn,k with

1<k≤n,1 < k \le n,1<k≤n,

so k≥2k \ge 2k≥2 and n≥2n \ge 2n≥2. Fix a parameter set Λ⊆R\Lambda\subseteq\mathbb RΛ⊆R that is compact and nonempty, so λmax⁡:=sup⁡Λ\lambda_{\max}:=\sup\Lambdaλmax​:=supΛ exists and belongs to Λ\LambdaΛ. Fix reals B,αB,\alphaB,α with α<B\alpha<Bα<B.

Losses. For every subset S⊆{1,…,n+k}S\subseteq\{1,\dots,n+k\}S⊆{1,…,n+k}, every outcome ω∈Ω\omega\in\Omegaω∈Ω and every λ∈R\lambda \in \mathbb Rλ∈R, there is a real number LS(ω)(λ)L_S(\omega)(\lambda)LS​(ω)(λ). Such a family is given for every subset SSS, but all hypotheses below concern only subsets with ∣S∣=k|S|=k∣S∣=k. Two collections of kkk-subsets are singled out:

  • the calibration subsets C\mathcal CC: all kkk-element subsets of {1,…,n}\{1,\dots,n\}{1,…,n} (there are (nk)\binom nk(kn​) of them);
  • the test subset T={n+1,…,n+k}T=\{n+1,\dots,n+k\}T={n+1,…,n+k}, which has exactly kkk elements.

Hypotheses.

  1. Exchangeability under relabelling. For every SSS with ∣S∣=k|S|=k∣S∣=k and every λ∈Λ\lambda\in\Lambdaλ∈Λ, the map ω↦LS(ω)(λ)\omega\mapsto L_S(\omega)(\lambda)ω↦LS​(ω)(λ) is measurable. For every permutation σ\sigmaσ of {1,…,n+k}\{1,\dots,n+k\}{1,…,n+k}, the joint law under PPP of the array (Lσ(S)(ω)(λ))∣S∣=k, λ∈Λ\big(L_{\sigma(S)}(\omega)(\lambda)\big)_{|S|=k,\ \lambda\in\Lambda}(Lσ(S)​(ω)(λ))∣S∣=k, λ∈Λ​ equals the joint law of (LS(ω)(λ))∣S∣=k, λ∈Λ\big(L_S(\omega)(\lambda)\big)_{|S|=k,\ \lambda\in\Lambda}(LS​(ω)(λ))∣S∣=k, λ∈Λ​. Both are viewed as random elements of the space of real functions on {S:∣S∣=k}×Λ\{S: |S|=k\}\times\Lambda{S:∣S∣=k}×Λ with the product σ-algebra. Only values at λ∈Λ\lambda\in\Lambdaλ∈Λ enter.
  2. Monotonicity. For every SSS with ∣S∣=k|S|=k∣S∣=k and every ω\omegaω (not merely almost every), λ↦LS(ω)(λ)\lambda\mapsto L_S(\omega)(\lambda)λ↦LS​(ω)(λ) is non-increasing on Λ\LambdaΛ.
  3. Right-continuity. For every SSS with ∣S∣=k|S|=k∣S∣=k and every ω\omegaω, at each x∈Λx\in\Lambdax∈Λ the function LS(ω)L_S(\omega)LS​(ω) is continuous at xxx relative to Λ∩[x,∞)\Lambda\cap[x,\infty)Λ∩[x,∞).
  4. Bounds. For PPP-almost every ω\omegaω, simultaneously for all SSS with ∣S∣=k|S|=k∣S∣=k:
    • LS(ω)(λ)≤BL_S(\omega)(\lambda)\le BLS​(ω)(λ)≤B for all λ∈Λ\lambda\in\Lambdaλ∈Λ, and
    • LS(ω)(λmax⁡)≤αL_S(\omega)(\lambda_{\max})\le\alphaLS​(ω)(λmax​)≤α.

The parameter. For each ω\omegaω define

λ^k(ω)=inf⁡{λ∈Λ: k! n!(n+k)!∑S∈CLS(ω)(λ)  +  B(1−(n!)2(n+k)! (n−k)!)≤α}.\hat\lambda_k(\omega)=\inf\Big\{\lambda\in\Lambda:\ \frac{k!\,n!}{(n+k)!}\sum_{S\in\mathcal C}L_S(\omega)(\lambda)\;+\;B\Big(1-\frac{(n!)^2}{(n+k)!\,(n-k)!}\Big)\le\alpha\Big\}.λ^k​(ω)=inf{λ∈Λ: (n+k)!k!n!​S∈C∑​LS​(ω)(λ)+B(1−(n+k)!(n−k)!(n!)2​)≤α}.

If this set is empty, λ^k(ω)\hat\lambda_k(\omega)λ^k​(ω) is instead λmax⁡\lambda_{\max}λmax​. Here n−k≥0n-k\ge0n−k≥0, so no truncated subtraction occurs. The prefactor is literally k! n!/(n+k)!k!\,n!/(n+k)!k!n!/(n+k)!, applied to a sum over the (nk)\binom nk(kn​) calibration subsets. Since Λ\LambdaΛ is closed and bounded, λ^k(ω)∈Λ\hat\lambda_k(\omega)\in\Lambdaλ^k​(ω)∈Λ in both cases.

Conclusion. Let X(ω)=LT(ω)(λ^k(ω))X(\omega)=L_T(\omega)\big(\hat\lambda_k(\omega)\big)X(ω)=LT​(ω)(λ^k​(ω)) be the test-subset loss at the data-dependent parameter. The theorem asserts

B−∫−(B−X(ω))+ dP(ω)  ≤  α,B-\int^{-}\big(B-X(\omega)\big)^{+}\,dP(\omega)\;\le\;\alpha,B−∫−(B−X(ω))+dP(ω)≤α,

computed in the extended reals [−∞,∞][-\infty,\infty][−∞,∞]. The integral is a lower Lebesgue integral with values in [0,∞][0,\infty][0,∞], and (⋅)+(\cdot)^+(⋅)+ denotes the positive part. No measurability of XXX is assumed or required for this quantity to be defined. If the integral is +∞+\infty+∞, the left side is −∞-\infty−∞ and the inequality holds trivially. Whenever X≤BX\le BX≤B almost surely and XXX is measurable, the left side equals the ordinary expectation E[X]\mathbb E[X]E[X] (possibly −∞-\infty−∞). So in that case the statement reads E[LT(λ^k)]≤α\mathbb E\big[L_T(\hat\lambda_k)\big]\le\alphaE[LT​(λ^k​)]≤α.

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