Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Theorem 2: conformal p-values are PRDS

Proved
ConformalOutlierTesting.conformal_pvalues_prds

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

conformal-inferencefalse-discovery-ratemultiple-testingoutlier-detectionprds

Let the scores be continuously distributed with law μ\muμ. Let nnn calibration scores be i.i.d. with law μ\muμ, and let mmm test points have independent scores, independent of the calibration data. The scores of the inliers j∈Ij\in Ij∈I have law μ\muμ, and the scores of the outliers have arbitrary laws. Then the marginal conformal p-values

(u^(marg)(X2n+1),…,u^(marg)(X2n+m))\big(\hat u^{(\mathrm{marg})}(X_{2n+1}),\dots,\hat u^{(\mathrm{marg})}(X_{2n+m})\big)(u^(marg)(X2n+1​),…,u^(marg)(X2n+m​))

are PRDS on the set III of inliers. That is, for every inlier iii and every increasing set AAA, P[(p1,…,pm)∈A∣pi=x]\mathbb P[(p_1,\dots,p_m)\in A\mid p_i=x]P[(p1​,…,pm​)∈A∣pi​=x] is nondecreasing in xxx.

Together with Benjamini and Yekutieli (2001), this shows that the BH procedure applied to conformal p-values controls the FDR.

Formalization Note The paper's wording asks only that "the inliers are jointly independent of each other and of the data in D\mathcal DD". The proof (Lemma 4, general case) assumes that all test points are mutually independent and independent of D\mathcal DD, as stated in Section 1.1, and the formal statement assumes the same. This is more than is needed. The outliers may depend on one another, as the paper notes in Section 6, but they must be independent of the inliers and of D\mathcal DD. Without that the conclusion can fail (see the mission report). Increasing sets are taken measurable. Since the p-values take finitely many values, this loses nothing. The conditional probability is a conditional expectation given σ(pi)\sigma(p_i)σ(pi​), and PRDS asks for a nondecreasing version of it.

Preamble
import Mathlib
import Definitions.Def_ConformalOutlierTesting_Basic

open MeasureTheory ProbabilityTheory Filter Topology Set BoundedContinuousFunction
Formal statement
namespace ConformalOutlierTesting

theorem conformal_pvalues_prds {n m : ℕ} (μ : Measure ℝ) [IsProbabilityMeasure μ] [NullSingletonClass μ]
    (ν : Fin m → Measure ℝ) [∀ j, IsProbabilityMeasure (ν j)] (I : Finset (Fin m))
    (hI : ∀ j ∈ I, ν j = μ) :
    IsPRDS (scoreLaw (n := n) μ ν) margPvals I := by sorry

end ConformalOutlierTesting
Source
Bates, Candès, Lei, Romano and Sesia, Testing for Outliers with Conformal p-values, arXiv:2104.08279v3 (2022), Section 2.2, Theorem 2 and Definition 1, pp. 6-7; proof in Appendix A.3, pp. 39-40
Read-back

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

Let n,m≥0n, m \ge 0n,m≥0 be natural numbers. Write [n]={0,…,n−1}[n] = \{0, \dots, n-1\}[n]={0,…,n−1} and [m]={0,…,m−1}[m] = \{0, \dots, m-1\}[m]={0,…,m−1}; either may be empty.

Hypotheses.

  • μ\muμ is a probability measure on R\mathbb{R}R with no atoms: μ({x})=0\mu(\{x\}) = 0μ({x})=0 for every x∈Rx \in \mathbb{R}x∈R.
  • ν0,…,νm−1\nu_0, \dots, \nu_{m-1}ν0​,…,νm−1​ are probability measures on R\mathbb{R}R. Nothing else is assumed about them; in particular they may have atoms.
  • I⊆[m]I \subseteq [m]I⊆[m] is a set of indices such that νj=μ\nu_j = \muνj​=μ for every j∈Ij \in Ij∈I. Indices outside III have arbitrary laws νj\nu_jνj​.

The probability space. The sample space is Rn×Rm\mathbb{R}^n \times \mathbb{R}^mRn×Rm, with points ω=(s,t)\omega = (s, t)ω=(s,t), where s=(s0,…,sn−1)s = (s_0, \dots, s_{n-1})s=(s0​,…,sn−1​) are the calibration scores and t=(t0,…,tm−1)t = (t_0, \dots, t_{m-1})t=(t0​,…,tm−1​) are the test scores. It carries the product measure

P  =  μ⊗n⊗(ν0⊗⋯⊗νm−1).P \;=\; \mu^{\otimes n} \otimes \bigl(\nu_0 \otimes \cdots \otimes \nu_{m-1}\bigr).P=μ⊗n⊗(ν0​⊗⋯⊗νm−1​).

So the sis_isi​ are i.i.d. with law μ\muμ, the tjt_jtj​ are independent with tj∼νjt_j \sim \nu_jtj​∼νj​, and all scores are mutually independent.

The random vector. On this space, define for each j∈[m]j \in [m]j∈[m]

Xj(s,t)  =  u^(tj)  =  1+#{ i∈[n]:si≤tj }n+1.X_j(s, t) \;=\; \hat u(t_j) \;=\; \frac{1 + \#\{\, i \in [n] : s_i \le t_j \,\}}{n+1}.Xj​(s,t)=u^(tj​)=n+11+#{i∈[n]:si​≤tj​}​.

Each XjX_jXj​ takes values in {1n+1,2n+1,…,1}\{\tfrac{1}{n+1}, \tfrac{2}{n+1}, \dots, 1\}{n+11​,n+12​,…,1}. All the XjX_jXj​ are built from the same calibration vector sss. When n=0n = 0n=0, every XjX_jXj​ is identically 111.

Conclusion. The vector X=(X0,…,Xm−1)X = (X_0, \dots, X_{m-1})X=(X0​,…,Xm−1​) is "PRDS on III" in the following precise sense. For every index i∈Ii \in Ii∈I, and every measurable set A⊆RmA \subseteq \mathbb{R}^mA⊆Rm that is an upper set, there exists a nondecreasing function f:R→Rf : \mathbb{R} \to \mathbb{R}f:R→R with

f(Xi(ω))  =  EP ⁣[1{X∈A} | σ(Xi)](ω)for P-almost every ω.f\bigl(X_i(\omega)\bigr) \;=\; \mathbb{E}_P\!\left[\mathbf{1}\{X \in A\} \,\middle|\, \sigma(X_i)\right](\omega) \quad \text{for } P\text{-almost every } \omega.f(Xi​(ω))=EP​[1{X∈A}∣σ(Xi​)](ω)for P-almost every ω.

Here:

  • An upper set means: if x∈Ax \in Ax∈A and y∈Rmy \in \mathbb{R}^my∈Rm satisfies xk≤ykx_k \le y_kxk​≤yk​ for all kkk, then y∈Ay \in Ay∈A.
  • σ(Xi)\sigma(X_i)σ(Xi​) is the σ\sigmaσ-algebra on Rn×Rm\mathbb{R}^n \times \mathbb{R}^mRn×Rm generated by the single coordinate XiX_iXi​.
  • fff is not required to be measurable or bounded. It is only required to be monotone nondecreasing and to give a version of the conditional probability of {X∈A}\{X \in A\}{X∈A} given XiX_iXi​.

Edge cases.

  • If m=0m = 0m=0 or I=∅I = \emptysetI=∅, there is no index i∈Ii \in Ii∈I to check, and the statement holds vacuously.
  • When n=0n = 0n=0, each XiX_iXi​ is constant. The conditional expectation is then a.e. the constant P(X∈A)P(X \in A)P(X∈A), which is either 000 or 111, and a constant fff suffices.
  • The atomlessness hypothesis applies only to μ\muμ, the common law of the calibration scores and of the test scores indexed by III. It does not apply to the laws νj\nu_jνj​ with j∉Ij \notin Ij∈/I.
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