Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Proposition 3 (as proved): simultaneous confidence bound for the FPR

Proved
ConformalOutlierTesting.fpr_simultaneous_bound

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

conformal-inferencefalse-discovery-ratemultiple-testingoutlier-detectionprds

Let Z1,…,ZnZ_1,\dots,Z_nZ1​,…,Zn​ be i.i.d. with law μ\muμ on R\mathbb RR and cumulative distribution function FFF. Let b0=0≤b1≤⋯≤bn≤bn+1=1b_0=0\le b_1\le\dots\le b_n\le b_{n+1}=1b0​=0≤b1​≤⋯≤bn​≤bn+1​=1 satisfy the band condition of Theorem 4 at level δ∈(0,1)\delta\in(0,1)δ∈(0,1). Then

P[F(z)≤b∣{j:Zj≤z}∣+1  for all z∈R]≥1−δ.\mathbb P\Big[F(z)\le b_{|\{j:Z_j\le z\}|+1}\ \text{ for all }z\in\mathbb R\Big]\ge1-\delta.P[F(z)≤b∣{j:Zj​≤z}∣+1​  for all z∈R]≥1−δ.

Equivalently, F(z)≤h(F^n(z))F(z)\le h(\hat F_n(z))F(z)≤h(F^n​(z)) wherever F^n(z)>0\hat F_n(z)>0F^n​(z)>0, and F(z)≤b1F(z)\le b_1F(z)≤b1​ for z<Z(1)z<Z_{(1)}z<Z(1)​, where h(t)=b⌈(n+1)t⌉h(t)=b_{\lceil(n+1)t\rceil}h(t)=b⌈(n+1)t⌉​ and F^n\hat F_nF^n​ is the empirical distribution function. Applied to the scores of a one-class classifier, this gives a uniform upper confidence bound for its false positive rate as a function of the threshold.

Formalization Note The paper states P[F(z)≤h(F^n(z)) ∀z]≥1−δ\mathbb P[F(z)\le h(\hat F_n(z))\ \forall z]\ge1-\deltaP[F(z)≤h(F^n​(z)) ∀z]≥1−δ with hhh as in Theorem 4. Since h(0)=b0=0h(0)=b_0=0h(0)=b0​=0, that would need F(z)=0F(z)=0F(z)=0 for every z<Z(1)z<Z_{(1)}z<Z(1)​, which fails with probability one for continuous FFF. The proof uses h(i/n)=bi+1h(i/n)=b_{i+1}h(i/n)=bi+1​, which holds for i≥1i\ge1i≥1 but not for i=0i=0i=0. What the proof establishes is the bound by bnF^n(z)+1b_{n\hat F_n(z)+1}bnF^n​(z)+1​ stated here. It holds for any law μ\muμ, as the paper's "some distribution" allows.

Preamble
import Mathlib
import Definitions.Def_ConformalOutlierTesting_Basic

open MeasureTheory ProbabilityTheory Filter Topology Set BoundedContinuousFunction
Formal statement
namespace ConformalOutlierTesting

theorem fpr_simultaneous_bound {n : ℕ} (μ : Measure ℝ) [IsProbabilityMeasure μ]
    (δ : ℝ) (hδ0 : 0 < δ) (hδ1 : δ < 1) (b : ℕ → ℝ) (hb : IsCCVSequence n δ b) :
    ENNReal.ofReal (1 - δ) ≤ (Measure.pi fun _ : Fin n => μ)
      {z | ∀ x : ℝ, cdf μ x ≤ b ((Finset.univ.filter fun j => z j ≤ x).card + 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 4.1, Proposition 3, eq. (21), p. 17; proof in Appendix A.6, p. 46
Read-back

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

Setting. Fix:

  • a natural number n≥0n \ge 0n≥0, the number of calibration scores;
  • a probability measure μ\muμ on R\mathbb{R}R, with cumulative distribution function
Fμ(x)=μ((−∞,x]),x∈R;F_\mu(x) = \mu\big((-\infty, x]\big), \qquad x \in \mathbb{R};Fμ​(x)=μ((−∞,x]),x∈R;
  • a real number δ\deltaδ with 0<δ<10 < \delta < 10<δ<1 (strict on both sides);
  • a sequence b=(b0,b1,b2,… )b = (b_0, b_1, b_2, \dots)b=(b0​,b1​,b2​,…) of real numbers indexed by all naturals i≥0i \ge 0i≥0.

Hypothesis on bbb. The sequence bbb must satisfy all of the following:

  • b0=0b_0 = 0b0​=0 and bn+1=1b_{n+1} = 1bn+1​=1;
  • 0≤bi≤10 \le b_i \le 10≤bi​≤1 for every 1≤i≤n1 \le i \le n1≤i≤n;
  • bi≤bi+1b_i \le b_{i+1}bi​≤bi+1​ for every 1≤i<n1 \le i < n1≤i<n. This makes b1≤⋯≤bnb_1 \le \dots \le b_nb1​≤⋯≤bn​; it does not separately require bn≤bn+1b_n \le b_{n+1}bn​≤bn+1​, although that follows from bn≤1=bn+1b_n \le 1 = b_{n+1}bn​≤1=bn+1​.
  • Let U1,…,UnU_1, \dots, U_nU1​,…,Un​ be i.i.d. with law Lebesgue measure restricted to [0,1][0,1][0,1], and let U(1)≤⋯≤U(n)U_{(1)} \le \dots \le U_{(n)}U(1)​≤⋯≤U(n)​ be their ascending order statistics. Then
P[ U(k)≤bk for all k=1,…,n ]  ≥  1−δ.\mathbb{P}\big[\,U_{(k)} \le b_k \text{ for all } k = 1, \dots, n\,\big] \;\ge\; 1 - \delta.P[U(k)​≤bk​ for all k=1,…,n]≥1−δ.

Values bib_ibi​ with i>n+1i > n+1i>n+1 are unconstrained, and none of them enters the conclusion.

Conclusion. Let Z=(Z1,…,Zn)Z = (Z_1, \dots, Z_n)Z=(Z1​,…,Zn​) have law μ⊗n\mu^{\otimes n}μ⊗n, so the ZjZ_jZj​ are i.i.d. with law μ\muμ. For x∈Rx \in \mathbb{R}x∈R, write

NZ(x)=∣{ j∈{1,…,n}:Zj≤x }∣N_Z(x) = \big|\{\, j \in \{1,\dots,n\} : Z_j \le x \,\}\big|NZ​(x)=​{j∈{1,…,n}:Zj​≤x}​

for the number of coordinates at most xxx. The theorem asserts

μ⊗n({ z∈Rn:Fμ(x)≤bNz(x)+1 for every x∈R })  ≥  1−δ.\mu^{\otimes n}\Big(\big\{\, z \in \mathbb{R}^n : F_\mu(x) \le b_{N_z(x)+1} \ \text{for every } x \in \mathbb{R} \,\big\}\Big) \;\ge\; 1 - \delta.μ⊗n({z∈Rn:Fμ​(x)≤bNz​(x)+1​ for every x∈R})≥1−δ.

In words: with probability at least 1−δ1-\delta1−δ, simultaneously for all real xxx, the true CDF value Fμ(x)F_\mu(x)Fμ​(x) is at most bNZ(x)+1b_{N_Z(x)+1}bNZ​(x)+1​.

Some features of this statement:

  • The index NZ(x)+1N_Z(x)+1NZ​(x)+1 ranges over {1,…,n+1}\{1, \dots, n+1\}{1,…,n+1}, so b0b_0b0​ never appears.
  • When NZ(x)=nN_Z(x) = nNZ​(x)=n, the bound reads Fμ(x)≤bn+1=1F_\mu(x) \le b_{n+1} = 1Fμ​(x)≤bn+1​=1, which always holds.
  • The inequality between Fμ(x)F_\mu(x)Fμ​(x) and bNZ(x)+1b_{N_Z(x)+1}bNZ​(x)+1​ is non-strict.
  • No continuity or atomlessness assumption is made on μ\muμ; ties among the ZjZ_jZj​ are allowed.

Measurability. Both probabilities above are evaluated on sets whose measurability is not asserted. If such a set is not measurable, the value is the outer measure. Both comparisons are made in [0,∞][0,\infty][0,∞], with 1−δ∈(0,1)1-\delta \in (0,1)1−δ∈(0,1).

Degenerate case n=0n = 0n=0. Here R0\mathbb{R}^0R0 is a single point carrying mass 111. The hypothesis reduces to b0=0b_0 = 0b0​=0 and b1=1b_1 = 1b1​=1; the probability condition holds automatically because that probability is 111. The conclusion reduces to Fμ(x)≤b1=1F_\mu(x) \le b_1 = 1Fμ​(x)≤b1​=1 for all xxx, which holds with probability 1≥1−δ1 \ge 1 - \delta1≥1−δ.

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