Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Proposition 3: fixed sequence testing controls FWER

Proved
LearnThenTest.fixed_sequence_controls_fwer

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

distribution-free-inferencefamily-wise-error-ratemultiple-testingp-valuesrisk-control

Let δ∈(0,1)\delta\in(0,1)δ∈(0,1) and let J⊆{1,…,N}\mathcal J\subseteq\{1,\dots,N\}J⊆{1,…,N} be a set of initializations. Fixed sequence testing (Algorithm 1) runs as follows. For each j∈Jj\in\mathcal Jj∈J not already rejected, it rejects j,j+1,…j,j+1,\dotsj,j+1,… for as long as the current p-value is at most δ/∣J∣\delta/|\mathcal J|δ/∣J∣, and it stops at the first acceptance or at index NNN. This procedure is an FWER-controlling algorithm at level δ\deltaδ in the sense of Definition 2.

Single-start fixed sequence testing (∣J∣=1|\mathcal J|=1∣J∣=1) needs no multiplicity correction. It is the procedure the paper recommends when the risk is nearly monotone in λ\lambdaλ.

Formalization Note The while loop of Algorithm 1 is stopped at the last index NNN, where the printed loop would read the undefined pN+1p_{N+1}pN+1​. Initializations are visited in increasing order.

Preamble
import Mathlib
import Definitions.Def_LearnThenTest_Basic

open MeasureTheory ProbabilityTheory Filter
Formal statement
namespace LearnThenTest

theorem fixed_sequence_controls_fwer (N : ℕ) (δ : ℝ) (hδ : 0 < δ ∧ δ < 1)
    (J : Finset (Fin N)) : IsFWERControlling N δ (fixedSeq N δ J) := by sorry

end LearnThenTest
Source
Angelopoulos, Bates, Candès, Jordan and Lei, Learn then Test: Calibrating Predictive Algorithms to Achieve Risk Control, arXiv:2110.01052v5 (2022), Section 2.3.1, Algorithm 1 and Proposition 3, p. 5; proof in Appendix C, p. 22
Read-back

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

Setting. Fix a natural number NNN, a real number δ\deltaδ with 0<δ<10 < \delta < 10<δ<1, and a set J⊆{0,1,…,N−1}J \subseteq \{0, 1, \dots, N-1\}J⊆{0,1,…,N−1} of indices, called the initializations. JJJ may be empty, and NNN may be 000. Indices are ordered in the usual way, 0<1<⋯<N−10 < 1 < \dots < N-10<1<⋯<N−1. A point x=(x0,…,xN−1)∈RNx = (x_0, \dots, x_{N-1}) \in \mathbb{R}^Nx=(x0​,…,xN−1​)∈RN is read as a vector of p-values.

The rejection rule AAA (fixed sequence testing). Let m=∣J∣m = |J|m=∣J∣ and set the threshold τ=δ/m\tau = \delta / mτ=δ/m. When J=∅J = \emptysetJ=∅ the threshold is the junk value 000, but it is never used.

For each index jjj, define the chain starting at jjj:

Cj(x)={ i∈{0,…,N−1}:i≥j and xk≤τ for every k with j≤k≤i }.C_j(x) = \{\, i \in \{0,\dots,N-1\} : i \ge j \text{ and } x_k \le \tau \text{ for every } k \text{ with } j \le k \le i \,\}.Cj​(x)={i∈{0,…,N−1}:i≥j and xk​≤τ for every k with j≤k≤i}.

This is the run of consecutive indices j,j+1,…j, j+1, \dotsj,j+1,… whose p-values are all at most τ\tauτ. It stops just before the first index whose p-value exceeds τ\tauτ, or at N−1N-1N−1. It is empty if xj>τx_j > \tauxj​>τ.

Now list JJJ in increasing order as j1<j2<⋯<jmj_1 < j_2 < \dots < j_mj1​<j2​<⋯<jm​ and compute A(x)A(x)A(x) as follows:

  1. Start with S=∅S = \emptysetS=∅.
  2. For r=1,…,mr = 1, \dots, mr=1,…,m in turn:
    • if jr∈Sj_r \in Sjr​∈S, leave SSS unchanged;
    • otherwise replace SSS by S∪Cjr(x)S \cup C_{j_r}(x)S∪Cjr​​(x).
  3. The output A(x)A(x)A(x) is the final SSS, a set of indices.

If J=∅J = \emptysetJ=∅, then A(x)=∅A(x) = \emptysetA(x)=∅ for every xxx.

What is asserted. The theorem states that, for every such NNN, δ\deltaδ and JJJ, the rule AAA is FWER-controlling at level δ\deltaδ. By definition, this is the conjunction of two claims.

  1. Measurability. For every index jjj, the set {x∈RN:j∈A(x)}\{x \in \mathbb{R}^N : j \in A(x)\}{x∈RN:j∈A(x)} is a Borel-measurable subset of RN\mathbb{R}^NRN.

  2. Error control. Suppose the following hold:

    • μ\muμ is any probability measure on RN\mathbb{R}^NRN, with arbitrary dependence between coordinates;
    • J0⊆{0,…,N−1}J_0 \subseteq \{0,\dots,N-1\}J0​⊆{0,…,N−1} is any index set, with no relation to JJJ required;
    • μ\muμ-almost every xxx has all coordinates in [0,1][0,1][0,1];
    • for each j∈J0j \in J_0j∈J0​, the coordinate xjx_jxj​ is a valid p-value under μ\muμ, meaning
μ({x:xj≤u})≤ufor every u∈[0,1].\mu(\{x : x_j \le u\}) \le u \quad \text{for every } u \in [0,1].μ({x:xj​≤u})≤ufor every u∈[0,1].

Then

μ({x:A(x)⊆{0,…,N−1}∖J0})  ≥  1−δ,\mu\big(\{x : A(x) \subseteq \{0,\dots,N-1\} \setminus J_0\}\big) \;\ge\; 1 - \delta,μ({x:A(x)⊆{0,…,N−1}∖J0​})≥1−δ,

that is, with μ\muμ-probability at least 1−δ1-\delta1−δ, A(x)A(x)A(x) contains no index of J0J_0J0​.

Remarks on scope.

  • No assumption is placed on the coordinates outside J0J_0J0​, beyond lying almost surely in [0,1][0,1][0,1].
  • "True nulls" enter only as the index set J0J_0J0​ together with the validity condition on its coordinates.
  • Since δ<1\delta < 1δ<1, the bound 1−δ1-\delta1−δ is a positive number.
  • When N=0N = 0N=0, J=∅J = \emptysetJ=∅, or J0=∅J_0 = \emptysetJ0​=∅, the event in claim 2 holds for every xxx, so its probability is 111.
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