Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Proposition 1: the pointwise FPR has a Beta distribution

Proved
ConformalOutlierTesting.fpr_beta_distribution

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μ, and let the nnn calibration scores be i.i.d. with law μ\muμ. Let α<1\alpha<1α<1 with ℓ=⌊(n+1)α⌋≥1\ell=\lfloor(n+1)\alpha\rfloor\ge1ℓ=⌊(n+1)α⌋≥1. Then the conditional false positive rate

FPR(α;D)=P[u^(marg)(X2n+1)≤α∣D]\mathrm{FPR}(\alpha;\mathcal D)=\mathbb P\big[\hat u^{(\mathrm{marg})}(X_{2n+1})\le\alpha\mid\mathcal D\big]FPR(α;D)=P[u^(marg)(X2n+1​)≤α∣D]

follows the Beta(ℓ, n+1−ℓ)\mathrm{Beta}(\ell,\,n+1-\ell)Beta(ℓ,n+1−ℓ) distribution.

Its mean is ℓ/(n+1)≤α\ell/(n+1)\le\alphaℓ/(n+1)≤α, but it exceeds α\alphaα with non-negligible probability.

Formalization Note The paper does not restrict α\alphaα. For α<1/(n+1)\alpha<1/(n+1)α<1/(n+1) one has ℓ=0\ell=0ℓ=0, and Beta(0,n+1)\mathrm{Beta}(0,n+1)Beta(0,n+1) is not a distribution (the FPR is then 000). For α≥1\alpha\ge1α≥1 the second parameter is not positive. The hypotheses ℓ≥1\ell\ge1ℓ≥1 and α<1\alpha<1α<1 exclude these cases.

Preamble
import Mathlib
import Definitions.Def_ConformalOutlierTesting_Basic

open MeasureTheory ProbabilityTheory Filter Topology Set BoundedContinuousFunction
Formal statement
namespace ConformalOutlierTesting

theorem fpr_beta_distribution {n : ℕ} (μ : Measure ℝ) [IsProbabilityMeasure μ] [NullSingletonClass μ]
    (α : ℝ) (hα1 : α < 1) (hl : 1 ≤ ⌊((n : ℝ) + 1) * α⌋₊) :
    (Measure.pi fun _ : Fin n => μ).map (fun s => fpr μ s α) =
      betaMeasure (⌊((n : ℝ) + 1) * α⌋₊ : ℝ) ((n : ℝ) + 1 - ⌊((n : ℝ) + 1) * α⌋₊) := by sorry

end ConformalOutlierTesting
Source
Bates, Candès, Lei, Romano and Sesia, Testing for Outliers with Conformal p-values, arXiv:2104.08279v3 (2022), Section 3.1, Proposition 1, eq. (9), p. 8
Read-back

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

Setting. Fix a natural number nnn (the number of calibration scores) and a Borel probability measure μ\muμ on R\mathbb{R}R. The measure μ\muμ is assumed to have no atoms: μ({x})=0\mu(\{x\}) = 0μ({x})=0 for every x∈Rx \in \mathbb{R}x∈R. Fix a real number α\alphaα satisfying two hypotheses:

  • α<1\alpha < 1α<1;
  • 1≤ℓ1 \le \ell1≤ℓ, where
ℓ  :=  ⌊(n+1) α⌋N,\ell \;:=\; \big\lfloor (n+1)\,\alpha \big\rfloor_{\mathbb{N}},ℓ:=⌊(n+1)α⌋N​,

the natural-number floor (which returns 000 whenever (n+1)α<0(n+1)\alpha < 0(n+1)α<0).

Consequences of the hypotheses. Together these force:

  • (n+1)α≥1(n+1)\alpha \ge 1(n+1)α≥1, so α≥1n+1>0\alpha \ge \tfrac{1}{n+1} > 0α≥n+11​>0;
  • n≥1n \ge 1n≥1, because for n=0n = 0n=0 the floor of α<1\alpha < 1α<1 is 000;
  • 1≤ℓ≤n1 \le \ell \le n1≤ℓ≤n, so both Beta parameters below are at least 111.

The marginal conformal p-value. For calibration scores s=(s1,…,sn)∈Rns = (s_1, \dots, s_n) \in \mathbb{R}^ns=(s1​,…,sn​)∈Rn and a point x∈Rx \in \mathbb{R}x∈R, define

u^(x;s)  =  1+#{ i:si≤x }n+1.\hat u(x; s) \;=\; \frac{1 + \#\{\, i : s_i \le x \,\}}{n+1}.u^(x;s)=n+11+#{i:si​≤x}​.

The false positive rate. As a function of sss, define

FPR(s)  =  μ({ x∈R:u^(x;s)≤α }),\mathrm{FPR}(s) \;=\; \mu\big(\{\, x \in \mathbb{R} : \hat u(x; s) \le \alpha \,\}\big),FPR(s)=μ({x∈R:u^(x;s)≤α}),

a real number in [0,1][0,1][0,1]. This is the μ\muμ-probability that a fresh point drawn from μ\muμ receives a p-value at most α\alphaα, with sss held fixed.

Claim. Let s1,…,sns_1, \dots, s_ns1​,…,sn​ be i.i.d. with law μ\muμ, so that sss has the product law μ⊗n\mu^{\otimes n}μ⊗n on Rn\mathbb{R}^nRn. The theorem asserts that the image (pushforward) of μ⊗n\mu^{\otimes n}μ⊗n under the map s↦FPR(s)s \mapsto \mathrm{FPR}(s)s↦FPR(s) is exactly the Beta distribution

(μ⊗n)∘FPR−1  =  Beta(ℓ,  n+1−ℓ).\big(\mu^{\otimes n}\big)\circ \mathrm{FPR}^{-1} \;=\; \mathrm{Beta}\big(\ell,\; n + 1 - \ell\big).(μ⊗n)∘FPR−1=Beta(ℓ,n+1−ℓ).

Here Beta(a,b)\mathrm{Beta}(a, b)Beta(a,b) is the probability measure on R\mathbb{R}R with density

xa−1(1−x)b−1B(a,b)\frac{x^{a-1}(1-x)^{b-1}}{B(a,b)}B(a,b)xa−1(1−x)b−1​

on (0,1)(0,1)(0,1) and density 000 elsewhere.

Convention for non-measurable maps. The pushforward is taken with the convention that it is the zero measure if s↦FPR(s)s \mapsto \mathrm{FPR}(s)s↦FPR(s) fails to be almost-everywhere measurable with respect to μ⊗n\mu^{\otimes n}μ⊗n. The asserted equality with a probability measure therefore also implicitly asserts that this map is a.e. measurable.

What is not assumed. No further assumptions are made on μ\muμ (no density or continuity beyond having no atoms). No assumption is made on α\alphaα beyond the two hypotheses above, and (n+1)α(n+1)\alpha(n+1)α need not be an integer.

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