Experimentation.Sequential
The anytime-valid inference substrate for adaptive / sequential experiments, where the treatment-assignment rule evolves with the accumulating data.
Ville 2 core · 2 supporting Ville's inequality gives time-uniform control for nonnegative test supermartingales. ★ IsTestSupermartingale★ ville_inequality
Ville inequality
Ville's inequality gives time-uniform control for nonnegative test supermartingales.
The predicate IsTestSupermartingale packages a nonnegative supermartingale with initial expected
wealth at most one. The theorem supermartingale_maximal_ineq proves the finite-horizon maximal
bound, ville_inequality passes to the event of ever crossing a positive level, and ville_test
specializes the result to the 1/α threshold used by anytime-valid tests.
A test supermartingale for a null hypothesis: a nonnegative supermartingale adapted to the data filtration whose initial expected value is at most one. It is the wealth process of a bet against the null that cannot grow in expectation under it.
Definition (Lean source)
Ville's inequality (time-uniform maximal inequality). If M is a supermartingale adapted to the filtration ℱ under the finite measure μ, M is everywhere nonnegative, and the level λ is positive, then the probability that M ever reaches λ is at most E[M₀] / λ, the bound taken over the event of reaching the boundary at some finite time.
Formal statement
Proof (Lean source)
2 supporting declarations (lemmas, instances)
-
supermartingale_maximal_ineqtheorem — Finite-horizon supermartingale maximal inequality. For a nonnegative supermartingale M and level λ > 0, the probability that M reaches λ by time n is at most E[M₀] / λ.hypothesesconclusion≤ ofReal (μ[M 0] / lam)Proof (Lean source)
theorem supermartingale_maximal_ineq [IsFiniteMeasure μ] {M : ℕ → Ω → ℝ} (hM : Supermartingale M ℱ μ) (hnonneg : ∀ n, 0 ≤ M n) {lam : ℝ} (hlam : 0 < lam) (n : ℕ) : μ {ω | lam ≤ (range (n + 1)).sup' nonempty_range_add_one (fun k => M k ω)} ≤ ofReal (μ[M 0] / lam) := by classical let τ : Ω → ℕ∞ := fun ω => (hittingBtwn M {y : ℝ | lam ≤ y} (0 : ℕ) n ω : ℕ) let A : Set Ω := {ω | lam ≤ (range (n + 1)).sup' nonempty_range_add_one (fun k => M k ω)} have hAmeas : MeasurableSet A := by exact measurableSet_le measurable_const (Finset.measurable_range_sup'' fun k _ => (hM.1.stronglyMeasurable (i := k)).measurable) have hτstop : IsStoppingTime ℱ τ := by exact hM.stronglyAdapted.adapted.isStoppingTime_hittingBtwn measurableSet_Ici have hτbdd : ∀ ω, τ ω ≤ n := by intro ω simpa [τ] using (show (((hittingBtwn M {y : ℝ | lam ≤ y} (0 : ℕ) n ω : ℕ) : ℕ∞) ≤ (n : ℕ∞)) from by exact WithTop.coe_le_coe.2 (hittingBtwn_le (u := M) (s := {y : ℝ | lam ≤ y}) (n := (0 : ℕ)) (m := n) (ω := ω))) have hτint : Integrable (stoppedValue M τ) μ := integrable_stoppedValue ℕ hτstop hM.2.2 hτbdd have hhit : ∀ ω ∈ A, lam ≤ stoppedValue M τ ω := by intro ω hω simp_rw [A, Set.mem_setOf_eq, Finset.le_sup'_iff, Finset.mem_range, Nat.lt_succ_iff] at hω refine stoppedValue_hittingBtwn_mem ?_ simpa only [Set.mem_setOf_eq, Set.mem_Icc, zero_le, true_and] using hω have hsetLower : lam * (μ A).toReal ≤ ∫ ω in A, stoppedValue M τ ω ∂μ := setIntegral_ge_of_const_le_real hAmeas (measure_ne_top _ _) hhit hτint.integrableOn have hstopped_nonneg : 0 ≤ stoppedValue M τ := by intro ω exact hnonneg _ ω have hset_le_total : ∫ ω in A, stoppedValue M τ ω ∂μ ≤ μ[stoppedValue M τ] := by have hcompl_nonneg : 0 ≤ ∫ ω in Aᶜ, stoppedValue M τ ω ∂μ := setIntegral_nonneg hAmeas.compl fun ω _ => hstopped_nonneg ω have hadd := integral_add_compl hAmeas hτint linarith have hτ_le_M0 : μ[stoppedValue M τ] ≤ μ[M 0] := by have hneg : Submartingale (fun k ω => -M k ω) ℱ μ := hM.neg have hopt : μ[stoppedValue (fun k ω => -M k ω) (fun _ : Ω => ((0 : ℕ) : ℕ∞))] ≤ μ[stoppedValue (fun k ω => -M k ω) τ] := by refine hneg.expected_stoppedValue_mono (isStoppingTime_const ℱ 0) hτstop ?_ hτbdd intro ω simp [τ] have hleft : μ[stoppedValue (fun k ω => -M k ω) (fun _ : Ω => ((0 : ℕ) : ℕ∞))] = - μ[M 0] := by rw [show stoppedValue (fun k ω => -M k ω) (fun _ : Ω => ((0 : ℕ) : ℕ∞)) = fun ω => -M 0 ω by funext ω simp only [stoppedValue] rfl] exact integral_neg (M 0) have hright : μ[stoppedValue (fun k ω => -M k ω) τ] = - μ[stoppedValue M τ] := by rw [show stoppedValue (fun k ω => -M k ω) τ = fun ω => - stoppedValue M τ ω by funext ω simp [stoppedValue]] exact integral_neg (stoppedValue M τ) rw [hleft, hright] at hopt linarith have hmul : lam * (μ A).toReal ≤ μ[M 0] := hsetLower.trans (hset_le_total.trans hτ_le_M0) have hM0_nonneg : 0 ≤ μ[M 0] := integral_nonneg (hnonneg 0) have hdiv_nonneg : 0 ≤ μ[M 0] / lam := div_nonneg hM0_nonneg hlam.le change μ A ≤ ofReal (μ[M 0] / lam) rw [ENNReal.le_ofReal_iff_toReal_le (measure_ne_top _ _) hdiv_nonneg] exact (le_div_iff₀ hlam).2 (by simpa [mul_comm] using hmul) -
ville_testtheorem — Ville's inequality for a test supermartingale: the chance of ever reaching 1/α is at most α.hypothesesconclusionμ {ω | ∃ n, 1 / α ≤ M n ω} ≤ ofReal αProof (Lean source)
theorem ville_test [IsFiniteMeasure μ] {M : ℕ → Ω → ℝ} (hM : IsTestSupermartingale M ℱ μ) {α : ℝ} (hα : 0 < α) : μ {ω | ∃ n, 1 / α ≤ M n ω} ≤ ofReal α := by obtain ⟨hsuper, hnn, hM0⟩ := hM have hlam : (0 : ℝ) < 1 / α := by positivity refine le_trans (ville_inequality hsuper hnn hlam) ?_ apply ENNReal.ofReal_le_ofReal rw [div_div_eq_mul_div, div_one] calc μ[M 0] * α ≤ 1 * α := mul_le_mul_of_nonneg_right hM0 hα.le _ = α := one_mul α
AdaptiveDesign 3 core · 0 supporting Adaptive experiments use assignment probabilities that are predictable from the pre-assignment history: the time-zero propensity is initial-information measurable, and the time-t + 1 propensity is measurable from the inf ★ AdaptiveExperiment★ propensity_pos_of_overlap
Adaptive sequential designs
Adaptive experiments use assignment probabilities that are predictable from the pre-assignment
history: the time-zero propensity is initial-information measurable, and the time-t + 1
propensity is measurable from the information available at time t.
The structure AdaptiveExperiment packages the filtration and predictable propensity process,
while AdaptiveExperiment.HasOverlap records the positivity margin δ ≤ propensity t ω ≤ 1 - δ
needed for inverse-propensity weighting. The lemma propensity_pos_of_overlap extracts strict
positivity from that overlap condition.
An adaptive sequential experiment: a time-indexed information flow ℱ on the outcome space together with a propensity process propensity recording the treatment probability of the unit arriving at each time, subject to three conditions — the process is predictable: the time-0 propensity is measurable with respect to the initial information, and the time-(t+1) propensity depends only on the information available at time t, every propensity is nonnegative, and every propensity is at most one.
Definition (Lean source)
The experiment satisfies overlap with margin δ when every propensity stays at least δ away from the boundary: δ ≤ propensity t ω ≤ 1 − δ. This is the positivity condition that makes inverse-propensity weighting (and hence the martingale construction underlying valid inference) well-behaved.
Definition (Lean source)
Under overlap with margin δ, every propensity is at least δ, hence strictly positive — so inverse-propensity weights are finite.
Formal statement
Proof (Lean source)
AnytimeValid 6 core · 0 supporting This file turns Ville's inequality for test supermartingales into reusable sequential-inference objects. ★ IsAnytimeValid★ isAnytimeValid_rejectionRegion★ IsConfidenceSequence★ isConfidenceSequence_confSeqOfWealth
Anytime-valid tests and confidence sequences
This file turns Ville's inequality for test supermartingales into reusable sequential-inference
objects. rejectionRegion is the event that wealth ever crosses 1/α, IsAnytimeValid states
level-α type-I error control, and isAnytimeValid_rejectionRegion proves that control from
Ville's inequality. The confidence-sequence side defines IsConfidenceSequence,
confSeqOfWealth, and isConfidenceSequence_confSeqOfWealth, the inverted coverage theorem.
The rejection region of the sequential test driven by wealth M at level α: the test rejects on the event that M ever reaches 1/α.
Definition (Lean source)
A rejection region is anytime-valid at level α under μ when its probability is at most α.
Definition (Lean source)
Anytime-valid type-I error control. If the wealth process M is a test supermartingale for the filtration ℱ under μ and the level α is positive, then the event that M ever reaches 1/α has probability at most α.
Formal statement
Proof (Lean source)
A predicate cover : ℕ → Ω → Prop (with cover n ω meaning "the target lies in the time-n set on outcome ω") is a confidence sequence at level α when the miscoverage probability — that the cover ever fails — is at most α.
Definition (Lean source)
The wealth-based cover predicate obtained by inversion. At time n, the cover holds exactly when the wealth M n has not yet reached 1/α.
Definition (Lean source)
Confidence-sequence coverage. If M is a test supermartingale for the filtration ℱ under μ and the level α is positive, then the cover obtained by requiring M's wealth to stay below 1/α fails at some time with probability at most α.