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.

def IsTestSupermartingale reviewed
Causalean.Experimentation.Sequential

Given a sample space, a σ-algebra on that space, a real-valued process indexed by nonnegative integer times, a filtration on that σ-algebra, and a measure on that measurable space, a test supermartingale is a supermartingale adapted to that filtration whose value is nonnegative at every time and sample point and whose expected initial value is at most one.

Definition (Lean source)
Ω :
Type u_1
shared
M :
ℕ → Ω → ℝ
:
Filtration ℕ m0
μ :
IsTestSupermartingale M ℱ μ :
Prop
clause 1
clause 2
n :
0 ≤ M n
clause 3
μ[M 0] ≤ 1
Causalean.Experimentation.Sequential.IsTestSupermartingale · Causalean/Experimentation/Sequential/Ville.lean:45
theorem ville_inequality reviewed
Causalean.Experimentation.Sequential

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
Ω :
shared
:
Filtration ℕ m0
shared
M :
ℕ → Ω → ℝ
hM :
hnonneg :
∀ n, 0 ≤ M n
lam :
hlam :
0 < lam
μ {ω | ∃ n, lam ≤ M n ω} ≤ ofReal (μ[M 0] / lam)
Proof (Lean source)
theorem ville_inequality [IsFiniteMeasure μ] {M : ℕ → Ω → ℝ} (hM : Supermartingale M ℱ μ) (hnonneg : ∀ n, 0 ≤ M n) {lam : ℝ} (hlam : 0 < lam) : μ {ω | ∃ n, lam ≤ M n ω} ≤ ofReal (μ[M 0] / lam) := by -- The "ever reaches lam" event is the increasing union of the finite-horizon events; apply the -- finite-horizon maximal inequality termwise. set A : ℕ → Set Ω := fun N => {ω | lam ≤ (range (N + 1)).sup' nonempty_range_add_one (fun k => M k ω)} with hA have hUnion : {ω | ∃ n, lam ≤ M n ω} = ⋃ N, A N := by ext ω simp only [hA, Set.mem_setOf_eq, Set.mem_iUnion] constructor · rintro ⟨n, hn⟩ exact ⟨n, Finset.le_sup'_of_le (f := fun k => M k ω) (Finset.self_mem_range_succ n) hn⟩ · rintro ⟨N, hN⟩ obtain ⟨k, _, hk⟩ := Finset.exists_mem_eq_sup' nonempty_range_add_one (fun k => M k ω) exact ⟨k, hN.trans hk.le⟩ have hmono : Monotone A := by intro a b hab ω hω simp only [hA, Set.mem_setOf_eq] at hω ⊢ have hsub : range (a + 1) ⊆ range (b + 1) := Finset.range_mono (Nat.succ_le_succ hab) exact le_trans hω (Finset.sup'_mono (fun k => M k ω) hsub nonempty_range_add_one) rw [hUnion, hmono.measure_iUnion] exact iSup_le (fun N => supermartingale_maximal_ineq hM hnonneg hlam N)
Causalean.Experimentation.Sequential.ville_inequality · Causalean/Experimentation/Sequential/Ville.lean:132
2 supporting declarations (lemmas, instances)
  • supermartingale_maximal_ineq theorem — 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₀] / λ.
    Ω :
    shared
    :
    Filtration ℕ m0
    shared
    M :
    ℕ → Ω → ℝ
    hM :
    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)
    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)
    Causalean.Experimentation.Sequential.supermartingale_maximal_ineq · Causalean/Experimentation/Sequential/Ville.lean:55
  • ville_test theorem — Ville's inequality for a test supermartingale: the chance of ever reaching 1/α is at most α.
    Ω :
    shared
    :
    Filtration ℕ m0
    shared
    M :
    ℕ → Ω → ℝ
    hM :
    α :
    :
    0 < α
    μ {ω | ∃ 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 α
    Causalean.Experimentation.Sequential.ville_test · Causalean/Experimentation/Sequential/Ville.lean:163
Adaptive­Design 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.

structure AdaptiveExperiment reviewed
Causalean.Experimentation.Sequential

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)
Ω :
Type*
m0 :
The data-collection filtration: time `t` represents the information available after observing the time-`t` history and before the next assignment is made.
:
Filtration ℕ m0
The propensity process: `propensity t ω` is the probability of treating the time-`t` unit on history `ω`.
propensity :
ℕ → Ω → ℝ
The propensity is predictable: `propensity 0` is initial-information measurable, and `propensity (t + 1)` is determined by the information available at time `t`.
propensity_predictable :
IsPredictable ℱ propensity
Propensities are nonnegative.
propensity_nonneg :
∀ t ω, 0 ≤ propensity t ω
Propensities are at most one.
propensity_le_one :
∀ t ω, propensity t ω ≤ 1
Causalean.Experimentation.Sequential.AdaptiveExperiment · Causalean/Experimentation/Sequential/AdaptiveDesign.lean:41
def HasOverlap reviewed
Causalean.Experimentation.Sequential.AdaptiveExperiment

For a measurable outcome space, an adaptive experiment on that space, and a real number serving as an overlap margin, the overlap condition with that margin holds precisely when the margin is strictly positive and at every time and on every outcome history, the experiment's treatment probability lies between the margin and one minus the margin.

Definition (Lean source)
Ω :
Type u_1
shared
E :
δ :
HasOverlap E δ :
Prop
clause 1
0 < δ
clause 2
t ω :
δ ≤ E.propensity t ω
E.propensity t ω ≤ 1 - δ
Causalean.Experimentation.Sequential.AdaptiveExperiment.HasOverlap · Causalean/Experimentation/Sequential/AdaptiveDesign.lean:67 · uses AdaptiveExperiment
lemma propensity_pos_of_overlap reviewed
Causalean.Experimentation.Sequential.AdaptiveExperiment

Under overlap with margin δ, every propensity is at least δ, hence strictly positive — so inverse-propensity weights are finite.

Formal statement
Ω :
shared
δ :
h :
E.HasOverlap δ
t :
ω :
Ω
0 < E.propensity t ω
Proof (Lean source)
lemma propensity_pos_of_overlap {E : AdaptiveExperiment Ω m0} {δ : ℝ} (h : E.HasOverlap δ) (t : ℕ) (ω : Ω) : 0 < E.propensity t ω := lt_of_lt_of_le h.1 (h.2 t ω).1
Causalean.Experimentation.Sequential.AdaptiveExperiment.propensity_pos_of_overlap · Causalean/Experimentation/Sequential/AdaptiveDesign.lean:78 · uses AdaptiveExperiment , HasOverlap
Anytime­Valid 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.

def rejectionRegion reviewed
Causalean.Experimentation.Sequential

For a sample space and a real-valued wealth process indexed by time and outcome, and a real-valued test level, the sequential-test rejection region is the event that the wealth reaches or exceeds 1/α1/α at at least one time, with this quotient understood as zero when α=0α=0.

Definition (Lean source)
Ω :
Type u_1
shared
M :
ℕ → Ω → ℝ
α :
rejectionRegion M α :
Set Ω
{ω | ∃ n, 1 / α ≤ M n ω}
Causalean.Experimentation.Sequential.rejectionRegion · Causalean/Experimentation/Sequential/AnytimeValid.lean:41
def IsAnytimeValid reviewed
Causalean.Experimentation.Sequential

For a measurable sample space, an event on that space, a measure on the sample space, and a real-valued test level, the property of being anytime-valid at that level means that the measure of the event is at most max{α,0}\max\{α,0\}.

Definition (Lean source)
Ω :
Type u_1
shared
R :
Set Ω
μ :
α :
IsAnytimeValid R μ α :
Prop
μ R ≤ ofReal α
Causalean.Experimentation.Sequential.IsAnytimeValid · Causalean/Experimentation/Sequential/AnytimeValid.lean:47
theorem isAnytimeValid_rejectionRegion reviewed
Causalean.Experimentation.Sequential

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
Ω :
shared
:
Filtration ℕ m0
shared
M :
ℕ → Ω → ℝ
hM :
α :
:
0 < α
Proof (Lean source)
theorem isAnytimeValid_rejectionRegion [IsFiniteMeasure μ] {M : ℕ → Ω → ℝ} (hM : IsTestSupermartingale M ℱ μ) {α : ℝ} (hα : 0 < α) : IsAnytimeValid (rejectionRegion M α) μ α := ville_test hM hα
Causalean.Experimentation.Sequential.isAnytimeValid_rejectionRegion · Causalean/Experimentation/Sequential/AnytimeValid.lean:53 · uses IsAnytimeValid , IsTestSupermartingale , rejectionRegion
def IsConfidenceSequence reviewed
Causalean.Experimentation.Sequential

For a measurable sample space, a time-indexed coverage predicate on that space, a measure on the sample space, and a real-valued level, the property of being a confidence sequence at that level means that the measure of outcomes on which coverage fails at at least one time is at most max{α,0}\max\{α,0\}.

Definition (Lean source)
Ω :
Type u_1
shared
cover :
ℕ → Ω → Prop
μ :
α :
IsConfidenceSequence cover μ α :
Prop
μ {ω | ∃ n, ¬ cover n ω} ≤ ofReal α
Causalean.Experimentation.Sequential.IsConfidenceSequence · Causalean/Experimentation/Sequential/AnytimeValid.lean:63
def confSeqOfWealth reviewed
Causalean.Experimentation.Sequential

For a sample space and a real-valued wealth process indexed by time and outcome and a real-valued level, the wealth-inverted coverage predicate holds at a given time and outcome exactly when the wealth at that time is strictly less than 1/α1/α, with this quotient understood as zero when α=0α=0.

Definition (Lean source)
Ω :
Type u_1
shared
M :
ℕ → Ω → ℝ
α :
confSeqOfWealth M α :
ℕ → Ω → Prop
fun n ω => M n ω < 1 / α
Causalean.Experimentation.Sequential.confSeqOfWealth · Causalean/Experimentation/Sequential/AnytimeValid.lean:70
theorem isConfidenceSequence_confSeqOfWealth reviewed
Causalean.Experimentation.Sequential

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 α.

Formal statement
Ω :
shared
:
Filtration ℕ m0
shared
M :
ℕ → Ω → ℝ
hM :
α :
:
0 < α
Proof (Lean source)
theorem isConfidenceSequence_confSeqOfWealth [IsFiniteMeasure μ] {M : ℕ → Ω → ℝ} (hM : IsTestSupermartingale M ℱ μ) {α : ℝ} (hα : 0 < α) : IsConfidenceSequence (confSeqOfWealth M α) μ α := by have hset : {ω | ∃ n, ¬ confSeqOfWealth M α n ω} = {ω | ∃ n, 1 / α ≤ M n ω} := by ext ω; simp only [confSeqOfWealth, Set.mem_setOf_eq, not_lt] rw [IsConfidenceSequence, hset] exact ville_test hM hα
Causalean.Experimentation.Sequential.isConfidenceSequence_confSeqOfWealth · Causalean/Experimentation/Sequential/AnytimeValid.lean:76 · uses IsConfidenceSequence , IsTestSupermartingale , confSeqOfWealth