Experimentation.Design­Based

The shared, paper-agnostic substrate for design-based / randomization inference under interference: the finite-population, fixed-potential-outcome flavor of the potential-outcomes framework, where probability comes from

Designs 17 core · 31 supporting · 6 submodules Canonical, paper-agnostic randomization designs with their inclusion probabilities computed once, ready to plug into the design-based estimation and optimality layers. Estimators 16 core · 3 supporting · 2 submodules Entry point for paper-agnostic estimators of finite-population causal estimands and their randomization properties. Finite­Population­CLT 23 core · 35 supporting · 8 submodules This module develops an explicit reveal martingale for a simple random sample without replacement. HT 11 core · 2 supporting · 3 submodules Horvitz-Thompson design-based estimators: totals, means, effects, unbiasedness, covariance formulas, and finite-population variance identities. Optimality 13 core · 11 supporting · 2 submodules This file treats a randomization design as the object being chosen from a finite family under an ordered risk criterion. Variance 2 core · 2 supporting · 1 submodule This namespace collects variance-estimation tools for finite design-based experiments.
In­Prob 5 core · 10 supporting Finite-design convergence in probability tracks vanishing assignment-tail probabilities along a sequence of randomization designs. ★ tendstoInProb_of_var★ tendstoInProb_div_one★ mul_boundedInProb

Convergence in probability for finite designs

Finite-design convergence in probability tracks vanishing assignment-tail probabilities along a sequence of randomization designs.

The predicate FiniteDesign.TendstoInProb states convergence of statistics X m to targets c m using the design probabilities of absolute-deviation events. The theorem tendstoInProb_of_var turns vanishing randomization variance into convergence to the design mean via Chebyshev's inequality. The closure result TendstoInProb.sub handles differences, and tendstoInProb_div_one is the Hájek/Slutsky ratio step for denominators converging in probability to one.

def TendstoInProb reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

For a sequence of finite assignment spaces, a sequence of finite randomization designs, a sequence of real-valued statistics, and a sequence of real-valued targets, the assertion of convergence in probability means that, for every positive ε\varepsilon, the probability that the statistic differs from its target by at least ε\varepsilon tends to zero as the sequence index tends to infinity.

Definition (Lean source)
Ω :
ℕ → Type u_1
shared
D :
∀ m, FiniteDesign (Ω m)
X :
∀ m
if
Ω m
then
ℝ
c :
ℕ → ℝ
ε :
ℝ
0 < ε
TendstoInProb D X c :
Prop
Tendsto (fun m => (D m).Pr (fun z => ε ≤ |X m z - c m|)) atTop (𝓝 0)
Causalean.Experimentation.DesignBased.FiniteDesign.TendstoInProb · Causalean/Experimentation/DesignBased/InProb.lean:56 · uses FiniteDesign
theorem tendstoInProb_of_var reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

Chebyshev consistency engine. Along a sequence of finite designs D, for statistics X, if the design variance of X m tends to zero as m → ∞, then X m converges in probability to its design mean E[X m].

Formal statement
Ω :
ℕ → Type u_1
shared
D :
∀ m, FiniteDesign (Ω m)
X :
∀ m
if
Ω m
then
ℝ
hvar :
Tendsto (fun m => (D m).Var (X m)) atTop (𝓝 0)
TendstoInProb D X (fun m => (D m).E (X m))
Proof (Lean source)
theorem tendstoInProb_of_var (D : ∀ m, FiniteDesign (Ω m)) (X : ∀ m, Ω m → ℝ) (hvar : Tendsto (fun m => (D m).Var (X m)) atTop (𝓝 0)) : TendstoInProb D X (fun m => (D m).E (X m)) := by intro ε hε have hε2 : (0 : ℝ) < ε ^ 2 := pow_pos hε 2 have hupper : Tendsto (fun m => (D m).Var (X m) / ε ^ 2) atTop (𝓝 0) := by simpa using hvar.div_const (ε ^ 2) refine squeeze_zero (fun m => ?_) (fun m => ?_) hupper · exact (D m).Pr_nonneg _ · exact (D m).chebyshev (X m) hε
Causalean.Experimentation.DesignBased.FiniteDesign.tendstoInProb_of_var · Causalean/Experimentation/DesignBased/InProb.lean:120 · uses FiniteDesign , E , TendstoInProb , Var
theorem tendstoInProb_div_one reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

Slutsky ratio step. Along a sequence of finite designs D, fix statistics X and Y. If X m converges in probability to a m, the denominator Y m converges in probability to 1, and the limit sequence a m is uniformly bounded by a constant M, then the ratio X m / Y m converges in probability to a m. (The realized normalizer tends to one, so dividing by it does not change the probability limit.)

Formal statement
Ω :
ℕ → Type u_1
shared
D :
∀ m, FiniteDesign (Ω m)
X Y :
∀ m
if
Ω m
then
ℝ
a :
ℕ → ℝ
M :
ℝ
ha :
∀ m, |a m| ≤ M
hX :
hY :
TendstoInProb D Y (fun _ => 1)
TendstoInProb D (fun m z => X m z / Y m z) a
Proof (Lean source)
theorem tendstoInProb_div_one (D : ∀ m, FiniteDesign (Ω m)) (X Y : ∀ m, Ω m → ℝ) (a : ℕ → ℝ) (M : ℝ) (ha : ∀ m, |a m| ≤ M) (hX : TendstoInProb D X a) (hY : TendstoInProb D Y (fun _ => 1)) : TendstoInProb D (fun m z => X m z / Y m z) a := by intro ε hε -- `M' := M + 1` is a strictly positive bound on `|a m|`, avoiding division by zero. set M' : ℝ := M + 1 with hM'def have hMnn : 0 ≤ M := le_trans (abs_nonneg _) (ha 0) have hM' : 0 < M' := by rw [hM'def]; linarith have haM' : ∀ m, |a m| ≤ M' := fun m => le_trans (ha m) (by rw [hM'def]; linarith) have hε4 : (0 : ℝ) < ε / 4 := by linarith have hε4M' : (0 : ℝ) < ε / (4 * M') := by positivity have hhalf : (0 : ℝ) < 1 / 2 := by norm_num -- Pointwise inclusion: the ratio-far event is contained in the union of three deviation events. have hbound : ∀ m, (D m).Pr (fun z => ε ≤ |X m z / Y m z - a m|) ≤ (D m).Pr (fun z => (1 : ℝ) / 2 ≤ |Y m z - 1|) + ((D m).Pr (fun z => ε / 4 ≤ |X m z - a m|) + (D m).Pr (fun z => ε / (4 * M') ≤ |Y m z - 1|)) := by intro m have hmono : (D m).Pr (fun z => ε ≤ |X m z / Y m z - a m|) ≤ (D m).Pr (fun z => ((1 : ℝ) / 2 ≤ |Y m z - 1|) ∨ ((ε / 4 ≤ |X m z - a m|) ∨ (ε / (4 * M') ≤ |Y m z - 1|))) := by apply (D m).Pr_mono intro z hz -- Split on whether the denominator is close to one. by_cases hYclose : (1 : ℝ) / 2 ≤ |Y m z - 1| · exact inl hYclose · push_neg at hYclose refine inr ?_ -- On `|Y - 1| < 1/2` we have `|Y| ≥ 1/2 > 0`. have hYlb : (1 : ℝ) / 2 ≤ |Y m z| := by have htri : |Y m z - 1| ≥ |1| - |Y m z| := by have := abs_sub_abs_le_abs_sub (1 : ℝ) (Y m z) rw [abs_sub_comm] at this simpa [abs_sub_comm] using this have h1 : |(1 : ℝ)| = 1 := by norm_num rw [h1] at htri linarith have hYpos : (0 : ℝ) < |Y m z| := lt_of_lt_of_le (by norm_num) hYlb have hYne : Y m z ≠ 0 := by intro h; rw [h] at hYpos; simp at hYpos -- `|X/Y - a| = |X - a·Y| / |Y| ≤ 2·|X - a·Y|`. have hratio : |X m z / Y m z - a m| = |X m z - a m * Y m z| / |Y m z| := by rw [← abs_div] congr 1 field_simp have hle2 : |X m z / Y m z - a m| ≤ 2 * |X m z - a m * Y m z| := by rw [hratio] rw [div_le_iff₀ hYpos] calc |X m z - a m * Y m z| = |X m z - a m * Y m z| * 1 := by ring _ ≤ |X m z - a m * Y m z| * (2 * |Y m z|) := by apply mul_le_mul_of_nonneg_left _ (abs_nonneg _) linarith _ = 2 * |X m z - a m * Y m z| * |Y m z| := by ring -- `|X - a·Y| ≤ |X - a| + |a|·|Y - 1|`. have hsplit : |X m z - a m * Y m z| ≤ |X m z - a m| + |a m| * |Y m z - 1| := by have heq : X m z - a m * Y m z = (X m z - a m) + a m * (1 - Y m z) := by ring calc |X m z - a m * Y m z| = |(X m z - a m) + a m * (1 - Y m z)| := by rw [heq] _ ≤ |X m z - a m| + |a m * (1 - Y m z)| := abs_add_le _ _ _ = |X m z - a m| + |a m| * |1 - Y m z| := by rw [abs_mul] _ = |X m z - a m| + |a m| * |Y m z - 1| := by rw [abs_sub_comm (1 : ℝ)] -- Combine: `ε ≤ |X/Y - a| ≤ 2|X-a| + 2M'|Y-1|`. have hcombine : ε ≤ 2 * |X m z - a m| + 2 * M' * |Y m z - 1| := by have haY : |a m| * |Y m z - 1| ≤ M' * |Y m z - 1| := mul_le_mul_of_nonneg_right (haM' m) (abs_nonneg _) have : ε ≤ 2 * (|X m z - a m| + |a m| * |Y m z - 1|) := le_trans hz (le_trans hle2 (by linarith [hsplit])) nlinarith [haY, abs_nonneg (Y m z - 1)] -- Hence one of the two half-bounds holds. by_contra hcon push_neg at hcon obtain ⟨h1, h2⟩ := hcon -- `2|X-a| < ε/2` and `2M'|Y-1| < ε/2`, contradicting `hcombine`. have hb1 : 2 * |X m z - a m| < ε / 2 := by linarith have hb2 : 2 * M' * |Y m z - 1| < ε / 2 := by have : |Y m z - 1| < ε / (4 * M') := h2 have h4M' : (0 : ℝ) < 4 * M' := by linarith rw [lt_div_iff₀ h4M'] at this nlinarith [this] linarith refine le_trans hmono ?_ refine le_trans ((D m).Pr_or_le _ _) ?_ have := (D m).Pr_or_le (fun z => ε / 4 ≤ |X m z - a m|) (fun z => ε / (4 * M') ≤ |Y m z - 1|) linarith [this] -- The upper bound tends to zero (three vanishing tails). have hupper : Tendsto (fun m => (D m).Pr (fun z => (1 : ℝ) / 2 ≤ |Y m z - 1|) + ((D m).Pr (fun z => ε / 4 ≤ |X m z - a m|) + (D m).Pr (fun z => ε / (4 * M') ≤ |Y m z - 1|))) atTop (𝓝 0) := by have t1 := hY (1 / 2) hhalf have t2 := hX (ε / 4) hε4 have t3 := hY (ε / (4 * M')) hε4M' have := t1.add (t2.add t3) simpa using this refine squeeze_zero (fun m => (D m).Pr_nonneg _) hbound hupper
Causalean.Experimentation.DesignBased.FiniteDesign.tendstoInProb_div_one · Causalean/Experimentation/DesignBased/InProb.lean:219 · uses FiniteDesign , TendstoInProb
def BoundedInProb reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

For a sequence of finite assignment spaces, a sequence of finite randomization designs, and a sequence of real-valued statistics, the assertion that the statistics are bounded in probability means that, for every positive tolerance, there is a real threshold such that, from some index onward, the probability that the statistic's absolute value is at least that threshold is at most the tolerance. This is the Op(1)O_p(1) counterpart of convergence in probability.

Definition (Lean source)
Ω :
ℕ → Type u_1
shared
D :
∀ m, FiniteDesign (Ω m)
X :
∀ m
if
Ω m
then
ℝ
η :
ℝ
0 < η
BoundedInProb D X :
Prop
∃ M : ℝ, ∀ᶠ m in atTop, (D m).Pr (fun z => M ≤ |X m z|) ≤ η
Causalean.Experimentation.DesignBased.FiniteDesign.BoundedInProb · Causalean/Experimentation/DesignBased/InProb.lean:324 · uses FiniteDesign
theorem mul_boundedInProb reviewed
Causalean.Experimentation.DesignBased.FiniteDesign.TendstoInProb

If one sequence converges to zero in probability and a second sequence is bounded in probability, then their product converges to zero in probability. This is the product-tightness principle that turns a vanishing factor times a bounded factor into a vanishing remainder.

Formal statement
Ω :
ℕ → Type u_1
∀ m, FiniteDesign (Ω m)
shared
U V :
∀ m
if
Ω m
then
ℝ
hU :
TendstoInProb D U (fun _ => 0)
hV :
TendstoInProb D (fun m z => U m z * V m z) (fun _ => 0)
Proof (Lean source)
theorem TendstoInProb.mul_boundedInProb {D : ∀ m, FiniteDesign (Ω m)} {U V : ∀ m, Ω m → ℝ} (hU : TendstoInProb D U (fun _ => 0)) (hV : BoundedInProb D V) : TendstoInProb D (fun m z => U m z * V m z) (fun _ => 0) := by intro ε hε simp only [sub_zero] apply tendsto_order.2 constructor · intro a ha filter_upwards [] with m exact lt_of_lt_of_le ha ((D m).Pr_nonneg _) · intro a ha have ha2 : (0 : ℝ) < a / 2 := by linarith obtain ⟨M, hM⟩ := hV (a / 2) ha2 set M' : ℝ := |M| + 1 with hM'def have hM' : 0 < M' := by rw [hM'def] positivity have hMle : M ≤ M' := by rw [hM'def] linarith [le_abs_self M] have hMbound : ∀ᶠ m in atTop, (D m).Pr (fun z => M' ≤ |V m z|) ≤ a / 2 := by filter_upwards [hM] with m hmm refine le_trans ?_ hmm apply (D m).Pr_mono intro z hz exact le_trans hMle hz have hbound : ∀ m, (D m).Pr (fun z => ε ≤ |U m z * V m z|) ≤ (D m).Pr (fun z => M' ≤ |V m z|) + (D m).Pr (fun z => ε / M' ≤ |U m z|) := by intro m refine le_trans ?_ (Pr_or_le (D m) _ _) apply (D m).Pr_mono intro z hz by_cases hVlarge : M' ≤ |V m z| · exact inl hVlarge · right push_neg at hVlarge rw [div_le_iff₀ hM'] rw [abs_mul] at hz have hUpos : 0 < |U m z| := by by_contra hUpos have hUzero : |U m z| = 0 := le_antisymm (le_of_not_gt hUpos) (abs_nonneg _) rw [hUzero, zero_mul] at hz linarith exact le_of_lt (lt_of_le_of_lt hz (mul_lt_mul_of_pos_left hVlarge hUpos)) have hU' : Tendsto (fun m => (D m).Pr (fun z => ε / M' ≤ |U m z|)) atTop (𝓝 0) := by have hεM' : (0 : ℝ) < ε / M' := by positivity simpa using hU (ε / M') hεM' have htail : ∀ᶠ m in atTop, (D m).Pr (fun z => ε / M' ≤ |U m z|) < a / 2 := (tendsto_order.mp hU').2 (a / 2) ha2 filter_upwards [htail, hMbound] with m hm hmb calc (D m).Pr (fun z => ε ≤ |U m z * V m z|) ≤ (D m).Pr (fun z => M' ≤ |V m z|) + (D m).Pr (fun z => ε / M' ≤ |U m z|) := hbound m _ < a := by linarith [hmb]
Causalean.Experimentation.DesignBased.FiniteDesign.TendstoInProb.mul_boundedInProb · Causalean/Experimentation/DesignBased/InProb.lean:428 · uses FiniteDesign , BoundedInProb , TendstoInProb
10 supporting declarations (lemmas, instances)
  • tendstoInProb_iff_tendstoInProbability theorem — For finite assignment spaces, randomization designs, row statistics, and row targets, finite-design convergence in probability is equivalent to convergence in probability under the induced row measures.
    Ω :
    ℕ → Type u_1
    shared
    D :
    ∀ m, FiniteDesign (Ω m)
    X :
    ∀ m
    if
    Ω m
    then
    ℝ
    c :
    ℕ → ℝ
    ↔ @TendstoInProbability ℕ Ω (fun _ => ⊤) ℝ inferInstance (fun m => @FiniteDesign.toMeasure (Ω m) (by infer_instance) ⊤ (D m)) X atTop (fun m _ => c m)
    Proof (Lean source)
    theorem tendstoInProb_iff_tendstoInProbability (D : ∀ m, FiniteDesign (Ω m)) (X : ∀ m, Ω m → ℝ) (c : ℕ → ℝ) : TendstoInProb D X c ↔ @TendstoInProbability ℕ Ω (fun _ => ⊤) ℝ inferInstance (fun m => @FiniteDesign.toMeasure (Ω m) (by infer_instance) ⊤ (D m)) X atTop (fun m _ => c m) := by letI : ∀ m, MeasurableSpace (Ω m) := fun _ => ⊤ rw [tendstoInProbability_iff_measureReal_norm] simp only [Real.norm_eq_abs, FiniteDesign.toMeasure_real_setOf] rfl
    Causalean.Experimentation.DesignBased.FiniteDesign.tendstoInProb_iff_tendstoInProbability · Causalean/Experimentation/DesignBased/InProb.lean:65
  • deterministic_tendstoInProb theorem — Under a sequence of finite-design laws, if a deterministic real sequence converges to a constant, then the corresponding constant-on-assignment statistics converge in finite-design probability.
    Ω :
    ℕ → Type u_1
    shared
    D :
    ∀ n, FiniteDesign (Ω n)
    a :
    ℕ → ℝ
    c :
    ℝ
    ha :
    Tendsto a atTop (𝓝 c)
    TendstoInProb D (fun n _ => a n) (fun _ => c)
    Proof (Lean source)
    theorem deterministic_tendstoInProb (D : ∀ n, FiniteDesign (Ω n)) (a : ℕ → ℝ) (c : ℝ) (ha : Tendsto a atTop (𝓝 c)) : TendstoInProb D (fun n _ => a n) (fun _ => c) := by intro ε hε have hev : ∀ᶠ n in atTop, |a n - c| < ε := by simpa [Real.dist_eq] using (Metric.tendsto_atTop.1 ha ε hε) apply tendsto_order.2 constructor · intro u hu filter_upwards [] with n exact hu.trans_le ((D n).Pr_nonneg _) · intro u hu filter_upwards [hev] with n hn have hz : (D n).Pr (fun _ => ε ≤ |a n - c|) = 0 := by unfold FiniteDesign.Pr FiniteDesign.E FiniteDesign.ind simp [not_le.mpr hn] rw [hz] exact hu
    Causalean.Experimentation.DesignBased.FiniteDesign.deterministic_tendstoInProb · Causalean/Experimentation/DesignBased/InProb.lean:79
  • tendstoInProb_continuousMap theorem — Under a sequence of finite-design laws, if a statistic converges in probability to a constant and a real map is continuous at that constant, then applying the map preserves convergence in probability.
    Ω :
    ℕ → Type u_1
    shared
    D :
    ∀ n, FiniteDesign (Ω n)
    X :
    ∀ n
    if
    Ω n
    then
    ℝ
    c :
    ℝ
    f :
    ℝ → ℝ
    hX :
    TendstoInProb D X (fun _ => c)
    hf :
    TendstoInProb D (fun n z => f (X n z)) (fun _ => f c)
    Proof (Lean source)
    theorem tendstoInProb_continuousMap (D : ∀ n, FiniteDesign (Ω n)) (X : ∀ n, Ω n → ℝ) (c : ℝ) (f : ℝ → ℝ) (hX : TendstoInProb D X (fun _ => c)) (hf : ContinuousAt f c) : TendstoInProb D (fun n z => f (X n z)) (fun _ => f c) := by intro ε hε obtain ⟨δ, hδ, hmap⟩ := (Metric.continuousAt_iff.1 hf) ε hε have htail := hX δ hδ refine squeeze_zero (fun n => (D n).Pr_nonneg _) (fun n => ?_) htail apply (D n).Pr_mono intro z hz by_contra hfar rw [not_le] at hfar have := hmap (show dist (X n z) c < δ by simpa [Real.dist_eq] using hfar) exact (not_lt_of_ge hz) (by simpa [Real.dist_eq] using this)
    Causalean.Experimentation.DesignBased.FiniteDesign.tendstoInProb_continuousMap · Causalean/Experimentation/DesignBased/InProb.lean:101
  • Pr_or_le lemma — Union bound for two events: Pr(P ∨ Q) ≤ Pr P + Pr Q.
    Ω' :
    Type*
    D :
    P Q :
    D.Pr (fun z => P z ∨ Q z) ≤ D.Pr P + D.Pr Q
    Proof (Lean source)
    lemma Pr_or_le {Ω' : Type*} [Fintype Ω'] (D : FiniteDesign Ω') (P Q : Ω' → Prop) [DecidablePred P] [DecidablePred Q] : D.Pr (fun z => P z ∨ Q z) ≤ D.Pr P + D.Pr Q := by unfold FiniteDesign.Pr FiniteDesign.E FiniteDesign.ind rw [← Finset.sum_add_distrib] apply Finset.sum_le_sum intro z _ rw [← mul_add] apply mul_le_mul_of_nonneg_left _ (D.p_nonneg z) by_cases hP : P z <;> by_cases hQ : Q z <;> simp [hP, hQ]
    Causalean.Experimentation.DesignBased.FiniteDesign.Pr_or_le · Causalean/Experimentation/DesignBased/InProb.lean:134
  • sub theorem — Along a sequence of finite designs, if the statistics X m converge in probability to a m and the statistics Y m converge in probability to b m, then the difference X m − Y m converges in probability to a m − b m: convergence in probability is closed under differences.
    Ω :
    ℕ → Type u_1
    ∀ m, FiniteDesign (Ω m)
    shared
    X Y :
    ∀ m
    if
    Ω m
    then
    ℝ
    a b :
    ℕ → ℝ
    hX :
    hY :
    TendstoInProb D (fun m z => X m z - Y m z) (fun m => a m - b m)
    Proof (Lean source)
    theorem TendstoInProb.sub {D : ∀ m, FiniteDesign (Ω m)} {X Y : ∀ m, Ω m → ℝ} {a b : ℕ → ℝ} (hX : TendstoInProb D X a) (hY : TendstoInProb D Y b) : TendstoInProb D (fun m z => X m z - Y m z) (fun m => a m - b m) := by intro ε hε have hε2 : (0 : ℝ) < ε / 2 := by linarith -- The combined tail bound: split each event into the two half-deviation events. have hbound : ∀ m, (D m).Pr (fun z => ε ≤ |(X m z - Y m z) - (a m - b m)|) ≤ (D m).Pr (fun z => ε / 2 ≤ |X m z - a m|) + (D m).Pr (fun z => ε / 2 ≤ |Y m z - b m|) := by intro m have hmono : (D m).Pr (fun z => ε ≤ |(X m z - Y m z) - (a m - b m)|) ≤ (D m).Pr (fun z => (ε / 2 ≤ |X m z - a m|) ∨ (ε / 2 ≤ |Y m z - b m|)) := by apply (D m).Pr_mono intro z hz by_contra hcon push_neg at hcon obtain ⟨h1, h2⟩ := hcon have htri : |(X m z - Y m z) - (a m - b m)| ≤ |X m z - a m| + |Y m z - b m| := by have : (X m z - Y m z) - (a m - b m) = (X m z - a m) - (Y m z - b m) := by ring rw [this] exact abs_sub _ _ linarith exact le_trans hmono (Pr_or_le (D m) _ _) have hupper : Tendsto (fun m => (D m).Pr (fun z => ε / 2 ≤ |X m z - a m|) + (D m).Pr (fun z => ε / 2 ≤ |Y m z - b m|)) atTop (𝓝 0) := by have := (hX (ε / 2) hε2).add (hY (ε / 2) hε2) simpa using this refine squeeze_zero (fun m => (D m).Pr_nonneg _) hbound hupper
    Causalean.Experimentation.DesignBased.FiniteDesign.TendstoInProb.sub · Causalean/Experimentation/DesignBased/InProb.lean:146
  • add theorem — Convergence in probability is closed under sums.
    Ω :
    ℕ → Type u_1
    ∀ m, FiniteDesign (Ω m)
    shared
    X Y :
    ∀ m
    if
    Ω m
    then
    ℝ
    a b :
    ℕ → ℝ
    hX :
    hY :
    TendstoInProb D (fun m z => X m z + Y m z) (fun m => a m + b m)
    Proof (Lean source)
    theorem TendstoInProb.add {D : ∀ m, FiniteDesign (Ω m)} {X Y : ∀ m, Ω m → ℝ} {a b : ℕ → ℝ} (hX : TendstoInProb D X a) (hY : TendstoInProb D Y b) : TendstoInProb D (fun m z => X m z + Y m z) (fun m => a m + b m) := by intro ε hε have hε2 : (0 : ℝ) < ε / 2 := by linarith have hbound : ∀ m, (D m).Pr (fun z => ε ≤ |(X m z + Y m z) - (a m + b m)|) ≤ (D m).Pr (fun z => ε / 2 ≤ |X m z - a m|) + (D m).Pr (fun z => ε / 2 ≤ |Y m z - b m|) := by intro m have hmono : (D m).Pr (fun z => ε ≤ |(X m z + Y m z) - (a m + b m)|) ≤ (D m).Pr (fun z => (ε / 2 ≤ |X m z - a m|) ∨ (ε / 2 ≤ |Y m z - b m|)) := by apply (D m).Pr_mono intro z hz by_contra hcon push_neg at hcon obtain ⟨h1, h2⟩ := hcon have htri : |(X m z + Y m z) - (a m + b m)| ≤ |X m z - a m| + |Y m z - b m| := by have : (X m z + Y m z) - (a m + b m) = (X m z - a m) + (Y m z - b m) := by ring rw [this] exact abs_add_le _ _ linarith exact le_trans hmono (Pr_or_le (D m) _ _) have hupper : Tendsto (fun m => (D m).Pr (fun z => ε / 2 ≤ |X m z - a m|) + (D m).Pr (fun z => ε / 2 ≤ |Y m z - b m|)) atTop (𝓝 0) := by have := (hX (ε / 2) hε2).add (hY (ε / 2) hε2) simpa using this refine squeeze_zero (fun m => (D m).Pr_nonneg _) hbound hupper
    Causalean.Experimentation.DesignBased.FiniteDesign.TendstoInProb.add · Causalean/Experimentation/DesignBased/InProb.lean:181
  • abs theorem — If X m → 0 in probability then |X m| → 0 in probability.
    Ω :
    ℕ → Type u_1
    ∀ m, FiniteDesign (Ω m)
    shared
    X :
    ∀ m
    if
    Ω m
    then
    ℝ
    h :
    TendstoInProb D X (fun _ => 0)
    TendstoInProb D (fun m z => |X m z|) (fun _ => 0)
    Proof (Lean source)
    theorem TendstoInProb.abs {D : ∀ m, FiniteDesign (Ω m)} {X : ∀ m, Ω m → ℝ} (h : TendstoInProb D X (fun _ => 0)) : TendstoInProb D (fun m z => |X m z|) (fun _ => 0) := by intro ε hε simpa only [sub_zero, abs_abs] using h ε hε
    Causalean.Experimentation.DesignBased.FiniteDesign.TendstoInProb.abs · Causalean/Experimentation/DesignBased/InProb.lean:212
  • boundedInProb_iff_boundedInProbability theorem — For finite assignment spaces, randomization designs, and row statistics, finite-design boundedness in probability is equivalent to the shared measure-theoretic stochastic-order notion at constant rate one.
    Ω :
    ℕ → Type u_1
    shared
    D :
    ∀ m, FiniteDesign (Ω m)
    X :
    ∀ m
    if
    Ω m
    then
    ℝ
    ↔ @BoundedInProbability ℕ Ω (fun _ => ⊤) ℝ inferInstance (fun m => @FiniteDesign.toMeasure (Ω m) (by infer_instance) ⊤ (D m)) X atTop (fun _ => 1)
    Proof (Lean source)
    theorem boundedInProb_iff_boundedInProbability (D : ∀ m, FiniteDesign (Ω m)) (X : ∀ m, Ω m → ℝ) : BoundedInProb D X ↔ @BoundedInProbability ℕ Ω (fun _ => ⊤) ℝ inferInstance (fun m => @FiniteDesign.toMeasure (Ω m) (by infer_instance) ⊤ (D m)) X atTop (fun _ => 1) := by letI : ∀ m, MeasurableSpace (Ω m) := fun _ => ⊤ constructor · intro h δ hδ by_cases hδtop : δ = ⊤ · exact ⟨1, one_pos, by simp [hδtop]⟩ have hδreal : 0 < δ.toReal := ENNReal.toReal_pos hδ.ne' hδtop obtain ⟨M, hM⟩ := h δ.toReal hδreal let M' : ℝ := |M| + 1 have hM' : 0 < M' := by simp [M']; positivity refine ⟨M', hM', ?_⟩ filter_upwards [hM] with m hm apply (ENNReal.toReal_le_toReal (MeasureTheory.measure_ne_top _ _) hδtop).1 simp only [mul_one, Real.norm_eq_abs] change (D m).toMeasure.real {z | M' ≤ |X m z|} ≤ δ.toReal rw [(D m).toMeasure_real_setOf] refine le_trans ((D m).Pr_mono (fun z => M' ≤ |X m z|) (fun z => M ≤ |X m z|) ?_) hm intro z hz have hMM' : M ≤ M' := by dsimp [M']; linarith [le_abs_self M] exact hMM'.trans hz · intro h η hη obtain ⟨M, _hMpos, hM⟩ := h (ofReal η) (ENNReal.ofReal_pos.mpr hη) refine ⟨M, ?_⟩ filter_upwards [hM] with m hm have hto := (ENNReal.toReal_le_toReal (MeasureTheory.measure_ne_top _ _) ENNReal.ofReal_ne_top).2 hm simp only [mul_one, Real.norm_eq_abs] at hto change (D m).toMeasure.real {z | M ≤ |X m z|} ≤ (ofReal η).toReal at hto rw [(D m).toMeasure_real_setOf, ENNReal.toReal_ofReal hη.le] at hto exact hto
    Causalean.Experimentation.DesignBased.FiniteDesign.boundedInProb_iff_boundedInProbability · Causalean/Experimentation/DesignBased/InProb.lean:333
  • boundedInProb_of_var_bound theorem — An eventual variance bound together with an eventual mean bound makes a sequence bounded in probability: if the design variances Var(X m) are eventually at most V and the means E(X m) eventually lie within c of zero, then X is uniformly tight.
    Ω :
    ℕ → Type u_1
    shared
    D :
    ∀ m, FiniteDesign (Ω m)
    X :
    ∀ m
    if
    Ω m
    then
    ℝ
    V c :
    ℝ
    hV :
    ∀ᶠ m in atTop, (D m).Var (X m) ≤ V
    hc :
    ∀ᶠ m in atTop, |(D m).E (X m)| ≤ c
    Proof (Lean source)
    theorem boundedInProb_of_var_bound (D : ∀ m, FiniteDesign (Ω m)) (X : ∀ m, Ω m → ℝ) {V c : ℝ} (hV : ∀ᶠ m in atTop, (D m).Var (X m) ≤ V) (hc : ∀ᶠ m in atTop, |(D m).E (X m)| ≤ c) : BoundedInProb D X := by intro η hη obtain ⟨m0, hm0⟩ := hV.exists have hVnn : 0 ≤ V := le_trans ((D m0).Var_nonneg (X m0)) hm0 set r : ℝ := V / η + 1 with hrdef have hr_pos : 0 < r := by rw [hrdef]; positivity have hr2_pos : 0 < r ^ 2 := pow_pos hr_pos 2 refine ⟨c + r, ?_⟩ filter_upwards [hV, hc] with m hVm hcm have hsub : (D m).Pr (fun z => c + r ≤ |X m z|) ≤ (D m).Pr (fun z => r ≤ |X m z - (D m).E (X m)|) := by apply (D m).Pr_mono intro z hz have h1 : |X m z| - |(D m).E (X m)| ≤ |X m z - (D m).E (X m)| := abs_sub_abs_le_abs_sub _ _ linarith refine le_trans hsub (le_trans ((D m).chebyshev (X m) hr_pos) ?_) rw [div_le_iff₀ hr2_pos] have hkey : η * r = V + η := by rw [hrdef]; field_simp have hexp : η * r ^ 2 = (V + η) * r := by rw [pow_two, ← mul_assoc, hkey] rw [hexp] have hr1 : (1 : ℝ) ≤ r := by rw [hrdef]; have : (0 : ℝ) ≤ V / η := by positivity linarith have hVle : V ≤ (V + η) * r := by calc V = V * 1 := (mul_one V).symm _ ≤ (V + η) * r := by apply mul_le_mul (by linarith) hr1 (by norm_num) (by linarith) linarith [hVm]
    Causalean.Experimentation.DesignBased.FiniteDesign.boundedInProb_of_var_bound · Causalean/Experimentation/DesignBased/InProb.lean:372
  • const_mul theorem — Scaling a convergent sequence by a constant scales its probability limit: if X m → a m in probability then c · X m → c · a m in probability.
    Ω :
    ℕ → Type u_1
    ∀ m, FiniteDesign (Ω m)
    shared
    X :
    ∀ m
    if
    Ω m
    then
    ℝ
    a :
    ℕ → ℝ
    c :
    ℝ
    h :
    TendstoInProb D (fun m z => c * X m z) (fun m => c * a m)
    Proof (Lean source)
    theorem TendstoInProb.const_mul {D : ∀ m, FiniteDesign (Ω m)} {X : ∀ m, Ω m → ℝ} {a : ℕ → ℝ} (c : ℝ) (h : TendstoInProb D X a) : TendstoInProb D (fun m z => c * X m z) (fun m => c * a m) := by intro ε hε have hc1 : 0 < |c| + 1 := by positivity have hεc : 0 < ε / (|c| + 1) := by positivity have hsub : ∀ m, (D m).Pr (fun z => ε ≤ |c * X m z - c * a m|) ≤ (D m).Pr (fun z => ε / (|c| + 1) ≤ |X m z - a m|) := by intro m apply (D m).Pr_mono intro z hz rw [← mul_sub, abs_mul] at hz rw [div_le_iff₀ hc1] nlinarith [hz, abs_nonneg (X m z), abs_nonneg c] refine squeeze_zero (fun m => (D m).Pr_nonneg _) hsub ?_ simpa using h (ε / (|c| + 1)) hεc
    Causalean.Experimentation.DesignBased.FiniteDesign.TendstoInProb.const_mul · Causalean/Experimentation/DesignBased/InProb.lean:408
Gaussian­CDF 3 core · 5 supporting The design-based standard-normal CDF is a namespace-local presentation of the canonical Mathlib-facing CDF. ★ stdNormalCdf_neg★ continuous_stdNormalCdf

Standard normal CDF adapter

The design-based standard-normal CDF is a namespace-local presentation of the canonical Mathlib-facing CDF.

The definition stdNormalCdf uses the .real (Iic t) probability-measure presentation needed by design-based interval and CLT statements, while stdNormalCdf_eq identifies it with Causalean.Mathlib.stdNormalCDF. The remaining lemmas forward the reusable facts needed downstream: nonnegativity, the upper bound by one, monotonicity, symmetry stdNormalCdf_neg, and continuity continuous_stdNormalCdf.

def stdNormalCdf reviewed
Causalean.Experimentation.DesignBased

For a real threshold, the standard normal cumulative distribution function is the probability that a standard normal random variable is no greater than that threshold.

Definition (Lean source)
t :
ℝ
stdNormalCdf t :
ℝ
Causalean.Experimentation.DesignBased.stdNormalCdf · Causalean/Experimentation/DesignBased/GaussianCDF.lean:41
lemma stdNormalCdf_neg reviewed
Causalean.Experimentation.DesignBased

Symmetry of the standard normal CDF. For any threshold t, the standard normal CDF satisfies Φ(−t) = 1 − Φ(t).

Formal statement
t :
ℝ
Proof (Lean source)
Causalean.Experimentation.DesignBased.stdNormalCdf_neg · Causalean/Experimentation/DesignBased/GaussianCDF.lean:66 · uses stdNormalCdf
lemma continuous_stdNormalCdf reviewed
Causalean.Experimentation.DesignBased

Continuity of the standard normal CDF. The standard normal cumulative distribution function Φ is continuous.

Formal statement
Proof (Lean source)
@[fun_prop] lemma continuous_stdNormalCdf : Continuous stdNormalCdf := by rw [show stdNormalCdf = stdNormalCDF from funext stdNormalCdf_eq] exact stdNormalCDF_continuous
Causalean.Experimentation.DesignBased.continuous_stdNormalCdf · Causalean/Experimentation/DesignBased/GaussianCDF.lean:71 · uses stdNormalCdf
5 supporting declarations (lemmas, instances)
Exposure 8 core · 3 supporting Exposure mappings turn assignments and unit traits into treatment conditions, and generalized exposure probabilities are the design probabilities of those conditions. ★ E_expoInd★ Cov_expoInd_same★ Cov_expoInd_cross

Exposure mappings and generalized exposure probabilities

Exposure mappings turn assignments and unit traits into treatment conditions, and generalized exposure probabilities are the design probabilities of those conditions.

The basic declarations are expo, the indicator expoInd, the marginal probability prop, and the joint probabilities propPairSame and propPairCross. The covariance lemmas Cov_expoInd_same and Cov_expoInd_cross rewrite indicator covariances into those probabilities, while expoInd_mul_self_of_ne and propPairCross_self_of_ne record that one unit cannot occupy two distinct exposures in the same assignment. For finite exposure spaces, sum_prop_eq_one shows that each unit's exposure probabilities sum to one.

def expo reviewed
Causalean.Experimentation.DesignBased

For an assignment-to-exposure rule, a map assigning each unit its traits, a unit, and an assignment, the unit's exposure is the exposure assigned by that rule to the assignment and the unit's traits.

Definition (Lean source)
Ω :
Type u_1
shared
ι :
Type u_2
shared
Θ :
Type u_3
shared
Δ :
Type u_4
shared
f :
Ω → Θ → Δ
θ :
ι → Θ
i :
ι
z :
Ω
expo f θ i z :
Δ
f z (θ i)
Causalean.Experimentation.DesignBased.expo · Causalean/Experimentation/DesignBased/Exposure.lean:49
def expoInd reviewed
Causalean.Experimentation.DesignBased

For an assignment-to-exposure rule, a map assigning each unit its traits, a unit, and an exposure condition from a set whose elements can be compared for equality, the exposure indicator maps each assignment to one when that unit receives that condition and to zero otherwise.

Definition (Lean source)
Ω :
Type u_1
shared
ι :
Type u_2
shared
Θ :
Type u_3
shared
Δ :
Type u_4
shared
f :
Ω → Θ → Δ
θ :
ι → Θ
i :
ι
d :
Δ
expoInd f θ i d :
Ω → ℝ
FiniteDesign.ind (fun z => expo f θ i z = d)
Causalean.Experimentation.DesignBased.expoInd · Causalean/Experimentation/DesignBased/Exposure.lean:56
def prop reviewed
Causalean.Experimentation.DesignBased

On a finite assignment space, for a finite randomization design, an assignment-to-exposure rule, a map assigning each unit its traits, a unit, and an exposure condition from a set whose elements can be compared for equality, the generalized probability of exposure is the design probability that the unit receives that condition.

Definition (Lean source)
Ω :
Type u_1
shared
ι :
Type u_2
shared
Θ :
Type u_3
shared
Δ :
Type u_4
shared
D :
f :
Ω → Θ → Δ
θ :
ι → Θ
i :
ι
d :
Δ
prop D f θ i d :
ℝ
D.Pr (fun z => expo f θ i z = d)
Causalean.Experimentation.DesignBased.prop · Causalean/Experimentation/DesignBased/Exposure.lean:63 · uses FiniteDesign
def propPairSame reviewed
Causalean.Experimentation.DesignBased

On a finite assignment space, for a finite randomization design, an assignment-to-exposure rule, a map assigning each unit its traits, two units, and an exposure condition from a set whose elements can be compared for equality, the same-condition joint exposure probability is the design expectation of the product of the two units' indicators for that condition.

Definition (Lean source)
Ω :
Type u_1
shared
ι :
Type u_2
shared
Θ :
Type u_3
shared
Δ :
Type u_4
shared
D :
f :
Ω → Θ → Δ
θ :
ι → Θ
i j :
ι
d :
Δ
propPairSame D f θ i j d :
ℝ
D.E (fun z => expoInd f θ i d z * expoInd f θ j d z)
Causalean.Experimentation.DesignBased.propPairSame · Causalean/Experimentation/DesignBased/Exposure.lean:71 · uses FiniteDesign
def propPairCross reviewed
Causalean.Experimentation.DesignBased

On a finite assignment space, for a finite randomization design, an assignment-to-exposure rule, a map assigning each unit its traits, two units, and two exposure conditions from a set whose elements can be compared for equality, the cross-condition joint exposure probability is the design expectation of the product of the first unit's indicator for the first condition and the second unit's indicator for the second condition.

Definition (Lean source)
Ω :
Type u_1
shared
ι :
Type u_2
shared
Θ :
Type u_3
shared
Δ :
Type u_4
shared
D :
f :
Ω → Θ → Δ
θ :
ι → Θ
i j :
ι
d d' :
Δ
propPairCross D f θ i j d d' :
ℝ
D.E (fun z => expoInd f θ i d z * expoInd f θ j d' z)
Causalean.Experimentation.DesignBased.propPairCross · Causalean/Experimentation/DesignBased/Exposure.lean:79 · uses FiniteDesign
lemma E_expoInd reviewed
Causalean.Experimentation.DesignBased

Exposure probability as an expectation. For a design, an exposure mapping, unit traits, a unit i, and an exposure level d, the design expectation of the exposure indicator equals the generalized probability of exposure π_i(d).

Formal statement
Ω :
Type u_1
shared
ι :
Type u_2
shared
Θ :
Type u_3
shared
Δ :
Type u_4
shared
D :
f :
Ω → Θ → Δ
θ :
ι → Θ
i :
ι
d :
Δ
D.E (expoInd f θ i d) = prop D f θ i d
Proof (Lean source)
@[simp, indicator_simps] lemma E_expoInd (D : FiniteDesign Ω) (f : Ω → Θ → Δ) (θ : ι → Θ) (i : ι) (d : Δ) : D.E (expoInd f θ i d) = prop D f θ i d := rfl
Causalean.Experimentation.DesignBased.E_expoInd · Causalean/Experimentation/DesignBased/Exposure.lean:88 · uses FiniteDesign , E , expoInd , prop
lemma Cov_expoInd_same reviewed
Causalean.Experimentation.DesignBased

Covariance of same-exposure indicators. For a design, an exposure mapping, unit traits, units i and j, and an exposure level d, the design covariance of the two units' d-exposure indicators equals the joint exposure probability π_ij(d) minus the product of their marginal exposure probabilities.

Formal statement
Ω :
Type u_1
shared
ι :
Type u_2
shared
Θ :
Type u_3
shared
Δ :
Type u_4
shared
D :
f :
Ω → Θ → Δ
θ :
ι → Θ
i j :
ι
d :
Δ
D.Cov (expoInd f θ i d) (expoInd f θ j d)
= propPairSame D f θ i j d - prop D f θ i d * prop D f θ j d
Proof (Lean source)
lemma Cov_expoInd_same (D : FiniteDesign Ω) (f : Ω → Θ → Δ) (θ : ι → Θ) (i j : ι) (d : Δ) : D.Cov (expoInd f θ i d) (expoInd f θ j d) = propPairSame D f θ i j d - prop D f θ i d * prop D f θ j d := by unfold propPairSame rw [FiniteDesign.Cov_eq, E_expoInd, E_expoInd]
lemma Cov_expoInd_cross reviewed
Causalean.Experimentation.DesignBased

Covariance of cross-exposure indicators. For a design, an exposure mapping, unit traits, units i and j, and exposure levels d and d', the design covariance of unit i's d-exposure indicator and unit j's d'-exposure indicator equals the cross joint exposure probability π_ij(d,d') minus the product of their marginal exposure probabilities.

Formal statement
Ω :
Type u_1
shared
ι :
Type u_2
shared
Θ :
Type u_3
shared
Δ :
Type u_4
shared
D :
f :
Ω → Θ → Δ
θ :
ι → Θ
i j :
ι
d d' :
Δ
D.Cov (expoInd f θ i d) (expoInd f θ j d')
= propPairCross D f θ i j d d' - prop D f θ i d * prop D f θ j d'
Proof (Lean source)
lemma Cov_expoInd_cross (D : FiniteDesign Ω) (f : Ω → Θ → Δ) (θ : ι → Θ) (i j : ι) (d d' : Δ) : D.Cov (expoInd f θ i d) (expoInd f θ j d') = propPairCross D f θ i j d d' - prop D f θ i d * prop D f θ j d' := by unfold propPairCross rw [FiniteDesign.Cov_eq, E_expoInd, E_expoInd]
3 supporting declarations (lemmas, instances)
  • expoInd_mul_self_of_ne lemma — A unit cannot be in two distinct exposures at once: the indicators are pointwise disjoint.
    Ω :
    Type u_1
    shared
    ι :
    Type u_2
    shared
    Θ :
    Type u_3
    shared
    Δ :
    Type u_4
    shared
    f :
    Ω → Θ → Δ
    θ :
    ι → Θ
    i :
    ι
    d d' :
    Δ
    hne :
    d ≠ d'
    z :
    Ω
    expoInd f θ i d z * expoInd f θ i d' z = 0
    Proof (Lean source)
    lemma expoInd_mul_self_of_ne (f : Ω → Θ → Δ) (θ : ι → Θ) (i : ι) {d d' : Δ} (hne : d ≠ d') (z : Ω) : expoInd f θ i d z * expoInd f θ i d' z = 0 := by unfold expoInd FiniteDesign.ind by_cases h : expo f θ i z = d · simp [h, hne] · simp [h]
    Causalean.Experimentation.DesignBased.expoInd_mul_self_of_ne · Causalean/Experimentation/DesignBased/Exposure.lean:119
  • propPairCross_self_of_ne lemma — The self cross-exposure joint probability vanishes for distinct exposures.
    Ω :
    Type u_1
    shared
    ι :
    Type u_2
    shared
    Θ :
    Type u_3
    shared
    Δ :
    Type u_4
    shared
    D :
    f :
    Ω → Θ → Δ
    θ :
    ι → Θ
    i :
    ι
    d d' :
    Δ
    hne :
    d ≠ d'
    propPairCross D f θ i i d d' = 0
    Proof (Lean source)
    lemma propPairCross_self_of_ne (D : FiniteDesign Ω) (f : Ω → Θ → Δ) (θ : ι → Θ) (i : ι) {d d' : Δ} (hne : d ≠ d') : propPairCross D f θ i i d d' = 0 := by unfold propPairCross rw [show (fun z => expoInd f θ i d z * expoInd f θ i d' z) = (fun _ => (0 : ℝ)) from funext (fun z => expoInd_mul_self_of_ne f θ i hne z)] exact D.E_const 0
    Causalean.Experimentation.DesignBased.propPairCross_self_of_ne · Causalean/Experimentation/DesignBased/Exposure.lean:128
  • sum_prop_eq_one lemma — Exposure probabilities sum to one. For a design, an exposure mapping, unit traits, and a unit i, the generalized exposure probabilities of unit i, summed over all exposure levels, equal one.
    Ω :
    Type u_1
    shared
    ι :
    Type u_2
    shared
    Θ :
    Type u_3
    shared
    Δ :
    Type u_4
    shared
    D :
    f :
    Ω → Θ → Δ
    θ :
    ι → Θ
    i :
    ι
    ∑ d, prop D f θ i d = 1
    Proof (Lean source)
    lemma sum_prop_eq_one (D : FiniteDesign Ω) (f : Ω → Θ → Δ) (θ : ι → Θ) (i : ι) : ∑ d, prop D f θ i d = 1 := by simp only [prop, FiniteDesign.Pr, FiniteDesign.E, FiniteDesign.ind] rw [Finset.sum_comm] have : ∀ z, ∑ d, D.p z * (if expo f θ i z = d then (1:ℝ) else 0) = D.p z := by intro z rw [← Finset.mul_sum] simp rw [Finset.sum_congr rfl (fun z _ => this z), D.p_sum]
    Causalean.Experimentation.DesignBased.sum_prop_eq_one · Causalean/Experimentation/DesignBased/Exposure.lean:138
Risk 4 core · 6 supporting Bias and mean squared error summarize fixed-target estimation error under a finite design. ★ mse_eq_var_add_bias_sq

Design-based risk summaries

Bias and mean squared error summarize fixed-target estimation error under a finite design.

The definitions FiniteDesign.bias, FiniteDesign.mse, and FiniteDesign.Unbiased describe estimation error for a fixed target under a finite randomization design. The central theorem FiniteDesign.mse_eq_var_add_bias_sq proves the bias-variance decomposition, with supporting lemmas for unbiased estimators, nonnegativity, the lower bound FiniteDesign.var_le_mse, and congruence under pointwise-equal estimators.

def bias reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

For a randomization design, a real-valued estimator of the realized assignment, and a real-valued target, the estimator's design bias is its design expectation minus the target.

Definition (Lean source)
Ω :
Type u_1
shared
D :
shared
est :
Ω → ℝ
μ :
ℝ
bias D est μ :
ℝ
D.E est - μ
Causalean.Experimentation.DesignBased.FiniteDesign.bias · Causalean/Experimentation/DesignBased/Risk.lean:45 · uses FiniteDesign
def mse reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

For a randomization design, a real-valued estimator of the realized assignment, and a real-valued target, the estimator's design mean squared error is the design expectation of the squared difference between the estimator and the target.

Definition (Lean source)
Ω :
Type u_1
shared
D :
shared
est :
Ω → ℝ
μ :
ℝ
mse D est μ :
ℝ
D.E (fun z => (est z - μ) ^ 2)
Causalean.Experimentation.DesignBased.FiniteDesign.mse · Causalean/Experimentation/DesignBased/Risk.lean:50 · uses FiniteDesign
def Unbiased reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

For a randomization design, a real-valued estimator of the realized assignment, and a real-valued target, the assertion that the estimator is unbiased means that its design expectation equals the target.

Definition (Lean source)
Ω :
Type u_1
shared
D :
shared
est :
Ω → ℝ
μ :
ℝ
Unbiased D est μ :
Prop
D.E est = μ
Causalean.Experimentation.DesignBased.FiniteDesign.Unbiased · Causalean/Experimentation/DesignBased/Risk.lean:55 · uses FiniteDesign
lemma mse_eq_var_add_bias_sq reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

Bias–variance decomposition. The mean squared error mse of estimator est for target μ equals its randomization variance plus the square of its bias: mse = Var + bias².

Formal statement
Ω :
Type u_1
shared
D :
shared
est :
Ω → ℝ
μ :
ℝ
D.mse est μ = D.Var est + (D.bias est μ) ^ 2
Proof (Lean source)
lemma mse_eq_var_add_bias_sq (est : Ω → ℝ) (μ : ℝ) : D.mse est μ = D.Var est + (D.bias est μ) ^ 2 := by unfold mse bias rw [Var_eq] have h : (fun z => (est z - μ) ^ 2) = (fun z => (est z) ^ 2 + ((-(2 * μ)) * est z + μ ^ 2)) := by funext z; ring rw [h, E_add, E_add, E_const_mul, E_const]; ring
Causalean.Experimentation.DesignBased.FiniteDesign.mse_eq_var_add_bias_sq · Causalean/Experimentation/DesignBased/Risk.lean:60 · uses FiniteDesign , Var , bias , mse
6 supporting declarations (lemmas, instances)
  • mse_eq_var_of_unbiased lemma — For an unbiased estimator the mean squared error equals the variance.
    Ω :
    Type u_1
    shared
    D :
    shared
    est :
    Ω → ℝ
    μ :
    ℝ
    h :
    D.Unbiased est μ
    D.mse est μ = D.Var est
    Proof (Lean source)
    lemma mse_eq_var_of_unbiased {est : Ω → ℝ} {μ : ℝ} (h : D.Unbiased est μ) : D.mse est μ = D.Var est := by rw [mse_eq_var_add_bias_sq] unfold bias Unbiased at * rw [h]; ring
    Causalean.Experimentation.DesignBased.FiniteDesign.mse_eq_var_of_unbiased · Causalean/Experimentation/DesignBased/Risk.lean:71
  • bias_of_unbiased lemma — The bias of an unbiased estimator is zero.
    Ω :
    Type u_1
    shared
    D :
    shared
    est :
    Ω → ℝ
    μ :
    ℝ
    h :
    D.Unbiased est μ
    D.bias est μ = 0
    Proof (Lean source)
    @[simp] lemma bias_of_unbiased {est : Ω → ℝ} {μ : ℝ} (h : D.Unbiased est μ) : D.bias est μ = 0 := by unfold bias Unbiased at *; rw [h]; ring
    Causalean.Experimentation.DesignBased.FiniteDesign.bias_of_unbiased · Causalean/Experimentation/DesignBased/Risk.lean:78
  • mse_nonneg lemma — Mean squared error is nonnegative.
    Ω :
    Type u_1
    shared
    D :
    shared
    est :
    Ω → ℝ
    μ :
    ℝ
    0 ≤ D.mse est μ
    Proof (Lean source)
    lemma mse_nonneg (est : Ω → ℝ) (μ : ℝ) : 0 ≤ D.mse est μ := D.E_nonneg (fun _ => sq_nonneg _)
    Causalean.Experimentation.DesignBased.FiniteDesign.mse_nonneg · Causalean/Experimentation/DesignBased/Risk.lean:83
  • Var_nonneg lemma — Variance is nonnegative (it is the mean squared error of the centered estimator).
    Ω :
    Type u_1
    shared
    D :
    shared
    X :
    Ω → ℝ
    0 ≤ D.Var X
    Proof (Lean source)
    lemma Var_nonneg (X : Ω → ℝ) : 0 ≤ D.Var X := by have : D.Var X = D.mse X (D.E X) := by unfold mse Var; rfl rw [this]; exact D.mse_nonneg _ _
    Causalean.Experimentation.DesignBased.FiniteDesign.Var_nonneg · Causalean/Experimentation/DesignBased/Risk.lean:87
  • var_le_mse lemma — Mean squared error is bounded below by the variance.
    Ω :
    Type u_1
    shared
    D :
    shared
    est :
    Ω → ℝ
    μ :
    ℝ
    D.Var est ≤ D.mse est μ
    Proof (Lean source)
    lemma var_le_mse (est : Ω → ℝ) (μ : ℝ) : D.Var est ≤ D.mse est μ := by rw [mse_eq_var_add_bias_sq] exact le_add_of_nonneg_right (sq_nonneg _)
    Causalean.Experimentation.DesignBased.FiniteDesign.var_le_mse · Causalean/Experimentation/DesignBased/Risk.lean:92
  • mse_congr lemma — Congruence: pointwise-equal estimators have equal mean squared error.
    Ω :
    Type u_1
    shared
    D :
    shared
    est est' :
    Ω → ℝ
    μ :
    ℝ
    h :
    ∀ z, est z = est' z
    D.mse est μ = D.mse est' μ
    Proof (Lean source)
    lemma mse_congr {est est' : Ω → ℝ} {μ : ℝ} (h : ∀ z, est z = est' z) : D.mse est μ = D.mse est' μ := D.E_congr (fun z => by rw [h z])
    Causalean.Experimentation.DesignBased.FiniteDesign.mse_congr · Causalean/Experimentation/DesignBased/Risk.lean:97
Finite­Population­Variance 2 core · 3 supporting This file supplies the variance-estimation half of finite-population inference. ★ sampleVariance_tendstoInProb

Consistency of finite-population sample variances

This file supplies the variance-estimation half of finite-population inference. It defines the ordinary sample variance of a simple random sample, proves its centered-second-moment identity, and establishes consistency under Li--Ding's maximal-deviation regularity. The proof uses only the exact simple-random-sampling variance formula and Chebyshev's inequality; variance consistency is not assumed.

def sampleVariance reviewed
Causalean.Experimentation.FinitePopulationMoments

For a finite population, a sample size, outcomes, and a sample of that size, the ordinary sample variance is the sum of squared deviations from the sample mean divided by one fewer than the sample size.

Definition (Lean source)
U :
n :
ℕ
y :
U → ℝ
S :
{S : Finset U // S.card = n}
sampleVariance n y S :
ℝ
(∑ i, if i ∈ S.val then (y i - sampleMean n y S) ^ 2 else 0) / ((n : ℝ) - 1)
Causalean.Experimentation.FinitePopulationMoments.sampleVariance · Causalean/Experimentation/DesignBased/FinitePopulationVariance.lean:32
theorem sampleVariance_tendstoInProb reviewed
Causalean.Experimentation.FinitePopulationMoments.SampleVarianceConsistency

Absolute finite-population sample-variance consistency. Along outcome vectors and growing simple random samples whose sizes are between two and their population sizes, suppose the finite-population variances converge and the largest squared centered outcome divided by the sample size vanishes. Then the ordinary sample variance converges in randomization probability to the finite-population variance.

Formal statement
U :
ℕ → Type u_1
shared
n :
ℕ → ℕ
hn2 :
∀ k, 2 ≤ n k
hnle :
∀ k, n k ≤ card (U k)
y :
∀ k
if
U k
then
ℝ
v :
ℝ
hnTop :
hvar :
Tendsto (fun k => popVar (y k)) atTop (𝓝 v)
hmax :
Tendsto (fun k => popMaxSqDev (y k) / (n k : ℝ)) atTop (𝓝 0)
FiniteDesign.TendstoInProb (fun k => completeRandomization (n k) (hnle k)) (fun k => sampleVariance (n k) (y k)) (fun k => popVar (y k))
Proof (Lean source)
theorem sampleVariance_tendstoInProb (n : ℕ → ℕ) (hn2 : ∀ k, 2 ≤ n k) (hnle : ∀ k, n k ≤ card (U k)) (y : ∀ k, U k → ℝ) (v : ℝ) (hnTop : Tendsto n atTop atTop) (hvar : Tendsto (fun k => popVar (y k)) atTop (𝓝 v)) (hmax : Tendsto (fun k => popMaxSqDev (y k) / (n k : ℝ)) atTop (𝓝 0)) : FiniteDesign.TendstoInProb (fun k => completeRandomization (n k) (hnle k)) (fun k => sampleVariance (n k) (y k)) (fun k => popVar (y k)) := by classical letI hsampleNonempty : ∀ k, Nonempty {S : Finset (U k) // S.card = n k} := fun k => by obtain ⟨S, _hsub, hS⟩ := Finset.exists_subset_card_eq (s := univ) (by simpa using hnle k) exact ⟨⟨S, hS⟩⟩ have hn0 : ∀ k, 0 < n k := fun k => lt_of_lt_of_le (by norm_num) (hn2 k) have hz := centeredSq_sampleMean_tendstoInProb n hn2 hnle y v hvar hmax have hzCentered : FiniteDesign.TendstoInProb (fun k => completeRandomization (n k) (hnle k)) (fun k S => sampleMean (n k) (fun i => (y k i - popMean (y k)) ^ 2) S - popMean (fun i => (y k i - popMean (y k)) ^ 2)) (fun _ => 0) := by intro ε hε simpa using hz ε hε have hx := centered_sampleMean_tendstoInProb n hn2 hnle y v hnTop hvar have hxSq : FiniteDesign.TendstoInProb (fun k => completeRandomization (n k) (hnle k)) (fun k S => (sampleMean (n k) (fun i => y k i - popMean (y k)) S) ^ 2) (fun _ => 0) := by exact FiniteDesign.TendstoInProb.sq_zero hx have hscaleBdd : ∀ k, |(n k : ℝ) / ((n k : ℝ) - 1)| ≤ (2 : ℝ) := by intro k have hnR : (2 : ℝ) ≤ (n k : ℝ) := by exact_mod_cast hn2 k have hden : (0 : ℝ) < (n k : ℝ) - 1 := by linarith rw [abs_of_nonneg (div_nonneg (by positivity) hden.le)] rw [div_le_iff₀ hden] linarith have hzScaled := FiniteDesign.TendstoInProb.mul_deterministic_of_bounded (fun k => (n k : ℝ) / ((n k : ℝ) - 1)) 2 hscaleBdd hzCentered have hxScaled := FiniteDesign.TendstoInProb.mul_deterministic_of_bounded (fun k => (n k : ℝ) / ((n k : ℝ) - 1)) 2 hscaleBdd hxSq have hdet := scaled_popMean_centeredSq_sub_popVar_tendsto n hn2 hnle y v hnTop hvar have hdetProb := FiniteDesign.deterministic_tendstoInProb (fun k => completeRandomization (n k) (hnle k)) (fun k => ((n k : ℝ) / ((n k : ℝ) - 1)) * popMean (fun i => (y k i - popMean (y k)) ^ 2) - popVar (y k)) 0 hdet have hsum : FiniteDesign.TendstoInProb (fun k => completeRandomization (n k) (hnle k)) (fun k S => sampleVariance (n k) (y k) S - popVar (y k)) (fun _ => 0) := by convert (hzScaled.sub hxScaled).add hdetProb using 1 · funext k S rw [sampleVariance_eq_centered (n k) (hn0 k) (y k) S] ring · funext k ring intro ε hε simpa using hsum ε hε
Causalean.Experimentation.FinitePopulationMoments.SampleVarianceConsistency.sampleVariance_tendstoInProb · Causalean/Experimentation/DesignBased/FinitePopulationVariance.lean:359 · uses TendstoInProb , completeRandomization , popMaxSqDev , popVar , sampleVariance
3 supporting declarations (lemmas, instances)
  • sampleVariance_eq_centered lemma — For a nonempty simple random sample, its outcomes, and its realized sample, the sample variance equals n/(n-1) times the sampled centered second moment minus the squared sampled centered first moment.
    U :
    n :
    ℕ
    hn :
    0 < n
    y :
    U → ℝ
    S :
    {S : Finset U // S.card = n}
    sampleVariance n y S
    = ((n : ℝ) / ((n : ℝ) - 1)) * (sampleMean n (fun i => (y i - popMean y) ^ 2) S - (sampleMean n (fun i => y i - popMean y) S) ^ 2)
    Proof (Lean source)
    lemma sampleVariance_eq_centered {U : Type*} [Fintype U] [DecidableEq U] (n : ℕ) (hn : 0 < n) (y : U → ℝ) (S : {S : Finset U // S.card = n}) : sampleVariance n y S = ((n : ℝ) / ((n : ℝ) - 1)) * (sampleMean n (fun i => (y i - popMean y) ^ 2) S - (sampleMean n (fun i => y i - popMean y) S) ^ 2) := by classical have hnR : (n : ℝ) ≠ 0 := by exact_mod_cast hn.ne' have hcenter : sampleMean n (fun i => y i - popMean y) S = sampleMean n y S - popMean y := by unfold sampleMean have hsum : (∑ i : U, if i ∈ S.val then y i - popMean y else 0) = (∑ i : U, if i ∈ S.val then y i else 0) - (n : ℝ) * popMean y := by rw [← Finset.sum_filter, Finset.sum_sub_distrib] simp [S.property] rw [hsum] field_simp let x : U → ℝ := fun i => y i - popMean y let xb : ℝ := sampleMean n x S have hsumxS : (∑ i ∈ S.val, x i) = (n : ℝ) * xb := by dsimp [xb] unfold sampleMean rw [show (∑ i : U, if i ∈ S.val then x i else 0) = ∑ i ∈ S.val, x i by simp] field_simp have hsq : (∑ i : U, if i ∈ S.val then (x i - xb) ^ 2 else 0) = (∑ i : U, if i ∈ S.val then (x i) ^ 2 else 0) - (n : ℝ) * xb ^ 2 := by rw [show (∑ i : U, if i ∈ S.val then (x i - xb) ^ 2 else 0) = ∑ i ∈ S.val, (x i - xb) ^ 2 by simp] rw [show (∑ i : U, if i ∈ S.val then x i ^ 2 else 0) = ∑ i ∈ S.val, x i ^ 2 by simp] have hterm : ∀ i, (x i - xb) ^ 2 = x i ^ 2 - 2 * xb * x i + xb ^ 2 := by intro i ring simp_rw [hterm, Finset.sum_add_distrib, Finset.sum_sub_distrib] rw [← Finset.mul_sum, hsumxS] simp [S.property] ring unfold sampleVariance have hshift : (∑ i : U, if i ∈ S.val then (y i - sampleMean n y S) ^ 2 else 0) = ∑ i : U, if i ∈ S.val then (x i - xb) ^ 2 else 0 := by apply Finset.sum_congr rfl intro i _ by_cases hi : i ∈ S.val <;> simp [hi, x, xb, hcenter] rw [hshift, hsq] change ((∑ i : U, if i ∈ S.val then (y i - popMean y) ^ 2 else 0) - (n : ℝ) * (sampleMean n (fun i => y i - popMean y) S) ^ 2) / ((n : ℝ) - 1) = _ unfold sampleMean field_simp
    Causalean.Experimentation.FinitePopulationMoments.sampleVariance_eq_centered · Causalean/Experimentation/DesignBased/FinitePopulationVariance.lean:39
  • popVar_centeredSq_le_max_mul_popVar lemma — For a population containing at least two units and its outcomes, the finite-population variance of the squared centered outcomes is at most the largest squared centered outcome times the original finite-population variance.
    U :
    Type*
    Nonempty U
    hN :
    2 ≤ card U
    y :
    U → ℝ
    popVar (fun i => (y i - popMean y) ^ 2) ≤ popMaxSqDev y * popVar y
    Proof (Lean source)
    lemma popVar_centeredSq_le_max_mul_popVar {U : Type*} [Fintype U] [Nonempty U] (hN : 2 ≤ Fintype.card U) (y : U → ℝ) : popVar (fun i => (y i - popMean y) ^ 2) ≤ popMaxSqDev y * popVar y := by classical let N : ℕ := Fintype.card U let x : U → ℝ := fun i => y i - popMean y let z : U → ℝ := fun i => x i ^ 2 have hNR : (2 : ℝ) ≤ (N : ℝ) := by exact_mod_cast hN have hNpos : (0 : ℝ) < (N : ℝ) := by linarith have hN1pos : (0 : ℝ) < (N : ℝ) - 1 := by linarith have hNne : (N : ℝ) ≠ 0 := ne_of_gt hNpos have hraw : (∑ i, (z i - popMean z) ^ 2) = (∑ i, z i ^ 2) - (∑ i, z i) ^ 2 / (N : ℝ) := by unfold popMean change (∑ i, (z i - (∑ j, z j) / (N : ℝ)) ^ 2) = _ have hterm : ∀ i, (z i - (∑ j, z j) / (N : ℝ)) ^ 2 = z i ^ 2 - 2 * ((∑ j, z j) / (N : ℝ)) * z i + ((∑ j, z j) / (N : ℝ)) ^ 2 := by intro i ring simp_rw [hterm, Finset.sum_add_distrib, Finset.sum_sub_distrib] rw [← Finset.mul_sum, Finset.sum_const, Finset.card_univ, nsmul_eq_mul] change _ = (∑ i, z i ^ 2) - (∑ i, z i) ^ 2 / (N : ℝ) field_simp ring have hraw_le : (∑ i, (z i - popMean z) ^ 2) ≤ ∑ i, z i ^ 2 := by rw [hraw] have hnonneg : 0 ≤ (∑ i, z i) ^ 2 / (N : ℝ) := div_nonneg (sq_nonneg _) hNpos.le linarith have hzmax : ∀ i, z i ≤ popMaxSqDev y := by intro i exact Finset.le_sup' (fun j => (y j - popMean y) ^ 2) (Finset.mem_univ i) have hsum_le : (∑ i, z i ^ 2) ≤ popMaxSqDev y * ∑ i, z i := by rw [Finset.mul_sum] apply Finset.sum_le_sum intro i _ change z i ^ 2 ≤ popMaxSqDev y * z i rw [sq] exact mul_le_mul_of_nonneg_right (hzmax i) (sq_nonneg (x i)) unfold popVar change (∑ i, (z i - popMean z) ^ 2) / ((N : ℝ) - 1) ≤ popMaxSqDev y * ((∑ i, x i ^ 2) / ((N : ℝ) - 1)) rw [div_le_iff₀ hN1pos] calc (∑ i, (z i - popMean z) ^ 2) ≤ ∑ i, z i ^ 2 := hraw_le _ ≤ popMaxSqDev y * ∑ i, z i := hsum_le _ = (popMaxSqDev y * ((∑ i, x i ^ 2) / ((N : ℝ) - 1))) * ((N : ℝ) - 1) := by dsimp [z] field_simp
    Causalean.Experimentation.FinitePopulationMoments.popVar_centeredSq_le_max_mul_popVar · Causalean/Experimentation/DesignBased/FinitePopulationVariance.lean:93
  • popMean_centered_eq_zero lemma — For a nonempty finite population with outcomes, the population mean of the centered outcomes is zero.
    U :
    Type*
    Nonempty U
    y :
    U → ℝ
    popMean (fun i => y i - popMean y) = 0
    Proof (Lean source)
    lemma popMean_centered_eq_zero {U : Type*} [Fintype U] [Nonempty U] (y : U → ℝ) : popMean (fun i => y i - popMean y) = 0 := by classical have hN : (Fintype.card U : ℝ) ≠ 0 := by exact_mod_cast Fintype.card_ne_zero unfold popMean rw [Finset.sum_sub_distrib, Finset.sum_const, Finset.card_univ, nsmul_eq_mul] field_simp ring
    Causalean.Experimentation.FinitePopulationMoments.popMean_centered_eq_zero · Causalean/Experimentation/DesignBased/FinitePopulationVariance.lean:148
Sequential­Sampling 17 core · 14 supporting This module represents sequential sampling without replacement by a uniformly random permutation. ★ permutationNextMean_eq_remainingMean★ permutationCenteredDraw_condExp_zero★ permutationNextVariance_eq_remainingVariance

Sequential simple random sampling without replacement

This module represents sequential sampling without replacement by a uniformly random permutation. It defines the prefix filtration, the next draw and its finite conditional moments, and the Doob martingale-difference array of a centered simple-random-sample mean.

abbrev PermutationSampleSpace reviewed
Causalean.Experimentation.DesignBased

Given a population size, the ordered sampling space is the set of permutations of the N population indices.

Definition (Lean source)
N :
ℕ
PermutationSampleSpace N :
Type
Perm (Fin N)
Causalean.Experimentation.DesignBased.PermutationSampleSpace · Causalean/Experimentation/DesignBased/SequentialSampling.lean:30
def uniformPermutationDesign reviewed
Causalean.Experimentation.DesignBased

Given a population size, the uniform permutation design gives every ordering of the population the same probability.

Definition (Lean source)
N :
ℕ
uniformPermutationDesign N :
by classical exact { p := fun _ => 1 / (card (PermutationSampleSpace N) : ℝ) p_nonneg := fun _ => one_div_nonneg.mpr (Nat.cast_nonneg _) p_sum := by rw [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] have hcard : card (PermutationSampleSpace N) ≠ 0 := Fintype.card_ne_zero have hcardR : (card (PermutationSampleSpace N) : ℝ) ≠ 0 := by exact_mod_cast hcard field_simp [hcardR] }
Causalean.Experimentation.DesignBased.uniformPermutationDesign · Causalean/Experimentation/DesignBased/SequentialSampling.lean:50 · uses FiniteDesign , PermutationSampleSpace
def permutationPrefix reviewed
Causalean.Experimentation.DesignBased

Given a prefix length and an ordering, the revealed prefix records the draw at positions below k and records no value at later positions.

Definition (Lean source)
N :
ℕ
k :
ℕ
permutationPrefix k π :
Fin N → Option (Fin N)
fun i => if i.val < k then some (π i) else none
Causalean.Experimentation.DesignBased.permutationPrefix · Causalean/Experimentation/DesignBased/SequentialSampling.lean:64 · uses PermutationSampleSpace
def truncatePermutationPrefix reviewed
Causalean.Experimentation.DesignBased

Given a truncation length and a possibly revealed coordinate vector, the truncated prefix retains positions below k and hides all later positions.

Definition (Lean source)
N :
ℕ
k :
ℕ
x :
Fin N → Option (Fin N)
truncatePermutationPrefix k x :
Fin N → Option (Fin N)
fun i => if i.val < k then x i else none
Causalean.Experimentation.DesignBased.truncatePermutationPrefix · Causalean/Experimentation/DesignBased/SequentialSampling.lean:70
def permutationRevealFiltration reviewed
Causalean.Experimentation.DesignBased

For a population size, the successive-draw filtration is generated at time k by the first k values of the random ordering.

Definition (Lean source)
N :
ℕ
permutationRevealFiltration N :
clause 1
seq k := comap (permutationPrefix k) inferInstance
clause 2
mono' := by intro k l hkl apply MeasurableSpace.comap_le_comap_of_eq_comp (truncatePermutationPrefix k) (measurable_of_finite _) funext π i change (if i.val < k then some (π i) else none)
= if i.val < k then (if i.val < l then some (π i) else none) else none by_cases hik : i.val < k · have hil : i.val < l := lt_of_lt_of_le hik hkl simp [hik, hil] · simp [hik]
clause 3
le' := fun _ => le_top
def permutationDraw reviewed
Causalean.Experimentation.DesignBased

Given a population outcome vector, a draw position that is inside the population, and an ordering, the outcome of that draw is the outcome at the index occupying position k.

Definition (Lean source)
N :
ℕ
y :
Fin N → ℝ
k :
ℕ
hk :
k < N
permutationDraw y k hk π :
ℝ
y (π ⟨k, hk⟩)
Causalean.Experimentation.DesignBased.permutationDraw · Causalean/Experimentation/DesignBased/SequentialSampling.lean:95 · uses PermutationSampleSpace
def permutationSwapPosition reviewed
Causalean.Experimentation.DesignBased

Given a finite population and an ordering, a valid natural-number position, and any position in the ordering, the position-swapped ordering exchanges those two draw positions.

Definition (Lean source)
N :
ℕ
k :
ℕ
hk :
k < N
j :
Fin N
permutationSwapPosition π k hk j :
π * swap ⟨k, hk⟩ j
Causalean.Experimentation.DesignBased.permutationSwapPosition · Causalean/Experimentation/DesignBased/SequentialSampling.lean:101 · uses PermutationSampleSpace
def permutationRevealedSum reviewed
Causalean.Experimentation.DesignBased

Given a population outcome vector, a revealed-prefix length, its feasibility, and an ordering, the sum of outcomes in the revealed positions adds the first k ordered outcomes.

Definition (Lean source)
N :
ℕ
y :
Fin N → ℝ
k :
ℕ
hk :
k ≤ N
permutationRevealedSum y k hk π :
ℝ
∑ i : Fin k, y (π (castLE hk i))
Causalean.Experimentation.DesignBased.permutationRevealedSum · Causalean/Experimentation/DesignBased/SequentialSampling.lean:158 · uses PermutationSampleSpace
def permutationRemainingSum reviewed
Causalean.Experimentation.DesignBased

Given a population outcome vector, a revealed-prefix length, its feasibility, and an ordering, the sum of outcomes remaining after the prefix is the population total minus the revealed sum.

Definition (Lean source)
N :
ℕ
y :
Fin N → ℝ
k :
ℕ
hk :
k ≤ N
permutationRemainingSum y k hk π :
ℝ
(∑ i : Fin N, y (π i)) - permutationRevealedSum y k hk π
Causalean.Experimentation.DesignBased.permutationRemainingSum · Causalean/Experimentation/DesignBased/SequentialSampling.lean:165 · uses PermutationSampleSpace
def permutationRemainingPosition reviewed
Causalean.Experimentation.DesignBased

Given a feasible prefix length and an offset among the remaining positions, the corresponding position in the original ordering has index k+j.

Definition (Lean source)
N :
ℕ
k :
ℕ
hk :
k ≤ N
j :
Fin (N - k)
permutationRemainingPosition k hk j :
Fin N
⟨k + j.val, by omega⟩
Causalean.Experimentation.DesignBased.permutationRemainingPosition · Causalean/Experimentation/DesignBased/SequentialSampling.lean:172
def permutationNextMean reviewed
Causalean.Experimentation.DesignBased

Given a population outcome vector, a valid draw position, and an ordering, the finite conditional mean of the next draw given the preceding prefix is the uniform-design fiber average over orderings with the same first k draws.

Definition (Lean source)
N :
ℕ
y :
Fin N → ℝ
k :
ℕ
hk :
k < N
permutationNextMean y k hk π :
ℝ
Causalean.Experimentation.DesignBased.permutationNextMean · Causalean/Experimentation/DesignBased/SequentialSampling.lean:295 · uses PermutationSampleSpace
theorem permutationNextMean_eq_remainingMean reviewed
Causalean.Experimentation.DesignBased

Given population outcomes, a valid next-draw position, and an ordering, the conditional mean of the next draw is the arithmetic mean of the outcomes remaining after the revealed prefix.

Formal statement
N :
ℕ
y :
Fin N → ℝ
k :
ℕ
hk :
k < N
permutationNextMean y k hk π = permutationRemainingSum y k hk.le π / ((N - k : ℕ) : ℝ)
Proof (Lean source)
theorem permutationNextMean_eq_remainingMean {N : ℕ} (y : Fin N → ℝ) (k : ℕ) (hk : k < N) (π : PermutationSampleSpace N) : permutationNextMean y k hk π = permutationRemainingSum y k hk.le π / ((N - k : ℕ) : ℝ) := by classical let D := uniformPermutationDesign N let c : ℝ := 1 / (card (PermutationSampleSpace N) : ℝ) let b := permutationPrefix k π have hcard : (card (PermutationSampleSpace N) : ℝ) ≠ 0 := by exact_mod_cast (Fintype.card_ne_zero : card (PermutationSampleSpace N) ≠ 0) have hc : c ≠ 0 := one_div_ne_zero hcard have hp : D.p π ≠ 0 := by change c ≠ 0 exact hc have hmass : fiberMass D (permutationPrefix k) b ≠ 0 := by intro hzero exact hp (p_eq_zero_of_mem_fiberMass_eq_zero D (permutationPrefix k) b hzero π rfl) have hnum : fiberNumerator D (permutationPrefix k) (fun σ (_ : Unit) => permutationDraw y k hk σ) b () = c * (∑ σ : PermutationSampleSpace N, if permutationPrefix k σ = b then permutationDraw y k hk σ else 0) := by unfold fiberNumerator rw [Finset.mul_sum] apply Finset.sum_congr rfl intro σ _ by_cases hσ : permutationPrefix k σ = b <;> simp [D, c, uniformPermutationDesign, hσ] have hmass' : fiberMass D (permutationPrefix k) b = c * (∑ σ : PermutationSampleSpace N, if permutationPrefix k σ = b then (1 : ℝ) else 0) := by unfold fiberMass rw [Finset.mul_sum] apply Finset.sum_congr rfl intro σ _ by_cases hσ : permutationPrefix k σ = b <;> simp [D, c, uniformPermutationDesign, hσ] have hcount : ((N - k : ℕ) : ℝ) ≠ 0 := by exact_mod_cast (Nat.sub_pos_of_lt hk).ne' have hraw := remainingCount_mul_sum_prefixFiber_permutationDraw y k hk π have hweighted : ((N - k : ℕ) : ℝ) * fiberNumerator D (permutationPrefix k) (fun σ (_ : Unit) => permutationDraw y k hk σ) b () = fiberMass D (permutationPrefix k) b * permutationRemainingSum y k hk.le π := by rw [hnum, hmass'] dsimp only [b] calc ((N - k : ℕ) : ℝ) * (c * ∑ σ : PermutationSampleSpace N, if permutationPrefix k σ = permutationPrefix k π then permutationDraw y k hk σ else 0) = c * (((N - k : ℕ) : ℝ) * ∑ σ : PermutationSampleSpace N, if permutationPrefix k σ = permutationPrefix k π then permutationDraw y k hk σ else 0) := by ring _ = c * ((∑ σ : PermutationSampleSpace N, if permutationPrefix k σ = permutationPrefix k π then (1 : ℝ) else 0) * permutationRemainingSum y k hk.le π) := by rw [hraw] _ = (c * ∑ σ : PermutationSampleSpace N, if permutationPrefix k σ = permutationPrefix k π then (1 : ℝ) else 0) * permutationRemainingSum y k hk.le π := by ring unfold permutationNextMean finiteConditionalMean conditionalMeanAlongMap simp only [D, b, hmass, if_false] apply (div_eq_div_iff hmass hcount).2 calc fiberNumerator D (permutationPrefix k) (fun σ (_ : Unit) => permutationDraw y k hk σ) b () * ((N - k : ℕ) : ℝ) = ((N - k : ℕ) : ℝ) * fiberNumerator D (permutationPrefix k) (fun σ (_ : Unit) => permutationDraw y k hk σ) b () := mul_comm _ _ _ = fiberMass D (permutationPrefix k) b * permutationRemainingSum y k hk.le π := hweighted _ = permutationRemainingSum y k hk.le π * fiberMass D (permutationPrefix k) b := mul_comm _ _
theorem permutationCenteredDraw_condExp_zero reviewed
Causalean.Experimentation.DesignBased

For population outcomes and a valid next-draw position, the next draw centered by its prefix-conditional mean has conditional expectation zero.

Formal statement
N :
ℕ
y :
Fin N → ℝ
k :
ℕ
hk :
k < N
((uniformPermutationDesign N).toMeasure)[ fun π => permutationDraw y k hk π - permutationNextMean y k hk π | (permutationRevealFiltration N) k]
=ᵐ[(uniformPermutationDesign N).toMeasure] 0
Proof (Lean source)
theorem permutationCenteredDraw_condExp_zero {N : ℕ} (y : Fin N → ℝ) (k : ℕ) (hk : k < N) : ((uniformPermutationDesign N).toMeasure)[ fun π => permutationDraw y k hk π - permutationNextMean y k hk π | (permutationRevealFiltration N) k] =ᵐ[(uniformPermutationDesign N).toMeasure] 0 := by let μ := (uniformPermutationDesign N).toMeasure let m := (permutationRevealFiltration N) k have hsub := condExp_sub (Integrable.of_finite : Integrable (permutationDraw y k hk) μ) (Integrable.of_finite : Integrable (permutationNextMean y k hk) μ) m have hdraw := permutationNextMean_ae_eq_condExp y k hk have hmean : μ[permutationNextMean y k hk | m] = permutationNextMean y k hk := condExp_of_stronglyMeasurable ((permutationRevealFiltration N).le k) (permutationNextMean_stronglyMeasurable y k hk) Integrable.of_finite change μ[permutationDraw y k hk - permutationNextMean y k hk | m] =ᵐ[μ] 0 filter_upwards [hsub, hdraw] with π hsubπ hdrawπ change permutationNextMean y k hk π = μ[permutationDraw y k hk | m] π at hdrawπ rw [hsubπ] change μ[permutationDraw y k hk | m] π - μ[permutationNextMean y k hk | m] π = 0 rw [hmean, ← hdrawπ] simp
def permutationNextVariance reviewed
Causalean.Experimentation.DesignBased

Given a population outcome vector, a valid draw position, and an ordering, the conditional centered second moment of the next draw is the prefix-fiber average of its squared deviation from the conditional first moment.

Definition (Lean source)
N :
ℕ
y :
Fin N → ℝ
k :
ℕ
hk :
k < N
permutationNextVariance y k hk π :
ℝ
Causalean.Experimentation.DesignBased.permutationNextVariance · Causalean/Experimentation/DesignBased/SequentialSampling.lean:432 · uses PermutationSampleSpace
theorem permutationNextVariance_eq_remainingVariance reviewed
Causalean.Experimentation.DesignBased

Given population outcomes, a valid next-draw position, and an ordering, the conditional centered second moment of the next draw is the average squared deviation of the remaining outcomes from their remaining mean.

Formal statement
N :
ℕ
y :
Fin N → ℝ
k :
ℕ
hk :
k < N
= (∑ j : Fin (N - k), (y (π (permutationRemainingPosition k hk.le j)) - permutationNextMean y k hk π) ^ 2) / ((N - k : ℕ) : ℝ)
Proof (Lean source)
theorem permutationNextVariance_eq_remainingVariance {N : ℕ} (y : Fin N → ℝ) (k : ℕ) (hk : k < N) (π : PermutationSampleSpace N) : permutationNextVariance y k hk π = (∑ j : Fin (N - k), (y (π (permutationRemainingPosition k hk.le j)) - permutationNextMean y k hk π) ^ 2) / ((N - k : ℕ) : ℝ) := by classical let m := permutationNextMean y k hk π let z : Fin N → ℝ := fun i => (y i - m) ^ 2 have hfiber : finiteConditionalMean (uniformPermutationDesign N) (permutationPrefix k) (fun σ => (permutationDraw y k hk σ - permutationNextMean y k hk σ) ^ 2) (permutationPrefix k π) = finiteConditionalMean (uniformPermutationDesign N) (permutationPrefix k) (permutationDraw z k hk) (permutationPrefix k π) := by unfold finiteConditionalMean conditionalMeanAlongMap split_ifs with hmass · rfl · congr 1 unfold fiberNumerator apply Finset.sum_congr rfl intro σ _ by_cases hprefix : permutationPrefix k σ = permutationPrefix k π · have hremain := permutationRemainingSum_eq_of_prefix_eq y k hk.le σ π hprefix have hmean : permutationNextMean y k hk σ = m := by dsimp only [m] rw [permutationNextMean_eq_remainingMean, permutationNextMean_eq_remainingMean, hremain] simp [hprefix, permutationDraw, z, hmean, m] · simp [hprefix] unfold permutationNextVariance rw [hfiber] change permutationNextMean z k hk π = _ rw [permutationNextMean_eq_remainingMean, ← sum_remainingPositions_eq_permutationRemainingSum]
def permutationSampleMean reviewed
Causalean.Experimentation.DesignBased

Given a feasible sample size, population outcomes, and an ordering, the mean of the first K draws is the ordered representation of the simple-random-sample mean.

Definition (Lean source)
N :
ℕ
K :
ℕ
hK :
K ≤ N
y :
Fin N → ℝ
permutationSampleMean K hK y π :
ℝ
(∑ j : Fin K, y (π (castLE hK j))) / (K : ℝ)
Causalean.Experimentation.DesignBased.permutationSampleMean · Causalean/Experimentation/DesignBased/SequentialSampling.lean:498 · uses PermutationSampleSpace
def srsPermutationDoobArray reviewed
Causalean.Experimentation.DesignBased

Given sequences of population and sample sizes and finite-population outcomes, the SRS Doob martingale-difference array reveals the permutation one draw at a time and has the centered first-K sample mean as its terminal statistic.

Definition (Lean source)
N K :
ℕ → ℕ
hK :
∀ n, K n ≤ N n
y :
∀ n
if
Fin (N n)
then
ℝ
srsPermutationDoobArray N K hK y :
MartingaleDifferenceArray (fun n => PermutationSampleSpace (N n)) (fun n => (uniformPermutationDesign (N n)).toMeasure)
doobMartingaleDifferenceArray K (fun n => permutationRevealFiltration (N n)) (fun n π => permutationSampleMean (K n) (hK n) (y n) π - popMean (y n)) (fun n => (uniformPermutationDesign (N n)).memLp_toMeasure (fun π => permutationSampleMean (K n) (hK n) (y n) π - popMean (y n)) 2)
14 supporting declarations (lemmas, instances)
Two­Stage 4 core · 0 supporting Compound designs combine a stage-one design with conditionally independent stage-two designs. ★ compound★ E_compound★ E_compound_factor

Two-stage compound randomization designs

Compound designs combine a stage-one design with conditionally independent stage-two designs.

The definition compound builds the joint finite design on (stage_one, stage_two_assignments) from a first-stage design and conditionally independent coordinate designs. Lemma FiniteDesign.E_compound expands expectations as an iterated finite sum, and FiniteDesign.E_compound_factor collapses the stage-two expectation of a statistic that depends on one coordinate to that coordinate's conditional marginal expectation.

def compoundCore reviewed
Causalean.Experimentation.DesignBased

For a finite space of first-stage outcomes, a finite space of second-stage outcomes, a probability design for the first stage, and a rule assigning a probability design for the second stage after each first-stage outcome, the compound two-stage design assigns a pair of outcomes the product of its first-stage probability and its conditional second-stage probability.

Definition (Lean source)
Ω₁ :
Type u_1
shared
Ω₂ :
Type*
Fintype Ω₂
D₁ :
D₂ :
Ω₁ → FiniteDesign Ω₂
compoundCore D₁ D₂ :
FiniteDesign (Ω₁ × Ω₂)
clause 1
p sw := D₁.p sw.1 * (D₂ sw.1).p sw.2
clause 2
p_nonneg sw := mul_nonneg (D₁.p_nonneg sw.1) ((D₂ sw.1).p_nonneg sw.2)
clause 3
p_sum := by rw [Fintype.sum_prod_type] have hs : ∀ s, (∑ w : Ω₂, D₁.p s * (D₂ s).p w)
= D₁.p s := by intro s rw [← Finset.mul_sum, (D₂ s).p_sum, mul_one] rw [Finset.sum_congr rfl (fun s _ => hs s), D₁.p_sum]
Causalean.Experimentation.DesignBased.compoundCore · Causalean/Experimentation/DesignBased/TwoStage.lean:51 · uses FiniteDesign
def compound reviewed
Causalean.Experimentation.DesignBased

For a finite space of first-stage outcomes, a finite index set for second-stage coordinates, a finite outcome space for each coordinate, a probability design for the first stage, and a rule assigning, after each first-stage outcome, a design to each coordinate, the compound two-stage design first draws the first-stage outcome and then independently draws every coordinate from its conditional design.

Definition (Lean source)
Ω₁ :
Type u_1
shared
ι :
Type u_2
ι → Type u_3
shared
D₁ :
D₂ :
Ω₁ → ∀ i, FiniteDesign (α i)
compound D₁ D₂ :
FiniteDesign (Ω₁ × ∀ i, α i)
compoundCore D₁ (fun s => prodDesign (D₂ s))
Causalean.Experimentation.DesignBased.compound · Causalean/Experimentation/DesignBased/TwoStage.lean:68 · uses FiniteDesign
lemma E_compound reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

For the stage-2 design map assigning each stage-1 outcome s a per-coordinate design D₂ s and any real-valued function X of the joint outcome, built on top of a stage-1 design D₁, the expectation of X under the compound (two-stage) design equals the double sum over stage-1 outcomes s and stage-2 profiles w of the compound probability D₁.p(s)·∏ᵢ(D₂ s i).p(wᵢ) times X(s,w).

Formal statement
Ω₁ :
Type u_1
shared
ι :
Type u_2
ι → Type u_3
shared
D₁ :
D₂ :
Ω₁ → ∀ i, FiniteDesign (α i)
X :
(Ω₁ × ∀ i, α i) → ℝ
(compound D₁ D₂).E X = ∑ s, ∑ w : ∀ i, α i, D₁.p s * (∏ i, (D₂ s i).p (w i)) * X (s, w)
Proof (Lean source)
lemma E_compound (D₁ : FiniteDesign Ω₁) (D₂ : Ω₁ → ∀ i, FiniteDesign (α i)) (X : (Ω₁ × ∀ i, α i) → ℝ) : (compound D₁ D₂).E X = ∑ s, ∑ w : ∀ i, α i, D₁.p s * (∏ i, (D₂ s i).p (w i)) * X (s, w) := by simp only [FiniteDesign.E, compound, compoundCore, prodDesign_p] rw [Fintype.sum_prod_type]
Causalean.Experimentation.DesignBased.FiniteDesign.E_compound · Causalean/Experimentation/DesignBased/TwoStage.lean:79 · uses FiniteDesign , E , compound
lemma E_compound_factor reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

Stage-2 collapse. For the stage-2 design map assigning each stage-1 outcome s a per-coordinate design D₂ s, the compound-design expectation of the product of a stage-1 quantity h(s) and a function g of a single group j's within-assignment wⱼ factors through the marginal expectation of group j's conditional design: E[h(s)·g(wⱼ)] = E_s[h(s)·E_{D₂ s j}[g]].

Formal statement
Ω₁ :
Type u_1
shared
ι :
Type u_2
ι → Type u_3
shared
D₁ :
D₂ :
Ω₁ → ∀ i, FiniteDesign (α i)
h :
Ω₁ → ℝ
j :
ι
g :
α j → ℝ
(compound D₁ D₂).E (fun sw => h sw.1 * g (sw.2 j)) = D₁.E (fun s => h s * (D₂ s j).E g)
Proof (Lean source)
lemma E_compound_factor (D₁ : FiniteDesign Ω₁) (D₂ : Ω₁ → ∀ i, FiniteDesign (α i)) (h : Ω₁ → ℝ) (j : ι) (g : α j → ℝ) : (compound D₁ D₂).E (fun sw => h sw.1 * g (sw.2 j)) = D₁.E (fun s => h s * (D₂ s j).E g) := by rw [E_compound] conv_rhs => rw [FiniteDesign.E] apply Finset.sum_congr rfl intro s _ rw [show (∑ w : ∀ i, α i, D₁.p s * (∏ i, (D₂ s i).p (w i)) * (h s * g (w j))) = D₁.p s * h s * ((prodDesign (D₂ s)).E (fun w => g (w j))) from by rw [FiniteDesign.E, Finset.mul_sum] apply Finset.sum_congr rfl intro w _ simp only [prodDesign_p] ring] rw [FiniteDesign.E_prod_apply] ring
Causalean.Experimentation.DesignBased.FiniteDesign.E_compound_factor · Causalean/Experimentation/DesignBased/TwoStage.lean:91 · uses FiniteDesign , E , compound
Compound­Variance 1 core · 1 supporting This file proves the expectation tower property FiniteDesign.E_compound_tower for the two-stage compound design and the corresponding law of total variance FiniteDesign.Var_compound_eq_tower. ★ Var_compound_eq_tower

Compound-design variance decomposition

This file proves the expectation tower property FiniteDesign.E_compound_tower for the two-stage compound design and the corresponding law of total variance FiniteDesign.Var_compound_eq_tower. The decomposition writes total variance as expected within-stage variance plus the stage-1 variance of the stage-2 conditional mean, the algebraic form used by partial-interference between-group and within-group variance decompositions.

lemma Var_compound_eq_tower reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

Law of total variance for the two-stage compound design. For a stage-1 design D₁ paired with a stage-2 design D₂ s at every stage-1 outcome s, applied to any statistic X on the joint outcome space, the total variance of X under the compound design decomposes as the stage-1 expectation of the stage-2 conditional variance of X, plus the stage-1 variance of the stage-2 conditional mean of X:

Formal statement
Ω₁ :
Type u_1
shared
ι :
Type u_2
ι → Type u_3
shared
D₁ :
D₂ :
Ω₁ → ∀ i, FiniteDesign (α i)
X :
(Ω₁ × ∀ i, α i) → ℝ
(compound D₁ D₂).Var X
= D₁.E (fun s => (prodDesign (D₂ s)).Var (fun w => X (s, w)))
+ D₁.Var (fun s => (prodDesign (D₂ s)).E (fun w => X (s, w)))
Proof (Lean source)
lemma Var_compound_eq_tower (D₁ : FiniteDesign Ω₁) (D₂ : Ω₁ → ∀ i, FiniteDesign (α i)) (X : (Ω₁ × ∀ i, α i) → ℝ) : (compound D₁ D₂).Var X = D₁.E (fun s => (prodDesign (D₂ s)).Var (fun w => X (s, w))) + D₁.Var (fun s => (prodDesign (D₂ s)).E (fun w => X (s, w))) := by -- stage-2 conditional mean and variance set m : Ω₁ → ℝ := fun s => (prodDesign (D₂ s)).E (fun w => X (s, w)) with hm set v : Ω₁ → ℝ := fun s => (prodDesign (D₂ s)).Var (fun w => X (s, w)) with hv -- Var X = E[X²] − (E X)² rw [Var_eq] -- E[X²] = E_s[ E_{D₂ s}[ X(s,·)² ] ] = E_s[ v s + (m s)² ] (inner Var_eq) have hEsq : (compound D₁ D₂).E (fun sw => X sw ^ 2) = D₁.E (fun s => v s + (m s) ^ 2) := by rw [E_compound_tower] apply D₁.E_congr intro s have hinner : (prodDesign (D₂ s)).E (fun w => X (s, w) ^ 2) = v s + (m s) ^ 2 := by rw [hv, hm] simp only rw [Var_eq] ring -- the goal's inner expectation is over `fun w => (fun sw => X sw ^ 2) (s, w)` simpa using hinner -- E X = E_s[ m s ] have hEX : (compound D₁ D₂).E X = D₁.E m := by rw [E_compound_tower] rw [hEsq, hEX, E_add] -- now: D₁.E v + D₁.E (fun s => (m s)²) − (D₁.E m)² = D₁.E v + D₁.Var m rw [Var_eq] ring
Causalean.Experimentation.DesignBased.FiniteDesign.Var_compound_eq_tower · Causalean/Experimentation/DesignBased/CompoundVariance.lean:67 · uses FiniteDesign , E , Var , compound , prodDesign
1 supporting declaration (lemmas, instances)
  • E_compound_tower lemma — Tower property of expectation for the compound design. The compound expectation iterates as the stage-1 expectation of the stage-2 product-design conditional expectation, E[F] = E_s[E_{D₂ s}[F(s, ·)]].
    Ω₁ :
    Type u_1
    shared
    ι :
    Type u_2
    ι → Type u_3
    shared
    D₁ :
    D₂ :
    Ω₁ → ∀ i, FiniteDesign (α i)
    F :
    (Ω₁ × ∀ i, α i) → ℝ
    (compound D₁ D₂).E F = D₁.E (fun s => (prodDesign (D₂ s)).E (fun w => F (s, w)))
    Proof (Lean source)
    lemma E_compound_tower (D₁ : FiniteDesign Ω₁) (D₂ : Ω₁ → ∀ i, FiniteDesign (α i)) (F : (Ω₁ × ∀ i, α i) → ℝ) : (compound D₁ D₂).E F = D₁.E (fun s => (prodDesign (D₂ s)).E (fun w => F (s, w))) := by rw [E_compound] simp only [FiniteDesign.E, prodDesign_p] apply Finset.sum_congr rfl intro s _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro w _ ring
    Causalean.Experimentation.DesignBased.FiniteDesign.E_compound_tower · Causalean/Experimentation/DesignBased/CompoundVariance.lean:51
Concentration 2 core · 2 supporting For a finite design D and a statistic X bounded by c, with design mean 0 and design variance at most v, bernstein_ge gives the one-sided tail bound Pr[ε ≤ X] ≤ exp(−ε² / (2(2v + cε))) and bernstein_abs_ge the two-sided b ★ bernstein_abs_ge★ bernstein_sum_ge_of_iIndepFun

Bernstein concentration for a bounded design statistic

For a finite design D and a statistic X bounded by c, with design mean 0 and design variance at most v, bernstein_ge gives the one-sided tail bound Pr[ε ≤ X] ≤ exp(−ε² / (2(2v + cε))) and bernstein_abs_ge the two-sided bound Pr[ε ≤ |X|] ≤ 2·exp(−ε² / (2(2v + cε))). These are exponentially sharper than the Chebyshev bound Var/ε², and are obtained from the measure-theoretic sub-exponential Chernoff bound through the design-to-measure bridge. Their constant is a single-statistic sub-exponential proxy; the independent-summand theorem bernstein_sum_ge_of_iIndepFun below has the sharp textbook constant.

theorem bernstein_abs_ge reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

Bernstein tail for a bounded design statistic (two-sided). For a statistic X on a finite design, suppose the bound c is nonnegative, X has design mean 0 , X is bounded in absolute value by c everywhere, the design variance of X is at most v, and the threshold ε is nonnegative. Then the design probability that X deviates from 0 by at least ε in absolute value is at most 2·exp(−ε²/(2(2v + cε))), twice the corresponding one-sided sub-exponential-proxy bound.

Formal statement
Ω :
Type u_1
shared
D :
shared
X :
Ω → ℝ
c v ε :
ℝ
hc :
0 ≤ c
hmean :
D.E X = 0
hbound :
∀ z, |X z| ≤ c
hvar :
D.Var X ≤ v
hε :
0 ≤ ε
D.Pr (fun z => ε ≤ |X z|) ≤ 2 * exp (-ε ^ 2 / (2 * (2 * v + c * ε)))
Proof (Lean source)
theorem bernstein_abs_ge (X : Ω → ℝ) {c v ε : ℝ} (hc : 0 ≤ c) (hmean : D.E X = 0) (hbound : ∀ z, |X z| ≤ c) (hvar : D.Var X ≤ v) (hε : 0 ≤ ε) : D.Pr (fun z => ε ≤ |X z|) ≤ 2 * exp (-ε ^ 2 / (2 * (2 * v + c * ε))) := by have hvarneg : D.Var (fun z => -X z) = D.Var X := by have he : (fun z => -X z) = (fun z => (-1 : ℝ) * X z) := by funext z; ring rw [he, D.Var_const_mul]; ring have hsub := D.hasSubexponentialMGF_of_bounded X hc hmean hbound hvar have hpos := D.hasSubexponentialMGF_of_bounded (v := v) (fun z => -X z) hc (by rw [D.E_neg, hmean, neg_zero]) (fun z => by simpa [abs_neg] using hbound z) (by simpa only [hvarneg] using hvar) have hup : D.toMeasure.real {ω | ε ≤ X ω - 0} ≤ exp (-ε ^ 2 / (2 * (2 * v + c * ε))) := by simp only [sub_zero] exact hsub.measure_ge_le hε have hlow : D.toMeasure.real {ω | ε ≤ -X ω + 0} ≤ exp (-ε ^ 2 / (2 * (2 * v + c * ε))) := by simp only [add_zero] exact hpos.measure_ge_le hε have h := measureReal_abs_dev_le_two_sided (μ := D.toMeasure) X 0 (exp (-ε ^ 2 / (2 * (2 * v + c * ε)))) (exp (-ε ^ 2 / (2 * (2 * v + c * ε)))) ε hup hlow rw [D.Pr_eq_measureReal (fun z => ε ≤ |X z|)] simpa only [sub_zero, two_mul] using h
Causalean.Experimentation.DesignBased.FiniteDesign.bernstein_abs_ge · Causalean/Experimentation/DesignBased/Concentration.lean:78 · uses FiniteDesign , E , Pr , Var
theorem bernstein_sum_ge_of_iIndepFun reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

Sharp design-based Bernstein inequality for independent summands. Given a design law, a positive summand count, and summands that are independent under that law, centered in design expectation, bounded above by the nonnegative envelope b, and have second design moments at most the positive proxy σ², then for a nonnegative deviation ε, the design probability that their sum exceeds nε is at most exp (−nε²/(2(σ²+bε/3))).

Formal statement
Ω :
Type u_1
shared
D :
shared
n :
ℕ
hn :
0 < n
X :
Fin n → Ω → ℝ
b sigma2 ε :
ℝ
hb :
0 ≤ b
hsigma2 :
0 < sigma2
hε :
0 ≤ ε
hindep :
iIndepFun X D.toMeasure
hmean :
∀ i, D.E (X i) = 0
hupper :
∀ i z, X i z ≤ b
hsecond :
∀ i, D.E (fun z => X i z ^ 2) ≤ sigma2
D.Pr (fun z => (n : ℝ) * ε ≤ ∑ i, X i z)
≤ exp (-(n : ℝ) * ε ^ 2 / (2 * (sigma2 + b * ε / 3)))
Proof (Lean source)
theorem bernstein_sum_ge_of_iIndepFun {n : ℕ} (hn : 0 < n) (X : Fin n → Ω → ℝ) {b sigma2 ε : ℝ} (hb : 0 ≤ b) (hsigma2 : 0 < sigma2) (hε : 0 ≤ ε) (hindep : iIndepFun X D.toMeasure) (hmean : ∀ i, D.E (X i) = 0) (hupper : ∀ i z, X i z ≤ b) (hsecond : ∀ i, D.E (fun z => X i z ^ 2) ≤ sigma2) : D.Pr (fun z => (n : ℝ) * ε ≤ ∑ i, X i z) ≤ exp (-(n : ℝ) * ε ^ 2 / (2 * (sigma2 + b * ε / 3))) := by rw [D.Pr_eq_measureReal] apply bernstein_sum_ge hn hb hsigma2 hε hindep (fun i => measurable_of_finite (X i)) (fun i => (D.memLp_toMeasure (X i) 1).integrable (by simp)) (fun i => (D.memLp_toMeasure (fun z => X i z ^ 2) 1).integrable (by simp)) · intro i rw [D.integral_toMeasure] exact hmean i · intro i exact Filter.Eventually.of_forall (hupper i) · intro i rw [D.integral_toMeasure] exact hsecond i
Causalean.Experimentation.DesignBased.FiniteDesign.bernstein_sum_ge_of_iIndepFun · Causalean/Experimentation/DesignBased/Concentration.lean:109 · uses FiniteDesign , E , Pr , toMeasure
2 supporting declarations (lemmas, instances)
  • hasSubexponentialMGF_of_bounded lemma — A bounded, mean-zero statistic on a finite design is sub-exponential under the design measure, with variance-proxy 2v and scale c. This is the finite-design instance of the Bernstein sub-exponential lemma, obtained through the measure bridge.
    Ω :
    Type u_1
    shared
    D :
    shared
    X :
    Ω → ℝ
    c v :
    ℝ
    hc :
    0 ≤ c
    hmean :
    D.E X = 0
    hbound :
    ∀ z, |X z| ≤ c
    hvar :
    D.Var X ≤ v
    HasSubexponentialMGF X ⟨2 * v, by exact mul_nonneg (by norm_num) (le_trans (D.E_nonneg fun _ => sq_nonneg _) hvar)⟩ ⟨c, hc⟩ D.toMeasure
    Proof (Lean source)
    lemma hasSubexponentialMGF_of_bounded (X : Ω → ℝ) {c v : ℝ} (hc : 0 ≤ c) (hmean : D.E X = 0) (hbound : ∀ z, |X z| ≤ c) (hvar : D.Var X ≤ v) : HasSubexponentialMGF X ⟨2 * v, by exact mul_nonneg (by norm_num) (le_trans (D.E_nonneg fun _ => sq_nonneg _) hvar)⟩ ⟨c, hc⟩ D.toMeasure := by have hmean' : D.toMeasure[X] = 0 := (D.integral_toMeasure X).trans hmean have hvar' : D.toMeasure[fun ω => X ω ^ 2] ≤ v := by rw [D.integral_toMeasure (fun z => X z ^ 2)] have : D.E (fun z => X z ^ 2) = D.Var X := by rw [D.Var_eq X, hmean]; ring rw [this]; exact hvar have hv : 0 ≤ v := le_trans (D.E_nonneg fun _ => sq_nonneg _) hvar simpa only [Real.sq_sqrt hv] using bounded_hasSubexponentialMGF (σ := sqrt v) hc (D.aemeasurable_toMeasure X) hmean' (Filter.Eventually.of_forall hbound) (by simpa only [Real.sq_sqrt hv] using hvar')
    Causalean.Experimentation.DesignBased.FiniteDesign.hasSubexponentialMGF_of_bounded · Causalean/Experimentation/DesignBased/Concentration.lean:45
  • bernstein_ge theorem — Sub-exponential-proxy tail for one bounded design statistic. If a statistic is bounded by c, has design mean 0, and has design variance at most v, then it exceeds a nonnegative threshold ε with probability at most exp(−ε² / (2(2v + cε))). This is the older single-statistic proxy constant; use bernstein_sum_ge_of_iIndepFun for independent summands and the textbook Bernstein constant.
    Ω :
    Type u_1
    shared
    D :
    shared
    X :
    Ω → ℝ
    c v ε :
    ℝ
    hc :
    0 ≤ c
    hmean :
    D.E X = 0
    hbound :
    ∀ z, |X z| ≤ c
    hvar :
    D.Var X ≤ v
    hε :
    0 ≤ ε
    D.Pr (fun z => ε ≤ X z) ≤ exp (-ε ^ 2 / (2 * (2 * v + c * ε)))
    Proof (Lean source)
    theorem bernstein_ge (X : Ω → ℝ) {c v ε : ℝ} (hc : 0 ≤ c) (hmean : D.E X = 0) (hbound : ∀ z, |X z| ≤ c) (hvar : D.Var X ≤ v) (hε : 0 ≤ ε) : D.Pr (fun z => ε ≤ X z) ≤ exp (-ε ^ 2 / (2 * (2 * v + c * ε))) := by have hsub := D.hasSubexponentialMGF_of_bounded X hc hmean hbound hvar have h := hsub.measure_ge_le hε rw [D.toMeasure_real_setOf (fun z => ε ≤ X z)] at h -- `((⟨_, _⟩ : ℝ≥0) : ℝ)` is definitionally the underlying real, so `exact` closes this -- at default transparency (`simpa`'s final check no longer unfolds it). exact h
    Causalean.Experimentation.DesignBased.FiniteDesign.bernstein_ge · Causalean/Experimentation/DesignBased/Concentration.lean:63
Dependency­CLT 1 core · 0 supporting dependency_studentized_cdf transports the bounded-degree dependency-graph CLT to the finite-design layer: for a sequence of designs whose unit contributions X n are uniformly bounded, mean-zero, and dependent only across ★ dependency_studentized_cdf

Design-based dependency-graph CLT

dependency_studentized_cdf transports the bounded-degree dependency-graph CLT to the finite-design layer: for a sequence of designs whose unit contributions X n are uniformly bounded, mean-zero, and dependent only across a bounded-degree graph, with the standardizing variance v n bounded below by a constant multiple of the number of units, the studentized statistic depSum(X n)/√(v n) has standard-normal limiting CDF under D n. It is stated in the FiniteDesign.Pr form so it plugs directly into conservative_wald_liminf_of_feasible_studentized_cdf.

theorem dependency_studentized_cdf reviewed
Causalean.Experimentation.DesignBased

Design-based dependency-graph CLT (studentized CDF form). Consider a sequence of finite designs D n together with a triangular array of unit contributions X n i and, for each n, a dependency-graph structure Dep n on the units. Suppose every neighbourhood in the dependency graph has size at most Dmax, the contributions are uniformly bounded by a nonnegative constant M, each contribution has design mean 0, the design second moment v n of the aggregate depSum(X n) is recorded exactly, a positive constant c eventually lower-bounds v n by c times the number of units, and the number of units diverges to infinity. Then, at every point s, the studentized aggregate depSum(X n)/√(v n) has, under the design D n, a limiting CDF equal to the standard normal CDF at s.

Formal statement
Ω :
ℕ → Type*
∀ n, Fintype (Ω n)
∀ n, MeasurableSpace (Ω n)
D :
∀ n, FiniteDesign (Ω n)
ι :
ℕ → Type*
∀ n, Fintype (ι n)
X :
∀ n
if
ι n
and
Ω n
then
ℝ
Dep :
∀ n, DepGraph (X n) (D n).toMeasure
Dmax :
ℕ
hdeg :
∀ n i, ((Dep n).nbhd i).card ≤ Dmax
M :
ℝ
hM :
0 ≤ M
hbound :
∀ n i ω, |X n i ω| ≤ M
hmean :
∀ n i, (D n).E (X n i) = 0
v :
ℕ → ℝ
hv :
∀ n, (D n).E (fun ω => depSum (X n) ω ^ 2) = v n
c :
ℝ
hc :
0 < c
hvc :
∀ᶠ n in atTop, c * (card (ι n) : ℝ) ≤ v n
hcard :
Tendsto (fun n => card (ι n)) atTop atTop
s :
ℝ
Tendsto (fun n => (D n).Pr (fun ω => depSum (X n) ω / sqrt (v n) ≤ s)) atTop (𝓝 (stdNormalCdf s))
Proof (Lean source)
theorem dependency_studentized_cdf {Ω : ℕ → Type*} [∀ n, Fintype (Ω n)] [∀ n, MeasurableSpace (Ω n)] [∀ n, MeasurableSingletonClass (Ω n)] (D : ∀ n, FiniteDesign (Ω n)) {ι : ℕ → Type*} [∀ n, Fintype (ι n)] (X : ∀ n, ι n → Ω n → ℝ) (Dep : ∀ n, DepGraph (X n) (D n).toMeasure) (Dmax : ℕ) (hdeg : ∀ n i, ((Dep n).nbhd i).card ≤ Dmax) (M : ℝ) (hM : 0 ≤ M) (hbound : ∀ n i ω, |X n i ω| ≤ M) (hmean : ∀ n i, (D n).E (X n i) = 0) (v : ℕ → ℝ) (hv : ∀ n, (D n).E (fun ω => depSum (X n) ω ^ 2) = v n) (c : ℝ) (hc : 0 < c) (hvc : ∀ᶠ n in atTop, c * (card (ι n) : ℝ) ≤ v n) (hcard : Tendsto (fun n => card (ι n)) atTop atTop) (s : ℝ) : Tendsto (fun n => (D n).Pr (fun ω => depSum (X n) ω / sqrt (v n) ≤ s)) atTop (𝓝 (stdNormalCdf s)) := by classical have hmean' : ∀ n i, ∫ ω, X n i ω ∂((D n).toMeasure) = 0 := by intro n i exact ((D n).integral_toMeasure (X n i)).trans (hmean n i) have hv' : ∀ n, ∫ ω, (depSum (X n) ω) ^ 2 ∂((D n).toMeasure) = v n := by intro n exact ((D n).integral_toMeasure (fun ω => (depSum (X n) ω) ^ 2)).trans (hv n) have hengine := bounded_degree_dependency_clt (fun n => (D n).toMeasure) X Dep Dmax hdeg M hM hbound hmean' v hv' c hc hvc hcard s rw [show stdNormalCdf s = (gaussianReal 0 1).real (Iic s) from rfl] refine hengine.congr (fun n => ?_) rw [← (D n).toMeasure_real_setOf, MeasureTheory.map_measureReal_apply (measurable_of_finite _) measurableSet_Iic] rfl
Edge­Variance­Bound 1 core · 5 supporting This file proves bounded-expectation and bounded-covariance helpers for FiniteDesign (abs_E_le, abs_Cov_le_two_sq, and Cov_zero_left) and the main dependency-graph edge-sum variance inequality var_edge_sum_le. ★ var_edge_sum_le

Edge-sum variance bound for finite designs

This file proves bounded-expectation and bounded-covariance helpers for FiniteDesign (abs_E_le, abs_Cov_le_two_sq, and Cov_zero_left) and the main dependency-graph edge-sum variance inequality var_edge_sum_le. The final theorem controls the variance of a sum of bounded edge-indexed statistics by 8 * M ^ 2 * (m ^ 3 * N) when the edge variables vanish off a symmetric bounded-degree graph and are uncorrelated across graph-separated edges.

theorem var_edge_sum_le reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

Variance of an edge-sum over a bounded-degree dependency graph. Consider real-valued statistics b i j attached to ordered pairs of units, all defined on the same finite design. Suppose every statistic attached to an edge of a graph G is bounded in absolute value by a nonnegative constant M, G is symmetric, every unit has at most m neighbours in G, every statistic attached to a pair that is not an edge of G is identically zero, and two statistics are uncorrelated whenever no edge of G connects an endpoint of one pair to an endpoint of the other. Then the variance of the double sum ∑ᵢ∑ⱼ b i j is at most 8·M²·m³·N, where N is the number of units.

Formal statement
Ω :
Type u_1
shared
D :
shared
ι :
Type*
b :
ι → ι → Ω → ℝ
G :
ι → ι → Prop
M :
ℝ
hM :
0 ≤ M
hbound :
∀ i j
if
G i j
then
∀ z, |b i j z| ≤ M
hsymm :
∀ i j
if
G i j
then
G j i
m :
ℕ
hdeg :
∀ i, (Finset.univ.filter (fun j => G i j)).card ≤ m
hvanish :
∀ i j
if
¬ G i j
then
b i j = fun _ => 0
hcov0 :
∀ i j k l
if
¬ (G i k ∨ G i l ∨ G j k ∨ G j l)
then
D.Cov (b i j) (b k l) = 0
D.Var (fun z => ∑ i, ∑ j, b i j z) ≤ 8 * M ^ 2 * ((m : ℝ) ^ 3 * (Fintype.card ι : ℝ))
Proof (Lean source)
theorem var_edge_sum_le {ι : Type*} [Fintype ι] (b : ι → ι → Ω → ℝ) (G : ι → ι → Prop) [DecidableRel G] {M : ℝ} (hM : 0 ≤ M) (hbound : ∀ i j, G i j → ∀ z, |b i j z| ≤ M) (hsymm : ∀ i j, G i j → G j i) {m : ℕ} (hdeg : ∀ i, (Finset.univ.filter (fun j => G i j)).card ≤ m) (hvanish : ∀ i j, ¬ G i j → b i j = fun _ => 0) (hcov0 : ∀ i j k l, ¬ (G i k ∨ G i l ∨ G j k ∨ G j l) → D.Cov (b i j) (b k l) = 0) : D.Var (fun z => ∑ i, ∑ j, b i j z) ≤ 8 * M ^ 2 * ((m : ℝ) ^ 3 * (Fintype.card ι : ℝ)) := by classical -- local indicator set χ : Prop → ℝ := fun p => if p then (1 : ℝ) else 0 with hχdef have χ_nonneg : ∀ p, 0 ≤ χ p := by intro p; by_cases h : p <;> simp [hχdef, h] have χ_le_one : ∀ p, χ p ≤ 1 := by intro p; by_cases h : p <;> simp [hχdef, h] -- degree-sum bound: ∑ j χ(G i j) ≤ m have hdegsum : ∀ i : ι, (∑ j, χ (G i j)) ≤ (m : ℝ) := by intro i have : (∑ j, χ (G i j)) = ((Finset.univ.filter (fun j => G i j)).card : ℝ) := by convert Finset.sum_boole (fun j => G i j) Finset.univ using 3 rw [this] exact_mod_cast hdeg i -- out-degree via symmetry: ∑ k χ(G k l) ≤ m have hdegsum' : ∀ l : ι, (∑ k, χ (G k l)) ≤ (m : ℝ) := by intro l have hcong : (∑ k, χ (G k l)) = (∑ k, χ (G l k)) := by apply Finset.sum_congr rfl intro k _ have : G k l ↔ G l k := ⟨hsymm k l, hsymm l k⟩ simp only [this] rw [hcong] exact hdegsum l -- (a) expand the variance as a quadruple sum of covariances have hexpand : D.Var (fun z => ∑ i, ∑ j, b i j z) = ∑ i, ∑ j, ∑ k, ∑ l, D.Cov (b i j) (b k l) := by have hrw : (fun z => ∑ i, ∑ j, b i j z) = (fun z => ∑ p ∈ (Finset.univ : Finset (ι × ι)), (1 : ℝ) * b p.1 p.2 z) := by funext z rw [Fintype.sum_prod_type] apply Finset.sum_congr rfl; intro i _ apply Finset.sum_congr rfl; intro j _ rw [one_mul] rw [hrw, D.Var_linear_comb (Finset.univ : Finset (ι × ι)) (fun _ => 1) (fun p z => b p.1 p.2 z)] rw [Fintype.sum_prod_type] apply Finset.sum_congr rfl; intro i _ apply Finset.sum_congr rfl; intro j _ rw [Fintype.sum_prod_type] apply Finset.sum_congr rfl; intro k _ apply Finset.sum_congr rfl; intro l _ rw [one_mul, one_mul] rw [hexpand] -- (b) termwise bound: Cov ≤ |Cov| ≤ (2M²)·bracket set bracket : ι → ι → ι → ι → ℝ := fun i j k l => χ (G i j) * χ (G k l) * (χ (G i k) + χ (G i l) + χ (G j k) + χ (G j l)) with hbracketdef have bracket_nonneg : ∀ i j k l, 0 ≤ bracket i j k l := by intro i j k l rw [hbracketdef] apply mul_nonneg (mul_nonneg (χ_nonneg _) (χ_nonneg _)) have h1 := χ_nonneg (G i k); have h2 := χ_nonneg (G i l) have h3 := χ_nonneg (G j k); have h4 := χ_nonneg (G j l) linarith have htermwise : ∀ i j k l, D.Cov (b i j) (b k l) ≤ (2 * M ^ 2) * bracket i j k l := by intro i j k l -- Cov = 0 in the "otherwise" cases, and bracket ≥ 1 in the "all hold" case by_cases hij : G i j · by_cases hkl : G k l · by_cases hconn : G i k ∨ G i l ∨ G j k ∨ G j l · -- all hold: bracket ≥ 1, Cov ≤ |Cov| ≤ 2M² have hb1 : (1 : ℝ) ≤ bracket i j k l := by simp only [hbracketdef] have hχij : χ (G i j) = 1 := by simp [hχdef, hij] have hχkl : χ (G k l) = 1 := by simp [hχdef, hkl] rw [hχij, hχkl, one_mul, one_mul] have n1 := χ_nonneg (G i k); have n2 := χ_nonneg (G i l) have n3 := χ_nonneg (G j k); have n4 := χ_nonneg (G j l) rcases hconn with h | h | h | h · have : χ (G i k) = 1 := by simp [hχdef, h] linarith · have : χ (G i l) = 1 := by simp [hχdef, h] linarith · have : χ (G j k) = 1 := by simp [hχdef, h] linarith · have : χ (G j l) = 1 := by simp [hχdef, h] linarith have hcov : D.Cov (b i j) (b k l) ≤ 2 * M ^ 2 := (le_abs_self _).trans (by simpa [sq, mul_assoc] using D.abs_Cov_le_two_sq hM (hbound i j hij) (hbound k l hkl)) have h2M2 : 0 ≤ 2 * M ^ 2 := by positivity calc D.Cov (b i j) (b k l) ≤ 2 * M ^ 2 := hcov _ = (2 * M ^ 2) * 1 := by ring _ ≤ (2 * M ^ 2) * bracket i j k l := mul_le_mul_of_nonneg_left hb1 h2M2 · -- ¬ connected: Cov = 0, bracket ≥ 0 rw [hcov0 i j k l hconn] exact mul_nonneg (by positivity) (bracket_nonneg i j k l) · -- ¬ G k l: b k l = 0 so Cov = 0 have : D.Cov (b i j) (b k l) = 0 := by rw [D.Cov_congr (X := b i j) (Y := b k l) (X' := b i j) (Y' := fun _ => 0) (fun z => rfl) (fun z => by rw [hvanish k l hkl])] rw [D.Cov_comm, D.Cov_zero_left] rw [this] exact mul_nonneg (by positivity) (bracket_nonneg i j k l) · -- ¬ G i j: b i j = 0 so Cov = 0 have : D.Cov (b i j) (b k l) = 0 := by rw [D.Cov_congr (X := b i j) (Y := b k l) (X' := fun _ => 0) (Y' := b k l) (fun z => by rw [hvanish i j hij]) (fun z => rfl)] rw [D.Cov_zero_left] rw [this] exact mul_nonneg (by positivity) (bracket_nonneg i j k l) -- sum the termwise bound over the quadruple have hsumbound : (∑ i, ∑ j, ∑ k, ∑ l, D.Cov (b i j) (b k l)) ≤ ∑ i, ∑ j, ∑ k, ∑ l, (2 * M ^ 2) * bracket i j k l := by apply Finset.sum_le_sum; intro i _ apply Finset.sum_le_sum; intro j _ apply Finset.sum_le_sum; intro k _ apply Finset.sum_le_sum; intro l _ exact htermwise i j k l refine hsumbound.trans ?_ -- (c) pull out 2M² and split the bracket into four sums have hpull : (∑ i, ∑ j, ∑ k, ∑ l, (2 * M ^ 2) * bracket i j k l) = (2 * M ^ 2) * (∑ i, ∑ j, ∑ k, ∑ l, bracket i j k l) := by rw [Finset.mul_sum] apply Finset.sum_congr rfl; intro i _ rw [Finset.mul_sum] apply Finset.sum_congr rfl; intro j _ rw [Finset.mul_sum] apply Finset.sum_congr rfl; intro k _ rw [Finset.mul_sum] rw [hpull] -- split bracket into S1+S2+S3+S4 set S : (ι → ι → ι → ι → ℝ) → ℝ := fun f => ∑ i, ∑ j, ∑ k, ∑ l, f i j k l with hSdef have hsplit : (∑ i, ∑ j, ∑ k, ∑ l, bracket i j k l) = S (fun i j k l => χ (G i j) * χ (G k l) * χ (G i k)) + S (fun i j k l => χ (G i j) * χ (G k l) * χ (G i l)) + S (fun i j k l => χ (G i j) * χ (G k l) * χ (G j k)) + S (fun i j k l => χ (G i j) * χ (G k l) * χ (G j l)) := by simp only [hSdef] simp only [← Finset.sum_add_distrib] apply Finset.sum_congr rfl; intro i _ apply Finset.sum_congr rfl; intro j _ apply Finset.sum_congr rfl; intro k _ apply Finset.sum_congr rfl; intro l _ rw [hbracketdef]; ring rw [hsplit] -- Each of S1..S4 ≤ N·m³. We prove a generic factorization helper. -- Helper: ∑ over a slot of χ(edge) * (nonneg) ≤ m * sup, using degree bounds. -- We just prove the four bounds directly. have h2M2nn : (0 : ℝ) ≤ 2 * M ^ 2 := by positivity have hmnn : (0 : ℝ) ≤ (m : ℝ) := by positivity -- S1 = ∑i ∑j ∑k ∑l χ(Gij) χ(Gkl) χ(Gik) -- factor: ∑i (∑j χ(Gij)) * (∑k χ(Gik) * (∑l χ(Gkl))) have hS1 : S (fun i j k l => χ (G i j) * χ (G k l) * χ (G i k)) ≤ (Fintype.card ι : ℝ) * (m : ℝ) ^ 3 := by simp only [hSdef] have hcard : (Fintype.card ι : ℝ) * (m : ℝ) ^ 3 = ∑ _i : ι, (m : ℝ) ^ 3 := by rw [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] rw [hcard] apply Finset.sum_le_sum; intro i _ -- bound ∑j∑k∑l χ(Gij)χ(Gkl)χ(Gik) ≤ m^3 -- = (∑j χ(Gij)) * (∑k χ(Gik) * (∑l χ(Gkl))) have hfact : (∑ j, ∑ k, ∑ l, χ (G i j) * χ (G k l) * χ (G i k)) = (∑ j, χ (G i j)) * (∑ k, χ (G i k) * (∑ l, χ (G k l))) := by rw [Finset.sum_mul] refine Finset.sum_congr rfl (fun j _ => ?_) rw [Finset.mul_sum] refine Finset.sum_congr rfl (fun k _ => ?_) rw [Finset.mul_sum, Finset.mul_sum] refine Finset.sum_congr rfl (fun l _ => ?_) ring rw [hfact] -- inner: ∑k χ(Gik) * (∑l χ(Gkl)) ≤ ∑k χ(Gik) * m ≤ m * m have hinner : (∑ k, χ (G i k) * (∑ l, χ (G k l))) ≤ (m : ℝ) ^ 2 := by have h1 : (∑ k, χ (G i k) * (∑ l, χ (G k l))) ≤ ∑ k, χ (G i k) * (m : ℝ) := by apply Finset.sum_le_sum; intro k _ exact mul_le_mul_of_nonneg_left (hdegsum k) (χ_nonneg _) have h2 : (∑ k, χ (G i k) * (m : ℝ)) = (∑ k, χ (G i k)) * (m : ℝ) := by rw [Finset.sum_mul] have h3 : (∑ k, χ (G i k)) * (m : ℝ) ≤ (m : ℝ) * (m : ℝ) := mul_le_mul_of_nonneg_right (hdegsum i) hmnn calc (∑ k, χ (G i k) * (∑ l, χ (G k l))) ≤ (∑ k, χ (G i k)) * (m : ℝ) := by rw [← h2]; exact h1 _ ≤ (m : ℝ) * (m : ℝ) := h3 _ = (m : ℝ) ^ 2 := by ring have hjsum : (∑ j, χ (G i j)) ≤ (m : ℝ) := hdegsum i have hinner_nn : (0 : ℝ) ≤ ∑ k, χ (G i k) * (∑ l, χ (G k l)) := Finset.sum_nonneg (fun k _ => mul_nonneg (χ_nonneg _) (Finset.sum_nonneg (fun l _ => χ_nonneg _))) have hjsum_nn : (0 : ℝ) ≤ ∑ j, χ (G i j) := Finset.sum_nonneg (fun j _ => χ_nonneg _) calc (∑ j, χ (G i j)) * (∑ k, χ (G i k) * (∑ l, χ (G k l))) ≤ (m : ℝ) * (m : ℝ) ^ 2 := mul_le_mul hjsum hinner hinner_nn hmnn _ = (m : ℝ) ^ 3 := by ring -- S2 = ∑i∑j∑k∑l χ(Gij)χ(Gkl)χ(Gil) -- factor: ∑i (∑j χ(Gij)) * (∑l χ(Gil) * (∑k χ(Gkl))) -- middle edge i–l have hS2 : S (fun i j k l => χ (G i j) * χ (G k l) * χ (G i l)) ≤ (Fintype.card ι : ℝ) * (m : ℝ) ^ 3 := by simp only [hSdef] have hcard : (Fintype.card ι : ℝ) * (m : ℝ) ^ 3 = ∑ _i : ι, (m : ℝ) ^ 3 := by rw [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] rw [hcard] apply Finset.sum_le_sum; intro i _ -- ∑j∑k∑l χ(Gij)χ(Gkl)χ(Gil) = (∑j χ(Gij)) * (∑l χ(Gil) * (∑k χ(Gkl))) have hfact : (∑ j, ∑ k, ∑ l, χ (G i j) * χ (G k l) * χ (G i l)) = (∑ j, χ (G i j)) * (∑ l, χ (G i l) * (∑ k, χ (G k l))) := by rw [Finset.sum_mul] refine Finset.sum_congr rfl (fun j _ => ?_) rw [Finset.sum_comm, Finset.mul_sum] refine Finset.sum_congr rfl (fun l _ => ?_) rw [Finset.mul_sum, Finset.mul_sum] refine Finset.sum_congr rfl (fun k _ => ?_) ring rw [hfact] have hinner : (∑ l, χ (G i l) * (∑ k, χ (G k l))) ≤ (m : ℝ) ^ 2 := by have h1 : (∑ l, χ (G i l) * (∑ k, χ (G k l))) ≤ ∑ l, χ (G i l) * (m : ℝ) := by apply Finset.sum_le_sum; intro l _ exact mul_le_mul_of_nonneg_left (hdegsum' l) (χ_nonneg _) have h2 : (∑ l, χ (G i l) * (m : ℝ)) = (∑ l, χ (G i l)) * (m : ℝ) := by rw [Finset.sum_mul] have h3 : (∑ l, χ (G i l)) * (m : ℝ) ≤ (m : ℝ) * (m : ℝ) := mul_le_mul_of_nonneg_right (hdegsum i) hmnn calc (∑ l, χ (G i l) * (∑ k, χ (G k l))) ≤ (∑ l, χ (G i l)) * (m : ℝ) := by rw [← h2]; exact h1 _ ≤ (m : ℝ) * (m : ℝ) := h3 _ = (m : ℝ) ^ 2 := by ring have hjsum : (∑ j, χ (G i j)) ≤ (m : ℝ) := hdegsum i have hinner_nn : (0 : ℝ) ≤ ∑ l, χ (G i l) * (∑ k, χ (G k l)) := Finset.sum_nonneg (fun l _ => mul_nonneg (χ_nonneg _) (Finset.sum_nonneg (fun k _ => χ_nonneg _))) have hjsum_nn : (0 : ℝ) ≤ ∑ j, χ (G i j) := Finset.sum_nonneg (fun j _ => χ_nonneg _) calc (∑ j, χ (G i j)) * (∑ l, χ (G i l) * (∑ k, χ (G k l))) ≤ (m : ℝ) * (m : ℝ) ^ 2 := mul_le_mul hjsum hinner hinner_nn hmnn -- … truncated; follow the source link for the rest …
Causalean.Experimentation.DesignBased.FiniteDesign.var_edge_sum_le · Causalean/Experimentation/DesignBased/EdgeVarianceBound.lean:117 · uses FiniteDesign , Cov , Var
5 supporting declarations (lemmas, instances)
  • abs_E_le lemma — The expectation of a random variable whose absolute value is bounded by M pointwise is itself bounded by M in absolute value.
    Ω :
    Type u_1
    shared
    D :
    shared
    X :
    Ω → ℝ
    M :
    ℝ
    h :
    ∀ z, |X z| ≤ M
    |D.E X| ≤ M
    Proof (Lean source)
    lemma abs_E_le {X : Ω → ℝ} {M : ℝ} (h : ∀ z, |X z| ≤ M) : |D.E X| ≤ M := by apply abs_le.mpr constructor · -- -M ≤ D.E X have hptw : ∀ z, 0 ≤ X z + M := by intro z; have := abs_le.mp (h z); linarith have hpos : 0 ≤ D.E (fun z => X z + M) := D.E_nonneg hptw have heq : D.E (fun z => X z + M) = D.E X + M := by rw [D.E_add]; simp [D.E_const] rw [heq] at hpos; linarith · -- D.E X ≤ M have hptw : ∀ z, 0 ≤ M - X z := by intro z; have := abs_le.mp (h z); linarith have hpos : 0 ≤ D.E (fun z => M - X z) := D.E_nonneg hptw have heq : D.E (fun z => M - X z) = M - D.E X := by rw [D.E_sub]; simp [D.E_const] rw [heq] at hpos; linarith
    Causalean.Experimentation.DesignBased.FiniteDesign.abs_E_le · Causalean/Experimentation/DesignBased/EdgeVarianceBound.lean:45
  • E_mono lemma — If one statistic is pointwise no larger than another, then its design expectation is no larger.
    Ω :
    Type u_1
    shared
    D :
    shared
    X Y :
    Ω → ℝ
    h :
    ∀ z, X z ≤ Y z
    D.E X ≤ D.E Y
    Proof (Lean source)
    lemma E_mono {X Y : Ω → ℝ} (h : ∀ z, X z ≤ Y z) : D.E X ≤ D.E Y := Finset.sum_le_sum (fun z _ => mul_le_mul_of_nonneg_left (h z) (D.p_nonneg z))
    Causalean.Experimentation.DesignBased.FiniteDesign.E_mono · Causalean/Experimentation/DesignBased/EdgeVarianceBound.lean:65
  • abs_E_le_E_abs lemma — The absolute value of a finite-design expectation is at most the expectation of the statistic's absolute value.
    Ω :
    Type u_1
    shared
    D :
    shared
    X :
    Ω → ℝ
    |D.E X| ≤ D.E (fun z => |X z|)
    Proof (Lean source)
    lemma abs_E_le_E_abs (X : Ω → ℝ) : |D.E X| ≤ D.E (fun z => |X z|) := by rw [abs_le] constructor · have hpos : 0 ≤ D.E (fun z => |X z| + X z) := D.E_nonneg (fun z => by linarith [neg_abs_le (X z)]) rw [D.E_add] at hpos linarith · have hpos : 0 ≤ D.E (fun z => |X z| - X z) := D.E_nonneg (fun z => by linarith [le_abs_self (X z)]) rw [D.E_sub] at hpos linarith
    Causalean.Experimentation.DesignBased.FiniteDesign.abs_E_le_E_abs · Causalean/Experimentation/DesignBased/EdgeVarianceBound.lean:70
  • abs_Cov_le_two_sq lemma — The design covariance of random variables bounded by MX and MY in absolute value pointwise is bounded by 2·MX·MY in absolute value.
    Ω :
    Type u_1
    shared
    D :
    shared
    X Y :
    Ω → ℝ
    MX MY :
    ℝ
    hMX :
    0 ≤ MX
    hX :
    ∀ z, |X z| ≤ MX
    hY :
    ∀ z, |Y z| ≤ MY
    |D.Cov X Y| ≤ 2 * MX * MY
    Proof (Lean source)
    lemma abs_Cov_le_two_sq {X Y : Ω → ℝ} {MX MY : ℝ} (hMX : 0 ≤ MX) (hX : ∀ z, |X z| ≤ MX) (hY : ∀ z, |Y z| ≤ MY) : |D.Cov X Y| ≤ 2 * MX * MY := by rw [D.Cov_eq] have hExy : |D.E (fun z => X z * Y z)| ≤ MX * MY := by apply D.abs_E_le (X := fun z => X z * Y z) (M := MX * MY) intro z rw [abs_mul] exact mul_le_mul (hX z) (hY z) (abs_nonneg _) hMX have hEX : |D.E X| ≤ MX := D.abs_E_le hX have hEY : |D.E Y| ≤ MY := D.abs_E_le hY have hprod : |D.E X * D.E Y| ≤ MX * MY := by rw [abs_mul] exact mul_le_mul hEX hEY (abs_nonneg _) hMX calc |D.E (fun z => X z * Y z) - D.E X * D.E Y| ≤ |D.E (fun z => X z * Y z)| + |D.E X * D.E Y| := abs_sub _ _ _ ≤ MX * MY + MX * MY := by linarith _ = 2 * MX * MY := by ring
    Causalean.Experimentation.DesignBased.FiniteDesign.abs_Cov_le_two_sq · Causalean/Experimentation/DesignBased/EdgeVarianceBound.lean:84
  • Cov_zero_left lemma — The covariance of the identically-zero random variable with anything is zero.
    Ω :
    Type u_1
    shared
    D :
    shared
    Y :
    Ω → ℝ
    D.Cov (fun _ => 0) Y = 0
    Proof (Lean source)
    lemma Cov_zero_left (Y : Ω → ℝ) : D.Cov (fun _ => 0) Y = 0 := by rw [D.Cov_eq] have h1 : D.E (fun z => (0 : ℝ) * Y z) = 0 := by rw [D.E_congr (fun z => zero_mul (Y z)), D.E_const] have h2 : D.E (fun _ : Ω => (0 : ℝ)) = 0 := D.E_const 0 rw [h1, h2]; ring
    Causalean.Experimentation.DesignBased.FiniteDesign.Cov_zero_left · Causalean/Experimentation/DesignBased/EdgeVarianceBound.lean:105
Heyde­Brown­Bridge 14 core · 6 supporting This module turns a finite product randomization design into the product probability space and reveal filtration needed by a supplied fourth-moment Kolmogorov-bound premise. ★ finiteDesign_kolmogorovBound_of_heydeBrownPremise

Finite-design fourth-moment-premise bridge

This module turns a finite product randomization design into the product probability space and reveal filtration needed by a supplied fourth-moment Kolmogorov-bound premise. It identifies the finite and measure-theoretic conditional expectations, predictable variations, moments, and CDF expressions, then transports that supplied premise without proving a Heyde--Brown inequality.

def prefixRank reviewed
Causalean.Experimentation.DesignBased

A reveal permutation and coordinate determine that coordinate's reveal rank, namely the step at which the permutation reveals it.

Definition (Lean source)
N :
ℕ
shared
pi :
Perm (Fin N)
i :
Fin N
prefixRank pi i :
Fin N
pi.symm i
Causalean.Experimentation.DesignBased.prefixRank · Causalean/Experimentation/DesignBased/HeydeBrownBridge.lean:34
def AgreeOnPrefix reviewed
Causalean.Experimentation.DesignBased

A reveal permutation, prefix length, and two assignments determine agreement through the reveal prefix: the assignments have the same values on every coordinate already revealed by this equality condition.

Definition (Lean source)
N :
ℕ
Fin N → Type u_1
shared
pi :
Perm (Fin N)
k :
Fin (N + 1)
w w' :
∀ i, alpha i
i :
(prefixRank pi i).val < k.val
AgreeOnPrefix pi k w w' :
Prop
w' i = w i
Causalean.Experimentation.DesignBased.AgreeOnPrefix · Causalean/Experimentation/DesignBased/HeydeBrownBridge.lean:38
def revealMeasurableSpace reviewed
Causalean.Experimentation.DesignBased

A reveal permutation and prefix length determine the σ-algebra generated by the revealed coordinates, which records exactly the information available after that many reveal steps by generating from those coordinate evaluations.

Definition (Lean source)
N :
ℕ
Fin N → Type u_1
shared
pi :
Perm (Fin N)
k :
Fin (N + 1)
revealMeasurableSpace pi k :
MeasurableSpace (∀ i, alpha i)
⨆ i, if (prefixRank pi i).val < k.val then comap (fun w : ∀ j, alpha j => w i) inferInstance else ⊥
Causalean.Experimentation.DesignBased.revealMeasurableSpace · Causalean/Experimentation/DesignBased/HeydeBrownBridge.lean:45
def revealFiltration reviewed
Causalean.Experimentation.DesignBased

A reveal permutation determines the reveal filtration, whose time-k σ-algebra is the prefix σ-algebra, is monotone in reveal time, and lies inside the full product σ-algebra.

Definition (Lean source)
N :
ℕ
Fin N → Type u_1
shared
pi :
Perm (Fin N)
revealFiltration pi :
Filtration (Fin (N + 1)) (inferInstance : MeasurableSpace (∀ i, alpha i))
clause 2
mono' := by intro k l hkl unfold revealMeasurableSpace refine iSup_mono fun i ↦ ?_ by_cases hik : (prefixRank pi i).val < k.val · have hil : (prefixRank pi i).val < l.val := lt_of_lt_of_le hik hkl simp [hik, hil] · simp [hik]
clause 3
le' := by intro k unfold revealMeasurableSpace refine iSup_le fun i ↦ ?_ split_ifs · simpa only [pi] using (le_iSup (fun j : Fin N ↦ comap (fun w : ∀ q, alpha q => w j) inferInstance) i) · exact bot_le
Causalean.Experimentation.DesignBased.revealFiltration · Causalean/Experimentation/DesignBased/HeydeBrownBridge.lean:54
def prefixCondExp reviewed
Causalean.Experimentation.DesignBased

A family of coordinate designs, reveal permutation, prefix length, and statistic determine the explicit prefix conditional expectation, obtained by averaging over unrevealed coordinates while holding revealed coordinates fixed by the stated finite sum.

Definition (Lean source)
N :
ℕ
Fin N → Type u_1
shared
D :
∀ i, FiniteDesign (alpha i)
pi :
Perm (Fin N)
k :
Fin (N + 1)
f :
(∀ i, alpha i) → ℝ
prefixCondExp D pi k f :
(∀ i, alpha i) → ℝ
by classical exact fun w ↦ ∑ w' : ∀ i, alpha i, if AgreeOnPrefix pi k w w' then (∏ i, if k.val ≤ (prefixRank pi i).val then (D i).p (w' i) else 1) * f w' else 0
Causalean.Experimentation.DesignBased.prefixCondExp · Causalean/Experimentation/DesignBased/HeydeBrownBridge.lean:78 · uses FiniteDesign
def IsPrefixMartingaleDifference reviewed
Causalean.Experimentation.DesignBased

A family of coordinate designs, reveal permutation, and increment family satisfy the prefix martingale-difference condition when each increment has zero conditional mean immediately before its reveal and is visible after that reveal.

Definition (Lean source)
N :
ℕ
Fin N → Type u_1
shared
D :
∀ i, FiniteDesign (alpha i)
pi :
Perm (Fin N)
X :
Fin N → (∀ i, alpha i) → ℝ
IsPrefixMartingaleDifference D pi X :
Prop
clause 1
s :
prefixCondExp D pi (castSucc s) (X s) = 0
clause 2
s :
prefixCondExp D pi (succ s) (X s) = X s
Causalean.Experimentation.DesignBased.IsPrefixMartingaleDifference · Causalean/Experimentation/DesignBased/HeydeBrownBridge.lean:92 · uses FiniteDesign
def finitePredictableVariation reviewed
Causalean.Experimentation.DesignBased

A family of coordinate designs, reveal permutation, and increment family determine the finite-design predictable variation, the sum of conditional second moments just before each reveal step by the displayed finite sum.

Definition (Lean source)
N :
ℕ
Fin N → Type u_1
shared
D :
∀ i, FiniteDesign (alpha i)
pi :
Perm (Fin N)
X :
Fin N → (∀ i, alpha i) → ℝ
finitePredictableVariation D pi X :
(∀ i, alpha i) → ℝ
fun w ↦ ∑ s, prefixCondExp D pi (castSucc s) (fun z ↦ (X s z) ^ 2) w
Causalean.Experimentation.DesignBased.finitePredictableVariation · Causalean/Experimentation/DesignBased/HeydeBrownBridge.lean:101 · uses FiniteDesign
def measurePredictableVariation reviewed
Causalean.Experimentation.DesignBased

A measure (in intended use a probability measure; none is required), filtration, and increment family determine the measure-theoretic predictable variation, the sum of conditional second moments at the preceding filtration times by the displayed finite sum.

Definition (Lean source)
N :
ℕ
shared
Omega :
Type*
mu :
Measure Omega
F :
Filtration (Fin (N + 1)) m
X :
Fin N → Omega → ℝ
measurePredictableVariation mu F X :
Omega → ℝ
fun w ↦ ∑ s, mu[(fun z ↦ (X s z) ^ 2) | F (castSucc s)] w
Causalean.Experimentation.DesignBased.measurePredictableVariation · Causalean/Experimentation/DesignBased/HeydeBrownBridge.lean:109
def finiteFourthMomentError reviewed
Causalean.Experimentation.DesignBased

A family of coordinate designs, reveal permutation, and increment family determine the finite fourth-moment error: the sum of fourth moments plus the second moment of predictable variation minus one by the displayed sum of two terms.

Definition (Lean source)
N :
ℕ
Fin N → Type u_1
shared
D :
∀ i, FiniteDesign (alpha i)
pi :
Perm (Fin N)
X :
Fin N → (∀ i, alpha i) → ℝ
finiteFourthMomentError D pi X :
ℝ
(∑ s, (prodDesign D).E (fun w ↦ |X s w| ^ 4))
+ (prodDesign D).E (fun w ↦ |finitePredictableVariation D pi X w - 1| ^ 2)
Causalean.Experimentation.DesignBased.finiteFourthMomentError · Causalean/Experimentation/DesignBased/HeydeBrownBridge.lean:117 · uses FiniteDesign
def measureFourthMomentError reviewed
Causalean.Experimentation.DesignBased

A measure (in intended use a probability measure; none is required), filtration, and increment family determine the measure-theoretic fourth-moment error: the sum of fourth moments plus the second moment of predictable variation minus one by the displayed sum of two terms.

Definition (Lean source)
N :
ℕ
shared
Omega :
Type*
mu :
Measure Omega
F :
Filtration (Fin (N + 1)) m
X :
Fin N → Omega → ℝ
measureFourthMomentError mu F X :
ℝ
(∑ s, ∫ w, |X s w| ^ 4 ∂mu) + ∫ w, |measurePredictableVariation mu F X w - 1| ^ 2 ∂mu
Causalean.Experimentation.DesignBased.measureFourthMomentError · Causalean/Experimentation/DesignBased/HeydeBrownBridge.lean:125
def finiteKolmogorovExpr reviewed
Causalean.Experimentation.DesignBased

A finite randomization design and real statistic determine its finite-design Kolmogorov expression, the largest absolute gap between its CDF and the standard-normal CDF by taking the supremum over thresholds.

Definition (Lean source)
Omega :
Type*
Fintype Omega
D :
Y :
Omega → ℝ
finiteKolmogorovExpr D Y :
ℝ
sSup (Set.range fun t : ℝ ↦ |D.Pr (fun w ↦ Y w ≤ t) - stdNormalCdf t|)
Causalean.Experimentation.DesignBased.finiteKolmogorovExpr · Causalean/Experimentation/DesignBased/HeydeBrownBridge.lean:134 · uses FiniteDesign
def measureKolmogorovExpr reviewed
Causalean.Experimentation.DesignBased

A measure and real random variable determine its measure-theoretic Kolmogorov expression, the largest absolute gap between its CDF and the standard-normal CDF by taking the supremum over thresholds. No probability-measure assumption is made: the CDF term is the real-valued measure of the lower set (zero where that measure is infinite), and an unbounded family of gaps has supremum zero by convention; for a probability measure the gaps are bounded and this is the usual Kolmogorov distance.

Definition (Lean source)
Omega :
Type*
mu :
Measure Omega
Y :
Omega → ℝ
measureKolmogorovExpr mu Y :
ℝ
sSup (Set.range fun t : ℝ ↦ |mu.real {w | Y w ≤ t} - stdNormalCdf t|)
Causalean.Experimentation.DesignBased.measureKolmogorovExpr · Causalean/Experimentation/DesignBased/HeydeBrownBridge.lean:141
def HeydeBrownFourthMomentPremise reviewed
Causalean.Experimentation.DesignBased

A measure (in intended use a probability measure; the premise itself does not require one), filtration, increment family, and constant define the supplied Heyde--Brown fourth-moment premise: adapted, centered, normalized increments with finite fourth moments obey the stated one-fifth-power Kolmogorov bound by the four displayed assumptions and conclusion.

Definition (Lean source)
N :
ℕ
shared
Omega :
Type*
mu :
Measure Omega
F :
Filtration (Fin (N + 1)) m
X :
Fin N → Omega → ℝ
C :
ℝ
(∀ s, AEStronglyMeasurable[F (succ s)] (X s) mu)
(∀ s, mu[X s | F (castSucc s)] =ᵐ[mu] 0)
(∑ s, ∫ w, (X s w) ^ 2 ∂mu) = 1
(∀ s, MemLp (X s) 4 mu)
HeydeBrownFourthMomentPremise mu F X C :
Prop
measureKolmogorovExpr mu (fun w ↦ ∑ s, X s w)
≤ C * rpow (measureFourthMomentError mu F X) (1 / 5 : ℝ)
Causalean.Experimentation.DesignBased.HeydeBrownFourthMomentPremise · Causalean/Experimentation/DesignBased/HeydeBrownBridge.lean:151
theorem finiteDesign_kolmogorovBound_of_heydeBrownPremise reviewed
Causalean.Experimentation.DesignBased

Given coordinate designs, a reveal permutation, an increment family, and a bound constant, if the increments are prefix martingale differences, their total second moment is one, and the supplied Heyde--Brown premise holds, then their sum satisfies the finite-design Kolmogorov bound transported from that premise.

Formal statement
N :
ℕ
Fin N → Type u_1
shared
D :
∀ i, FiniteDesign (alpha i)
pi :
Perm (Fin N)
X :
Fin N → (∀ i, alpha i) → ℝ
C :
ℝ
hsecond :
∑ s, (prodDesign D).E (fun w ↦ (X s w) ^ 2) = 1
hHeydeBrown :
finiteKolmogorovExpr (prodDesign D) (fun w ↦ ∑ s, X s w)
≤ C * rpow (finiteFourthMomentError D pi X) (1 / 5 : ℝ)
Proof (Lean source)
theorem finiteDesign_kolmogorovBound_of_heydeBrownPremise (D : ∀ i, FiniteDesign (alpha i)) (pi : Perm (Fin N)) (X : Fin N → (∀ i, alpha i) → ℝ) (C : ℝ) (hX : IsPrefixMartingaleDifference D pi X) (hsecond : ∑ s, (prodDesign D).E (fun w ↦ (X s w) ^ 2) = 1) (hHeydeBrown : HeydeBrownFourthMomentPremise (prodDesign D).toMeasure (revealFiltration pi) X C) : finiteKolmogorovExpr (prodDesign D) (fun w ↦ ∑ s, X s w) ≤ C * rpow (finiteFourthMomentError D pi X) (1 / 5 : ℝ) := by rw [finiteKolmogorovExpr_eq_measureKolmogorovExpr, finiteFourthMomentError_eq_measureFourthMomentError] exact hHeydeBrown (fun s ↦ aestronglyMeasurable_reveal_of_prefixCondExp_eq D pi (succ s) (X s) (hX.2 s)) (fun s ↦ condExp_ae_eq_zero_of_prefixCondExp_eq_zero D pi (castSucc s) (X s) (hX.1 s)) (by simpa only [← (prodDesign D).E_eq_integral] using hsecond) (fun s ↦ (prodDesign D).memLp_toMeasure (X s) 4)
6 supporting declarations (lemmas, instances)
  • prefixCondExp_ae_eq_condExp theorem — A family of coordinate designs, reveal permutation, prefix length, and statistic give an almost-everywhere identification of the explicit prefix average with conditional expectation under the product-design measure and its reveal σ-algebra.
    N :
    ℕ
    Fin N → Type u_1
    shared
    D :
    ∀ i, FiniteDesign (alpha i)
    pi :
    Perm (Fin N)
    k :
    Fin (N + 1)
    f :
    (∀ i, alpha i) → ℝ
    prefixCondExp D pi k f
    =ᵐ[(prodDesign D).toMeasure] (prodDesign D).toMeasure[f | (revealFiltration pi) k]
    Proof (Lean source)
    theorem prefixCondExp_ae_eq_condExp (D : ∀ i, FiniteDesign (alpha i)) (pi : Perm (Fin N)) (k : Fin (N + 1)) (f : (∀ i, alpha i) → ℝ) : prefixCondExp D pi k f =ᵐ[(prodDesign D).toMeasure] (prodDesign D).toMeasure[f | (revealFiltration pi) k] := by classical let m0 : MeasurableSpace (∀ i, alpha i) := inferInstance let m : MeasurableSpace (∀ i, alpha i) := (revealFiltration pi) k let mInv : MeasurableSpace (∀ i, alpha i) := by exact { MeasurableSet' := fun s ↦ ∀ w w', AgreeOnPrefix pi k w w' → (w ∈ s ↔ w' ∈ s) measurableSet_empty := by simp measurableSet_compl := by intro s hs w w' hww' simpa only [Set.mem_compl_iff] using not_congr (hs w w' hww') measurableSet_iUnion := by intro s hs w w' hww' constructor <;> intro hw · simp only [Set.mem_iUnion] at hw ⊢ obtain ⟨i, hi⟩ := hw exact ⟨i, (hs i w w' hww').1 hi⟩ · simp only [Set.mem_iUnion] at hw ⊢ obtain ⟨i, hi⟩ := hw exact ⟨i, (hs i w w' hww').2 hi⟩ } have hm : m ≤ m0 := by simpa only [m, m0] using (revealFiltration pi).le k have hmInv : m ≤ mInv := by unfold m revealFiltration revealMeasurableSpace refine iSup_le fun i ↦ ?_ by_cases hi : (prefixRank pi i).val < k.val · simp only [hi, if_true] intro s hs rw [MeasurableSpace.measurableSet_comap] at hs obtain ⟨t, ht, rfl⟩ := hs change ∀ w w', AgreeOnPrefix pi k w w' → (w i ∈ t ↔ w' i ∈ t) intro w w' hww' rw [hww' i hi] · simp [hi] have hmem_of_agree {s : Set (∀ i, alpha i)} (hs : MeasurableSet[m] s) {w w' : ∀ i, alpha i} (hww' : AgreeOnPrefix pi k w w') : w ∈ s ↔ w' ∈ s := by exact hmInv s hs w w' hww' have hcell (w' : ∀ i, alpha i) : MeasurableSet[m] {w | AgreeOnPrefix pi k w w'} := by have hset : {w | AgreeOnPrefix pi k w w'} = ⋂ i, if (prefixRank pi i).val < k.val then {w | w i = w' i} else univ := by ext w simp only [Set.mem_ofPred_eq, Set.mem_iInter] constructor · intro h i by_cases hi : (prefixRank pi i).val < k.val · simp [hi, (h i hi).symm] · simp [hi] · intro h i hi have h' : w i = w' i := by simpa [hi] using h i exact h'.symm rw [hset] refine MeasurableSet.iInter fun i ↦ ?_ by_cases hi : (prefixRank pi i).val < k.val · simp only [hi, if_true] have hbase : MeasurableSet[ comap (fun w : ∀ q, alpha q => w i) (inferInstance)] {w | w i = w' i} := (measurableSet_singleton (w' i)).preimage (comap_measurable (fun w : ∀ q, alpha q => w i)) have hcomponent : MeasurableSet[ if (prefixRank pi i).val < k.val then comap (fun w : ∀ q, alpha q => w i) inferInstance else ⊥] {w | w i = w' i} := by rw [if_pos hi] exact hbase exact (le_iSup (fun j : Fin N ↦ if (prefixRank pi j).val < k.val then comap (fun w : ∀ q, alpha q => w j) inferInstance else ⊥) i) _ hcomponent · simp [hi] have hmeas : Measurable[m] (prefixCondExp D pi k f) := by unfold prefixCondExp exact Finset.measurable_sum univ fun w' _ ↦ Measurable.ite (hcell w') measurable_const measurable_const let _ : MeasurableSpace (∀ i, alpha i) := m0 have hf : Integrable f (prodDesign D).toMeasure := Integrable.of_finite refine ae_eq_condExp_of_forall_setIntegral_eq hm hf ?_ ?_ hmeas.stronglyMeasurable.aestronglyMeasurable · intro s _ _ exact (show Integrable (prefixCondExp D pi k f) (prodDesign D).toMeasure from Integrable.of_finite).integrableOn · intro s hs _ have hs0 : MeasurableSet[m0] s := hm s hs rw [← integral_indicator hs0, ← integral_indicator hs0, FiniteDesign.integral_toMeasure, FiniteDesign.integral_toMeasure] have hmass (w' : ∀ i, alpha i) : (∑ z : ∀ i, alpha i, if AgreeOnPrefix pi k z w' then ∏ i, (D i).p (z i) else 0) = ∏ i, if (prefixRank pi i).val < k.val then (D i).p (w' i) else 1 := by have hterm (z : ∀ i, alpha i) : (if AgreeOnPrefix pi k z w' then ∏ i, (D i).p (z i) else 0) = ∏ i, if (prefixRank pi i).val < k.val then if z i = w' i then (D i).p (z i) else 0 else (D i).p (z i) := by by_cases hz : AgreeOnPrefix pi k z w' · rw [if_pos hz] apply Finset.prod_congr rfl intro i _ by_cases hi : (prefixRank pi i).val < k.val · simp [hi, (hz i hi).symm] · simp [hi] · rw [if_neg hz] simp only [AgreeOnPrefix] at hz push Not at hz obtain ⟨i, hi, hne⟩ := hz exact (Finset.prod_eq_zero (Finset.mem_univ i) (by simp [hi, hne.symm])).symm calc (∑ z : ∀ i, alpha i, if AgreeOnPrefix pi k z w' then ∏ i, (D i).p (z i) else 0) = ∑ z : ∀ i, alpha i, ∏ i, if (prefixRank pi i).val < k.val then if z i = w' i then (D i).p (z i) else 0 else (D i).p (z i) := Finset.sum_congr rfl fun z _ ↦ hterm z _ = ∏ i, ∑ a : alpha i, if (prefixRank pi i).val < k.val then if a = w' i then (D i).p a else 0 else (D i).p a := (Fintype.prod_sum (fun i (a : alpha i) ↦ if (prefixRank pi i).val < k.val then if a = w' i then (D i).p a else 0 else (D i).p a)).symm _ = ∏ i, if (prefixRank pi i).val < k.val then (D i).p (w' i) else 1 := by apply Finset.prod_congr rfl intro i _ by_cases hi : (prefixRank pi i).val < k.val · simp [hi] · simp [hi, (D i).p_sum] have hsplit (w' : ∀ i, alpha i) : (∏ i, if k.val ≤ (prefixRank pi i).val then (D i).p (w' i) else 1) * (∏ i, if (prefixRank pi i).val < k.val then (D i).p (w' i) else 1) = ∏ i, (D i).p (w' i) := by rw [← Finset.prod_mul_distrib] apply Finset.prod_congr rfl intro i _ by_cases hi : (prefixRank pi i).val < k.val · have hnle : ¬k.val ≤ (prefixRank pi i).val := Nat.not_le_of_gt hi simp [hi, hnle] · have hle : k.val ≤ (prefixRank pi i).val := Nat.le_of_not_gt hi simp [hi, hle] have hswap (z : ∀ i, alpha i) : (∏ i, (D i).p (z i)) * (if z ∈ s then ∑ w' : ∀ i, alpha i, if AgreeOnPrefix pi k z w' then (∏ i, if k.val ≤ (prefixRank pi i).val then (D i).p (w' i) else 1) * f w' else 0 else 0) = ∑ w' : ∀ i, alpha i, if w' ∈ s then (∏ i, if k.val ≤ (prefixRank pi i).val then (D i).p (w' i) else 1) * f w' * (if AgreeOnPrefix pi k z w' then ∏ i, (D i).p (z i) else 0) else 0 := by by_cases hz : z ∈ s · rw [if_pos hz, Finset.mul_sum] apply Finset.sum_congr rfl intro w' _ by_cases ha : AgreeOnPrefix pi k z w' · have hw' : w' ∈ s := (hmem_of_agree hs ha).1 hz simp only [ha, if_true, hw'] ring · simp [ha] · rw [if_neg hz] simp only [mul_zero] symm apply Finset.sum_eq_zero intro w' _ by_cases ha : AgreeOnPrefix pi k z w' · have hw' : w' ∉ s := fun hw' ↦ hz ((hmem_of_agree hs ha).2 hw') simp [hw'] · simp [ha] simp only [FiniteDesign.E, prodDesign_p, indicator, prefixCondExp] calc (∑ z, (∏ i, (D i).p (z i)) * if z ∈ s then ∑ w', if AgreeOnPrefix pi k z w' then (∏ i, if k.val ≤ (prefixRank pi i).val then (D i).p (w' i) else 1) * f w' else 0 else 0) = ∑ z, ∑ w', if w' ∈ s then (∏ i, if k.val ≤ (prefixRank pi i).val then (D i).p (w' i) else 1) * f w' * (if AgreeOnPrefix pi k z w' then ∏ i, (D i).p (z i) else 0) else 0 := Finset.sum_congr rfl fun z _ ↦ hswap z _ = ∑ w', ∑ z, if w' ∈ s then (∏ i, if k.val ≤ (prefixRank pi i).val then (D i).p (w' i) else 1) * f w' * (if AgreeOnPrefix pi k z w' then ∏ i, (D i).p (z i) else 0) else 0 := Finset.sum_comm _ = ∑ w', (∏ i, (D i).p (w' i)) * if w' ∈ s then f w' else 0 := by apply Finset.sum_congr rfl intro w' _ by_cases hw' : w' ∈ s · simp only [hw', if_true] rw [← Finset.mul_sum, hmass] rw [← hsplit w'] ring · simp [hw']
    Causalean.Experimentation.DesignBased.prefixCondExp_ae_eq_condExp · Causalean/Experimentation/DesignBased/HeydeBrownBridge.lean:168
  • aestronglyMeasurable_reveal_of_prefixCondExp_eq theorem — A family of coordinate designs, reveal permutation, prefix length, statistic, and pointwise equality to its prefix conditional expectation imply that the statistic is almost-everywhere strongly measurable for the reveal σ-algebra.
    N :
    ℕ
    Fin N → Type u_1
    shared
    D :
    ∀ i, FiniteDesign (alpha i)
    pi :
    Perm (Fin N)
    k :
    Fin (N + 1)
    f :
    (∀ i, alpha i) → ℝ
    hf :
    prefixCondExp D pi k f = f
    Proof (Lean source)
    theorem aestronglyMeasurable_reveal_of_prefixCondExp_eq (D : ∀ i, FiniteDesign (alpha i)) (pi : Perm (Fin N)) (k : Fin (N + 1)) (f : (∀ i, alpha i) → ℝ) (hf : prefixCondExp D pi k f = f) : AEStronglyMeasurable[(revealFiltration pi) k] f (prodDesign D).toMeasure := by rw [← hf] exact stronglyMeasurable_condExp.aestronglyMeasurable.congr (prefixCondExp_ae_eq_condExp D pi k f).symm
    Causalean.Experimentation.DesignBased.aestronglyMeasurable_reveal_of_prefixCondExp_eq · Causalean/Experimentation/DesignBased/HeydeBrownBridge.lean:387
  • condExp_ae_eq_zero_of_prefixCondExp_eq_zero theorem — A family of coordinate designs, reveal permutation, prefix length, statistic, and zero explicit prefix conditional expectation imply the measure-theoretic conditional expectation is almost everywhere zero.
    N :
    ℕ
    Fin N → Type u_1
    shared
    D :
    ∀ i, FiniteDesign (alpha i)
    pi :
    Perm (Fin N)
    k :
    Fin (N + 1)
    f :
    (∀ i, alpha i) → ℝ
    hf :
    prefixCondExp D pi k f = 0
    (prodDesign D).toMeasure[f | (revealFiltration pi) k] =ᵐ[(prodDesign D).toMeasure] 0
    Proof (Lean source)
    theorem condExp_ae_eq_zero_of_prefixCondExp_eq_zero (D : ∀ i, FiniteDesign (alpha i)) (pi : Perm (Fin N)) (k : Fin (N + 1)) (f : (∀ i, alpha i) → ℝ) (hf : prefixCondExp D pi k f = 0) : (prodDesign D).toMeasure[f | (revealFiltration pi) k] =ᵐ[(prodDesign D).toMeasure] 0 := by simpa only [hf] using (prefixCondExp_ae_eq_condExp D pi k f).symm
    Causalean.Experimentation.DesignBased.condExp_ae_eq_zero_of_prefixCondExp_eq_zero · Causalean/Experimentation/DesignBased/HeydeBrownBridge.lean:398
  • finitePredictableVariation_ae_eq_measurePredictableVariation theorem — A family of coordinate designs, reveal permutation, and increment family give an almost-everywhere equality between finite-design and measure-theoretic predictable variations under the product-design measure.
    N :
    ℕ
    Fin N → Type u_1
    shared
    D :
    ∀ i, FiniteDesign (alpha i)
    pi :
    Perm (Fin N)
    X :
    Fin N → (∀ i, alpha i) → ℝ
    Proof (Lean source)
    theorem finitePredictableVariation_ae_eq_measurePredictableVariation (D : ∀ i, FiniteDesign (alpha i)) (pi : Perm (Fin N)) (X : Fin N → (∀ i, alpha i) → ℝ) : finitePredictableVariation D pi X =ᵐ[(prodDesign D).toMeasure] measurePredictableVariation (prodDesign D).toMeasure (revealFiltration pi) X := by unfold finitePredictableVariation measurePredictableVariation filter_upwards [ae_all_iff.2 (fun s ↦ prefixCondExp_ae_eq_condExp D pi (castSucc s) (fun z ↦ (X s z) ^ 2))] with w hw exact Finset.sum_congr rfl fun s _ ↦ hw s
    Causalean.Experimentation.DesignBased.finitePredictableVariation_ae_eq_measurePredictableVariation · Causalean/Experimentation/DesignBased/HeydeBrownBridge.lean:407
  • finiteKolmogorovExpr_eq_measureKolmogorovExpr theorem — A family of coordinate designs and real statistic give an exact identification between the finite-design and measure-theoretic Kolmogorov expressions under the induced product-design measure.
    N :
    ℕ
    Fin N → Type u_1
    shared
    D :
    ∀ i, FiniteDesign (alpha i)
    Y :
    (∀ i, alpha i) → ℝ
    Proof (Lean source)
    theorem finiteKolmogorovExpr_eq_measureKolmogorovExpr (D : ∀ i, FiniteDesign (alpha i)) (Y : (∀ i, alpha i) → ℝ) : finiteKolmogorovExpr (prodDesign D) Y = measureKolmogorovExpr (prodDesign D).toMeasure Y := by classical unfold finiteKolmogorovExpr measureKolmogorovExpr apply congrArg sSup congr 1 funext t rw [FiniteDesign.Pr_eq_measureReal]
    Causalean.Experimentation.DesignBased.finiteKolmogorovExpr_eq_measureKolmogorovExpr · Causalean/Experimentation/DesignBased/HeydeBrownBridge.lean:421
  • finiteFourthMomentError_eq_measureFourthMomentError theorem — A family of coordinate designs, reveal permutation, and increment family give an exact identification between finite-design and measure-theoretic fourth-moment errors, including the predictable-variation term.
    N :
    ℕ
    Fin N → Type u_1
    shared
    D :
    ∀ i, FiniteDesign (alpha i)
    pi :
    Perm (Fin N)
    X :
    Fin N → (∀ i, alpha i) → ℝ
    Proof (Lean source)
    theorem finiteFourthMomentError_eq_measureFourthMomentError (D : ∀ i, FiniteDesign (alpha i)) (pi : Perm (Fin N)) (X : Fin N → (∀ i, alpha i) → ℝ) : finiteFourthMomentError D pi X = measureFourthMomentError (prodDesign D).toMeasure (revealFiltration pi) X := by unfold finiteFourthMomentError measureFourthMomentError congr 1 · apply Finset.sum_congr rfl intro s _ exact ((prodDesign D).integral_toMeasure (fun w ↦ |X s w| ^ 4)).symm · rw [← (prodDesign D).integral_toMeasure (fun w ↦ |finitePredictableVariation D pi X w - 1| ^ 2)] apply integral_congr_ae filter_upwards [finitePredictableVariation_ae_eq_measurePredictableVariation D pi X] with w hw rw [hw]
    Causalean.Experimentation.DesignBased.finiteFourthMomentError_eq_measureFourthMomentError · Causalean/Experimentation/DesignBased/HeydeBrownBridge.lean:435
Indep­Summands­CLT 2 core · 0 supporting Product-design sums of independent bounded mean-zero summands satisfy a standard-normal limit. ★ prodDesign_clt

Independent-summands CLT for product designs

Product-design sums of independent bounded mean-zero summands satisfy a standard-normal limit.

The construction diagDepGraph supplies the dependency graph whose only edges are self-edges, with independence coming from finite product designs. The theorem prodDesign_clt then specializes the dependency-graph Stein CLT: uniformly bounded, mean-zero coordinate summands with vanishing third-moment envelope and unit total design variance have standard-normal distributional limits under the product design.

def diagDepGraph reviewed
Causalean.Experimentation.DesignBased

At each stage suppose the coordinate index set and every coordinate assignment space are finite, coordinate equality is decidable, and every singleton in every coordinate assignment space is measurable. For a family of coordinate-specific randomization designs, indexed by stage and coordinate, a family of real-valued coordinate summands, and a stage, the diagonal dependency graph is the dependency graph of the coordinate summands under the corresponding product design, in which two coordinates are adjacent exactly when they are the same coordinate.

Definition (Lean source)
ι :
ℕ → Type u_1
(n : ℕ) → ι n → Type u_2
shared
D :
∀ n, ∀ i, FiniteDesign (α n i)
g :
∀ n, ∀ i, α n i → ℝ
n :
ℕ
diagDepGraph D g n :
DepGraph (fun (i : ι n) (w : ∀ j, α n j) => g n i (w i)) (prodDesign (D n)).toMeasure
clause 1
G a b := a = b
clause 2
clause 3
refl _ := rfl
clause 4
symm _ _ h := h.symm
clause 5
meas i := (Measurable.of_discrete).comp (measurable_pi_apply i)
clause 6
indep A B hAB := by have hdisj : Disjoint A B := by rw [Finset.disjoint_left] intro a haA haB exact hAB a haA a haB rfl exact indepFun_prodDesign_apply_blocks (D n) (fun i => Measurable.of_discrete) (fun i => Measurable.of_discrete) hdisj
theorem prodDesign_clt reviewed
Causalean.Experimentation.DesignBased

Independent-summands CLT over product designs. Fix a family of coordinate designs D n i and real-valued per-coordinate summands g n i, one pair per stage n and coordinate i. Suppose there is a sequence of nonnegative bounds B n tending to zero, every summand g n i a is bounded in absolute value by B n, the number of coordinates at stage n times B n cubed tends to zero, each summand has mean zero under its own coordinate design, and the total sum ∑ᵢ g n i (w i) has design variance exactly one under the product design at every stage n. Then the design probability that the sum is at most any fixed threshold s converges, as n → ∞, to the standard normal cumulative distribution function Φ(s).

Formal statement
ι :
ℕ → Type u_1
(n : ℕ) → ι n → Type u_2
shared
D :
∀ n, ∀ i, FiniteDesign (α n i)
g :
∀ n, ∀ i, α n i → ℝ
B :
ℕ → ℝ
hB :
∀ n, 0 ≤ B n
hB0 :
Tendsto B atTop (𝓝 0)
hbound :
∀ n i a, |g n i a| ≤ B n
hNB3 :
Tendsto (fun n => (card (ι n) : ℝ) * (B n) ^ 3) atTop (𝓝 0)
hmean :
∀ n i, (D n i).E (g n i) = 0
hvar :
∀ n, (prodDesign (D n)).Var (fun w => ∑ i, g n i (w i)) = 1
s :
ℝ
Tendsto (fun n => (prodDesign (D n)).Pr (fun w => (∑ i, g n i (w i)) ≤ s)) atTop (𝓝 (stdNormalCdf s))
Proof (Lean source)
theorem prodDesign_clt (D : ∀ n, ∀ i, FiniteDesign (α n i)) (g : ∀ n, ∀ i, α n i → ℝ) (B : ℕ → ℝ) (hB : ∀ n, 0 ≤ B n) (hB0 : Tendsto B atTop (𝓝 0)) (hbound : ∀ n i a, |g n i a| ≤ B n) (hNB3 : Tendsto (fun n => (card (ι n) : ℝ) * (B n) ^ 3) atTop (𝓝 0)) (hmean : ∀ n i, (D n i).E (g n i) = 0) (hvar : ∀ n, (prodDesign (D n)).Var (fun w => ∑ i, g n i (w i)) = 1) (s : ℝ) : Tendsto (fun n => (prodDesign (D n)).Pr (fun w => (∑ i, g n i (w i)) ≤ s)) atTop (𝓝 (stdNormalCdf s)) := by classical -- Probability measures and per-coordinate summands. set μ : ∀ n, Measure (∀ j, α n j) := fun n => (prodDesign (D n)).toMeasure with hμ set X : ∀ n, ι n → (∀ j, α n j) → ℝ := fun n i w => g n i (w i) with hX -- Diagonal dependency graph (independence from the product-measure bridge). set Dg : ∀ n, DepGraph (X n) (μ n) := fun n => diagDepGraph D g n with hDg -- Each summand is measurable. have hmeas : ∀ n i, Measurable (X n i) := fun n i => (Dg n).meas i -- Degree one: the neighborhood of `i` in the diagonal graph is `{i}`. have hdeg : ∀ n i, ((Dg n).nbhd i).card ≤ 1 := by intro n i have hsub : (Dg n).nbhd i ⊆ {i} := by intro j hj rw [Finset.mem_singleton] exact ((Dg n).mem_nbhd_iff.mp hj).symm calc ((Dg n).nbhd i).card ≤ ({i} : Finset (ι n)).card := Finset.card_le_card hsub _ = 1 := Finset.card_singleton i -- Mean-zero: `∫ Xₙᵢ dμₙ = (prodDesign Dₙ).E (Xₙᵢ) = (Dₙᵢ).E (gₙᵢ) = 0`. have hmean' : ∀ n i, ∫ w, X n i w ∂(μ n) = 0 := by intro n i rw [hμ, hX, FiniteDesign.integral_toMeasure, FiniteDesign.E_prod_apply, hmean] -- `depSum (Xₙ) w = ∑ i, g n i (w i)` definitionally. have hdepSum : ∀ n, depSum (X n) = (fun w => ∑ i, g n i (w i)) := fun n => rfl -- The total sum is mean-zero under the product design. have hEsum : ∀ n, (prodDesign (D n)).E (fun w => ∑ i, g n i (w i)) = 0 := by intro n rw [show (fun w : ∀ j, α n j => ∑ i, g n i (w i)) = (fun w => ∑ i, (fun i (w : ∀ j, α n j) => g n i (w i)) i w) from rfl, FiniteDesign.E_sum] refine Finset.sum_eq_zero (fun i _ => ?_) rw [FiniteDesign.E_prod_apply, hmean] -- Unit total variance: `∫ (depSum Xₙ)² dμₙ = 1` (mean-zero so `E[S²] = Var S = 1`). have hvar' : ∀ n, ∫ w, (depSum (X n) w) ^ 2 ∂(μ n) = 1 := by intro n rw [hdepSum n, hμ, FiniteDesign.integral_toMeasure] have hve := FiniteDesign.Var_eq (prodDesign (D n)) (fun w => ∑ i, g n i (w i)) rw [hEsum n, (by ring : (0 : ℝ) ^ 2 = 0), sub_zero] at hve rw [← hve, hvar n] -- Apply the dependency-graph Stein CLT (degree bound `m := 1`). have hbound' : ∀ n i (ω : ∀ j, α n j), |X n i ω| ≤ B n := fun n i ω => hbound n i (ω i) have hclt := stein_cdf_clt_of_depGraph μ X Dg 1 hdeg B hB hbound' hB0 hNB3 hmean' hvar' s -- Rewrite the limit point: `Φ(s) = (gaussianReal 0 1).real (Iic s)` by definition. rw [show stdNormalCdf s = (gaussianReal 0 1).real (Iic s) from rfl] -- Match the prelimit sequences pointwise. refine hclt.congr (fun n => ?_) have hWmeas : Measurable (depSum (X n)) := by fun_prop have hset : {w | (∑ i, g n i (w i)) ≤ s} = (depSum (X n)) ⁻¹' Iic s := by rw [hdepSum n]; rfl rw [hμ] at * rw [← FiniteDesign.toMeasure_real_setOf, hset, MeasureTheory.map_measureReal_apply hWmeas measurableSet_Iic]
Local­Dependence­Variance 2 core · 0 supporting This file provides BlockDegreeLE, the condition that no unit lies in more than d of the dependence blocks, and bernoulliDesign_E_sum_sq_le_blockDegree_mul_sum_sq, the resulting bound E[(∑ᵢ Fᵢ)²] ≤ d · ∑ᵢ E[Fᵢ²] for mean- ★ bernoulliDesign_E_sum_sq_le_blockDegree_mul_sum_sq

Local-dependence variance bound on a Bernoulli design

This file provides BlockDegreeLE, the condition that no unit lies in more than d of the dependence blocks, and bernoulliDesign_E_sum_sq_le_blockDegree_mul_sum_sq, the resulting bound E[(∑ᵢ Fᵢ)²] ≤ d · ∑ᵢ E[Fᵢ²] for mean-zero, block-dependent summands.

def BlockDegreeLE reviewed
Causalean.Experimentation.DesignBased

For a finite population of units, a dependence block assigned to each unit, and a nonnegative integer bound, the assertion that the block family has degree at most dd means that, for every unit, at most dd blocks contain that unit. When the blocks are the in-neighbourhoods of a dependency graph, this is the out-degree bound.

Definition (Lean source)
U :
Type u_1
shared
N :
U → Finset U
d :
ℕ
j :
U
BlockDegreeLE N d :
Prop
(Finset.univ.filter fun i => j ∈ N i).card ≤ d
Causalean.Experimentation.DesignBased.BlockDegreeLE · Causalean/Experimentation/DesignBased/LocalDependenceVariance.lean:49
theorem bernoulliDesign_E_sum_sq_le_blockDegree_mul_sum_sq reviewed
Causalean.Experimentation.DesignBased

Local-dependence variance bound. Under a Bernoulli design in which every unit's treatment probability lies strictly between 0 and 1, suppose each unit i contributes a term F i — attached to a dependence block N i — such that no unit's treatment is read by more than d of these blocks, every term has mean zero under the Bernoulli design, and each term F i depends only on the treatments of its own block N i. Then the second moment of the total ∑ᵢ F i is at most d times the total of the individual second moments, d · ∑ᵢ E[(F i)²]. The bound is scale free: it needs no uniform bound on the terms, no explicit decorrelation assumption, and no dependence on the population size.

Formal statement
U :
Type u_1
shared
p :
U → ℝ
hp0 :
∀ i, 0 < p i
hp1 :
∀ i, p i < 1
N :
U → Finset U
d :
ℕ
hdeg :
F :
U → (U → Bool) → ℝ
hmean :
∀ i, (bernoulliDesign p (fun k => (hp0 k).le) (fun k => (hp1 k).le)).E (F i) = 0
hdep :
∀ i, DependsOnBlock (N i) (F i)
(bernoulliDesign p (fun k => (hp0 k).le) (fun k => (hp1 k).le)).E (fun z => (∑ i, F i z) ^ 2)
≤ (d : ℝ) * ∑ i, (bernoulliDesign p (fun k => (hp0 k).le) (fun k => (hp1 k).le)).E (fun z => F i z ^ 2)
Proof (Lean source)
theorem bernoulliDesign_E_sum_sq_le_blockDegree_mul_sum_sq (p : U → ℝ) (hp0 : ∀ i, 0 < p i) (hp1 : ∀ i, p i < 1) (N : U → Finset U) (d : ℕ) (hdeg : BlockDegreeLE N d) (F : U → (U → Bool) → ℝ) (hmean : ∀ i, (bernoulliDesign p (fun k => (hp0 k).le) (fun k => (hp1 k).le)).E (F i) = 0) (hdep : ∀ i, DependsOnBlock (N i) (F i)) : (bernoulliDesign p (fun k => (hp0 k).le) (fun k => (hp1 k).le)).E (fun z => (∑ i, F i z) ^ 2) ≤ (d : ℝ) * ∑ i, (bernoulliDesign p (fun k => (hp0 k).le) (fun k => (hp1 k).le)).E (fun z => F i z ^ 2) := by classical have hp0' : ∀ i, 0 ≤ p i := fun i => (hp0 i).le have hp1' : ∀ i, p i ≤ 1 := fun i => (hp1 i).le set v : Finset U → ℝ := fun S => ∏ j ∈ S, p j * (1 - p j) with hv have hv0 (S : Finset U) : 0 ≤ v S := Finset.prod_nonneg fun j _ => mul_nonneg (hp0 j).le (sub_pos.mpr (hp1 j)).le choose a ha using fun i => exists_centeredMonomial_expansion (U := U) p (F i) have ha0 (i : U) : a i ∅ = 0 := centeredMonomial_coef_empty_eq_zero p hp0' hp1' (F i) (a i) (ha i) (hmean i) -- The units whose block can carry the basis direction `S`. set I : Finset U → Finset U := fun S => Finset.univ.filter fun i => S ⊆ N i with hI have hcardI (S : Finset U) (hSne : S.Nonempty) : (I S).card ≤ d := by obtain ⟨j, hjS⟩ := hSne refine (Finset.card_le_card ?_).trans (hdeg j) intro i hi exact Finset.mem_filter.mpr ⟨Finset.mem_univ i, (Finset.mem_filter.mp hi).2 hjS⟩ have hsumI (S : Finset U) (hS : S ∈ (Finset.univ : Finset U).powerset) : (∑ i, a i S) = ∑ i ∈ I S, a i S := by symm refine Finset.sum_subset_zero_on_sdiff (Finset.subset_univ _) (fun i hi => ?_) (fun _ _ => rfl) exact centeredMonomial_coef_eq_zero_of_not_subset p hp0' hp1' (N i) (F i) (hdep i) (a i) (ha i) S (by simpa [hI] using (Finset.mem_sdiff.mp hi).2) (fun j _ => hp0 j) (fun j _ => hp1 j) set A : Finset U → ℝ := fun S => ∑ i, a i S with hA have hsumExpansion (z : U → Bool) : (∑ i, F i z) = ∑ S ∈ (Finset.univ : Finset U).powerset, A S * centeredMonomial p S z := by simp_rw [ha] rw [Finset.sum_comm] exact Finset.sum_congr rfl fun S _ => by rw [hA, Finset.sum_mul] rw [bernoulliDesign_E_sq_of_expansion p hp0' hp1' (fun z => ∑ i, F i z) A hsumExpansion] calc (∑ S ∈ (Finset.univ : Finset U).powerset, A S ^ 2 * v S) ≤ ∑ S ∈ (Finset.univ : Finset U).powerset, (d : ℝ) * (∑ i, a i S ^ 2) * v S := by refine Finset.sum_le_sum fun S hS => ?_ by_cases hSne : S.Nonempty · have hcardR : ((I S).card : ℝ) ≤ d := by exact_mod_cast hcardI S hSne have hsquares : (0 : ℝ) ≤ ∑ i ∈ I S, a i S ^ 2 := by positivity have hCS' : A S ^ 2 ≤ (d : ℝ) * ∑ i, a i S ^ 2 := by rw [show A S = ∑ i ∈ I S, a i S from hsumI S hS] calc (∑ i ∈ I S, a i S) ^ 2 ≤ ((I S).card : ℝ) * ∑ i ∈ I S, a i S ^ 2 := sq_sum_le_card_mul_sum_sq _ ≤ (d : ℝ) * ∑ i ∈ I S, a i S ^ 2 := mul_le_mul_of_nonneg_right hcardR hsquares _ ≤ (d : ℝ) * ∑ i, a i S ^ 2 := by refine mul_le_mul_of_nonneg_left ?_ (by positivity) exact Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) fun _ _ _ => sq_nonneg _ exact mul_le_mul_of_nonneg_right hCS' (hv0 S) · have hSe : S = ∅ := Finset.not_nonempty_iff_eq_empty.mp hSne subst hSe simp [hA, ha0] _ = (d : ℝ) * ∑ i, ∑ S ∈ (Finset.univ : Finset U).powerset, a i S ^ 2 * v S := by rw [show (∑ S ∈ (Finset.univ : Finset U).powerset, (d : ℝ) * (∑ i, a i S ^ 2) * v S) = ∑ S ∈ (Finset.univ : Finset U).powerset, ∑ i, (d : ℝ) * a i S ^ 2 * v S from Finset.sum_congr rfl fun S _ => by rw [Finset.mul_sum, Finset.sum_mul]] rw [Finset.sum_comm, Finset.mul_sum] refine Finset.sum_congr rfl fun i _ => ?_ rw [Finset.mul_sum] exact Finset.sum_congr rfl fun S _ => by ring _ = _ := by refine congrArg _ (Finset.sum_congr rfl fun i _ => ?_) exact (bernoulliDesign_E_sq_of_expansion p hp0' hp1' (F i) (a i) (ha i)).symm
Causalean.Experimentation.DesignBased.bernoulliDesign_E_sum_sq_le_blockDegree_mul_sum_sq · Causalean/Experimentation/DesignBased/LocalDependenceVariance.lean:56 · uses BlockDegreeLE , DependsOnBlock , E , bernoulliDesign
Neyman­Composition 3 core · 5 supporting This file connects the library's three representations of within-arm variation: ordinary sample variance on a fixed-size subset, Boolean-assignment arm variances, and the finite-population variance. ★ control_sampleVariance_tendstoInProb

Composition lemmas for Neyman inference under complete randomization

This file connects the library's three representations of within-arm variation: ordinary sample variance on a fixed-size subset, Boolean-assignment arm variances, and the finite-population variance. Complementing the treated subset transports complete randomization to the control design, so the existing sample-variance consistency theorem applies to either arm.

def completeRandomizationComplementEquiv reviewed
Causalean.Experimentation.DesignBased

For a finite population, a feasible treated count, the complement equivalence between size-K treated subsets and size-N-K control subsets maps each treated set to precisely the units outside it.

Definition (Lean source)
U :
K :
ℕ
hK :
K ≤ card U
completeRandomizationComplementEquiv K hK :
{S : Finset U // S.card = K} ≃ {S : Finset U // S.card = card U - K}
clause 1
toFun S := ⟨S.valᶜ, by simp [Finset.card_compl, S.property]⟩
clause 2
invFun S := ⟨S.valᶜ, by simp [Finset.card_compl, S.property, Nat.sub_sub_self hK]⟩
clause 3
left_inv S := by apply Subtype.ext exact compl_compl S.val
clause 4
right_inv S := by apply Subtype.ext exact compl_compl S.val
Causalean.Experimentation.DesignBased.completeRandomizationComplementEquiv · Causalean/Experimentation/DesignBased/NeymanComposition.lean:41
def finCompleteRandomizationComplementEquiv reviewed
Causalean.Experimentation.DesignBased

For a population of n indexed units and a feasible treated count, the complement equivalence specialized to Fin n maps treated subsets to control subsets whose cardinality is written definitionally as n-K.

Definition (Lean source)
n :
ℕ
K :
ℕ
hK :
K ≤ n
finCompleteRandomizationComplementEquiv K hK :
{S : Finset (Fin n) // S.card = K} ≃ {S : Finset (Fin n) // S.card = n - K}
clause 1
toFun S := ⟨S.valᶜ, by simp [Finset.card_compl, S.property]⟩
clause 2
invFun S := ⟨S.valᶜ, by simp [Finset.card_compl, S.property, Nat.sub_sub_self hK]⟩
clause 3
left_inv S := by apply Subtype.ext exact compl_compl S.val
clause 4
right_inv S := by apply Subtype.ext exact compl_compl S.val
Causalean.Experimentation.DesignBased.finCompleteRandomizationComplementEquiv · Causalean/Experimentation/DesignBased/NeymanComposition.lean:74
theorem control_sampleVariance_tendstoInProb reviewed
Causalean.Experimentation.DesignBased

Along finite populations with outcome vectors and feasible treated counts, suppose every control arm contains at least two units, the control-arm sizes diverge, the population variances converge, and the largest squared centered outcome divided by the control-arm size vanishes. Then the ordinary sample variance on the complementary control set converges in randomization probability to the finite-population variance.

Formal statement
U :
ℕ → Type*
∀ k, Fintype (U k)
∀ k, DecidableEq (U k)
∀ k, Nonempty (U k)
K :
ℕ → ℕ
hK :
∀ k, K k ≤ card (U k)
hC2 :
∀ k, 2 ≤ card (U k) - K k
y :
∀ k
if
U k
then
ℝ
v :
ℝ
hCTop :
Tendsto (fun k => card (U k) - K k) atTop atTop
hvar :
Tendsto (fun k => popVar (y k)) atTop (𝓝 v)
hmax :
Tendsto (fun k => popMaxSqDev (y k) / (card (U k) - K k : ℕ)) atTop (𝓝 0)
FiniteDesign.TendstoInProb (fun k => completeRandomization (K k) (hK k)) (fun k S => sampleVariance (card (U k) - K k) (y k) (completeRandomizationComplementEquiv (K k) (hK k) S)) (fun k => popVar (y k))
Proof (Lean source)
theorem control_sampleVariance_tendstoInProb {U : ℕ → Type*} [∀ k, Fintype (U k)] [∀ k, DecidableEq (U k)] [∀ k, Nonempty (U k)] (K : ℕ → ℕ) (hK : ∀ k, K k ≤ card (U k)) (hC2 : ∀ k, 2 ≤ card (U k) - K k) (y : ∀ k, U k → ℝ) (v : ℝ) (hCTop : Tendsto (fun k => card (U k) - K k) atTop atTop) (hvar : Tendsto (fun k => popVar (y k)) atTop (𝓝 v)) (hmax : Tendsto (fun k => popMaxSqDev (y k) / (card (U k) - K k : ℕ)) atTop (𝓝 0)) : FiniteDesign.TendstoInProb (fun k => completeRandomization (K k) (hK k)) (fun k S => sampleVariance (card (U k) - K k) (y k) (completeRandomizationComplementEquiv (K k) (hK k) S)) (fun k => popVar (y k)) := by have h := FinitePopulationMoments.SampleVarianceConsistency.sampleVariance_tendstoInProb (fun k => card (U k) - K k) hC2 (fun k => sub_le _ _) y v hCTop hvar hmax intro ε hε have ht := h ε hε convert ht using 1 funext k let A : {S : Finset (U k) // S.card = card (U k) - K k} → Prop := fun S => ε ≤ |sampleVariance (card (U k) - K k) (y k) S - popVar (y k)| change (completeRandomization (K k) (hK k)).Pr (fun S => A (completeRandomizationComplementEquiv (K k) (hK k) S)) = (completeRandomization (card (U k) - K k) (sub_le _ _)).Pr A calc _ = ((completeRandomization (K k) (hK k)).map (completeRandomizationComplementEquiv (K k) (hK k))).Pr A := (FiniteDesign.Pr_map _ _ _).symm _ = _ := by rw [completeRandomization_map_complement]
5 supporting declarations (lemmas, instances)
Potential­Outcome 3 core · 3 supporting This file represents a unit's outcome under an assignment by evaluating its potential outcome at the exposure induced by that assignment. ★ Yobs_eq_sum

Potential outcomes under exposure mappings

This file represents a unit's outcome under an assignment by evaluating its potential outcome at the exposure induced by that assignment. It supplies the properly specified exposure condition and the observed-outcome construction used by the design-based interference results.

def ProperlySpecified reviewed
Causalean.Experimentation.DesignBased

For potential outcomes indexed by unit and exposure level, randomization potential outcomes indexed by unit and assignment, an assignment-to-exposure mapping, and unit-level attributes used by that mapping, the properly specified exposure condition states that, for every unit and every assignment, the randomization potential outcome equals the potential outcome at the exposure induced for that unit by the assignment.

Definition (Lean source)
Ω :
Type u_1
shared
ι :
Type u_2
shared
Θ :
Type u_3
shared
Δ :
Type u_4
shared
y :
ι → Δ → ℝ
yr :
ι → Ω → ℝ
f :
Ω → Θ → Δ
θ :
ι → Θ
i z :
ProperlySpecified y yr f θ :
Prop
yr i z = y i (expo f θ i z)
Causalean.Experimentation.DesignBased.ProperlySpecified · Causalean/Experimentation/DesignBased/PotentialOutcome.lean:41
def Yobs reviewed
Causalean.Experimentation.DesignBased

For potential outcomes indexed by unit and exposure level, an assignment-to-exposure mapping, unit-level attributes used by that mapping, a unit, and an assignment, the observed outcome is that unit's potential outcome at the exposure induced by the assignment.

Definition (Lean source)
Ω :
Type u_1
shared
ι :
Type u_2
shared
Θ :
Type u_3
shared
Δ :
Type u_4
shared
y :
ι → Δ → ℝ
f :
Ω → Θ → Δ
θ :
ι → Θ
i :
ι
z :
Ω
Yobs y f θ i z :
ℝ
y i (expo f θ i z)
Causalean.Experimentation.DesignBased.Yobs · Causalean/Experimentation/DesignBased/PotentialOutcome.lean:49
lemma Yobs_eq_sum reviewed
Causalean.Experimentation.DesignBased

Condition 2 (consistency). The observed outcome of unit i under assignment z equals the sum, over every exposure level, of the exposure indicator times the exposure-indexed potential outcome.

Formal statement
Ω :
Type u_1
shared
ι :
Type u_2
shared
Θ :
Type u_3
shared
Δ :
Type u_4
shared
y :
ι → Δ → ℝ
f :
Ω → Θ → Δ
θ :
ι → Θ
i :
ι
z :
Ω
Yobs y f θ i z = ∑ d, expoInd f θ i d z * y i d
Proof (Lean source)
lemma Yobs_eq_sum (y : ι → Δ → ℝ) (f : Ω → Θ → Δ) (θ : ι → Θ) (i : ι) (z : Ω) : Yobs y f θ i z = ∑ d, expoInd f θ i d z * y i d := by unfold Yobs expoInd FiniteDesign.ind rw [Finset.sum_eq_single (expo f θ i z) (fun d _ hd => by rw [if_neg (fun h => hd h.symm), zero_mul]) (fun h => absurd (Finset.mem_univ _) h)] simp
Causalean.Experimentation.DesignBased.Yobs_eq_sum · Causalean/Experimentation/DesignBased/PotentialOutcome.lean:59 · uses Yobs , expoInd
3 supporting declarations (lemmas, instances)
  • expoInd_mul_Yobs lemma — On the event expo i = d, the observed outcome agrees with the potential outcome y i d; hence 1(expo i = d)·Yobs i = 1(expo i = d)·y i d.
    Ω :
    Type u_1
    shared
    ι :
    Type u_2
    shared
    Θ :
    Type u_3
    shared
    Δ :
    Type u_4
    shared
    y :
    ι → Δ → ℝ
    f :
    Ω → Θ → Δ
    θ :
    ι → Θ
    i :
    ι
    d :
    Δ
    z :
    Ω
    expoInd f θ i d z * Yobs y f θ i z = expoInd f θ i d z * y i d
    Proof (Lean source)
    lemma expoInd_mul_Yobs (y : ι → Δ → ℝ) (f : Ω → Θ → Δ) (θ : ι → Θ) (i : ι) (d : Δ) (z : Ω) : expoInd f θ i d z * Yobs y f θ i z = expoInd f θ i d z * y i d := by unfold expoInd FiniteDesign.ind Yobs by_cases h : expo f θ i z = d <;> simp [h]
    Causalean.Experimentation.DesignBased.expoInd_mul_Yobs · Causalean/Experimentation/DesignBased/PotentialOutcome.lean:71
  • expoInd_mul_Yobs_sq lemma — Squared on-event substitution: 1(expo i = d)·(Yobs i)² = 1(expo i = d)·(y i d)².
    Ω :
    Type u_1
    shared
    ι :
    Type u_2
    shared
    Θ :
    Type u_3
    shared
    Δ :
    Type u_4
    shared
    y :
    ι → Δ → ℝ
    f :
    Ω → Θ → Δ
    θ :
    ι → Θ
    i :
    ι
    d :
    Δ
    z :
    Ω
    expoInd f θ i d z * (Yobs y f θ i z) ^ 2 = expoInd f θ i d z * (y i d) ^ 2
    Proof (Lean source)
    lemma expoInd_mul_Yobs_sq (y : ι → Δ → ℝ) (f : Ω → Θ → Δ) (θ : ι → Θ) (i : ι) (d : Δ) (z : Ω) : expoInd f θ i d z * (Yobs y f θ i z) ^ 2 = expoInd f θ i d z * (y i d) ^ 2 := by unfold expoInd FiniteDesign.ind Yobs by_cases h : expo f θ i z = d <;> simp [h]
    Causalean.Experimentation.DesignBased.expoInd_mul_Yobs_sq · Causalean/Experimentation/DesignBased/PotentialOutcome.lean:79
  • expoInd₂_mul_Yobs lemma — On the event expo i = di, multiplying the observed outcome for unit i by any real quantity leaves it valid to replace that outcome by potential outcome y i di.
    Ω :
    Type u_1
    shared
    ι :
    Type u_2
    shared
    Θ :
    Type u_3
    shared
    Δ :
    Type u_4
    shared
    y :
    ι → Δ → ℝ
    f :
    Ω → Θ → Δ
    θ :
    ι → Θ
    i :
    ι
    di :
    Δ
    q :
    Ω → ℝ
    z :
    Ω
    expoInd f θ i di z * q z * Yobs y f θ i z = expoInd f θ i di z * q z * y i di
    Proof (Lean source)
    lemma expoInd₂_mul_Yobs (y : ι → Δ → ℝ) (f : Ω → Θ → Δ) (θ : ι → Θ) (i : ι) (di : Δ) (q : Ω → ℝ) (z : Ω) : expoInd f θ i di z * q z * Yobs y f θ i z = expoInd f θ i di z * q z * y i di := by unfold expoInd FiniteDesign.ind Yobs by_cases h : expo f θ i z = di <;> simp [h]
    Causalean.Experimentation.DesignBased.expoInd₂_mul_Yobs · Causalean/Experimentation/DesignBased/PotentialOutcome.lean:86
Product­Block 3 core · 1 supporting Functions of disjoint coordinate blocks factor under a finite product design. ★ E_prod_block_mul★ Cov_prod_block_zero★ Cov_prod_disjoint_zero

Disjoint-block independence for product designs

Functions of disjoint coordinate blocks factor under a finite product design.

The theorem FiniteDesign.E_prod_block_mul factors the expectation of f * g when f depends only on coordinates in a block A and g depends only on the complement. The covariance corollaries FiniteDesign.Cov_prod_block_zero and FiniteDesign.Cov_prod_disjoint_zero package that independence for complement blocks and for arbitrary disjoint blocks.

theorem E_prod_block_mul reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

Disjoint-block factorization of expectation. For a family of independent coordinate designs D and real-valued functions f and g on the joint assignment space, suppose f is invariant under any change to the coordinates outside a block A — it depends only on the coordinates in A, and g depends only on the coordinates outside A. Then under the product design, the expectation of the product f·g factors as E[f·g] = E[f]·E[g]. The general (block-level) form of E_prod_apply₂.

Formal statement
ι :
Type u_1
ι → Type u_2
shared
D :
∀ i, FiniteDesign (α i)
A :
f g :
(∀ i, α i) → ℝ
hf :
∀ w w' : ∀ i
if
α i, (∀ i ∈ A, w i = w' i)
then
f w = f w'
hg :
∀ w w' : ∀ i
if
α i, (∀ i ∉ A, w i = w' i)
then
g w = g w'
(prodDesign D).E (fun w => f w * g w) = (prodDesign D).E f * (prodDesign D).E g
Proof (Lean source)
theorem E_prod_block_mul (D : ∀ i, FiniteDesign (α i)) (A : Finset ι) (f g : (∀ i, α i) → ℝ) (hf : ∀ w w' : ∀ i, α i, (∀ i ∈ A, w i = w' i) → f w = f w') (hg : ∀ w w' : ∀ i, α i, (∀ i ∉ A, w i = w' i) → g w = g w') : (prodDesign D).E (fun w => f w * g w) = (prodDesign D).E f * (prodDesign D).E g := by classical letI : (i : ι) → MeasurableSpace (α i) := fun _ => ⊤ haveI : (i : ι) → MeasurableSingletonClass (α i) := fun _ => inferInstance have hne := nonempty_of_design D -- A global reference point used to fill in the coordinates we drop. let x₀ : ∀ i, α i := fun i => (hne i).some -- Factor `f` through the `A`-block restriction and `g` through the `Aᶜ`-block restriction. let F : (∀ k : (A : Finset ι), α k) → ℝ := fun a => f (fun i => if h : i ∈ A then a ⟨i, h⟩ else x₀ i) let G : (∀ k : ((Aᶜ : Finset ι) : Finset ι), α k) → ℝ := fun b => g (fun i => if h : i ∈ (Aᶜ : Finset ι) then b ⟨i, h⟩ else x₀ i) have hfF : ∀ w, f w = F (fun k : (A : Finset ι) => w k) := by intro w refine hf _ _ (fun i hi => ?_) simp [hi] have hgG : ∀ w, g w = G (fun k : ((Aᶜ : Finset ι) : Finset ι) => w k) := by intro w refine hg _ _ (fun i hi => ?_) have hi' : i ∈ (Aᶜ : Finset ι) := by simpa using hi simp [hi'] -- Independence of the two disjoint coordinate blocks `A` and `Aᶜ`. have hindep : IndepFun (fun w : ∀ k, α k => f w) (fun w => g w) (prodDesign D).toMeasure := by have hdisj : Disjoint A (Aᶜ : Finset ι) := disjoint_compl_right have hblk := (indepFun_prodDesign_blocks D hdisj).comp (φ := F) (ψ := G) (measurable_of_finite F) (measurable_of_finite G) refine hblk.congr ?_ ?_ · filter_upwards with w using (hfF w).symm · filter_upwards with w using (hgG w).symm -- Convert the design expectations to integrals and apply independence. rw [← integral_toMeasure, ← integral_toMeasure, ← integral_toMeasure] exact ProbabilityTheory.IndepFun.integral_fun_mul_eq_mul_integral hindep (measurable_of_finite f).aestronglyMeasurable (measurable_of_finite g).aestronglyMeasurable
Causalean.Experimentation.DesignBased.FiniteDesign.E_prod_block_mul · Causalean/Experimentation/DesignBased/ProductBlock.lean:64 · uses FiniteDesign , E , prodDesign
theorem Cov_prod_block_zero reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

Disjoint-block covariance vanishing (complement form). For a family of independent coordinate designs D and real-valued functions f and g, suppose f depends only on the coordinates in a block A and g depends only on the coordinates outside A. Then their covariance under the product design is zero.

Formal statement
ι :
Type u_1
ι → Type u_2
shared
D :
∀ i, FiniteDesign (α i)
A :
f g :
(∀ i, α i) → ℝ
hf :
∀ w w' : ∀ i
if
α i, (∀ i ∈ A, w i = w' i)
then
f w = f w'
hg :
∀ w w' : ∀ i
if
α i, (∀ i ∉ A, w i = w' i)
then
g w = g w'
(prodDesign D).Cov f g = 0
Proof (Lean source)
theorem Cov_prod_block_zero (D : ∀ i, FiniteDesign (α i)) (A : Finset ι) (f g : (∀ i, α i) → ℝ) (hf : ∀ w w' : ∀ i, α i, (∀ i ∈ A, w i = w' i) → f w = f w') (hg : ∀ w w' : ∀ i, α i, (∀ i ∉ A, w i = w' i) → g w = g w') : (prodDesign D).Cov f g = 0 := by rw [Cov_eq, E_prod_block_mul D A f g hf hg, sub_self]
Causalean.Experimentation.DesignBased.FiniteDesign.Cov_prod_block_zero · Causalean/Experimentation/DesignBased/ProductBlock.lean:111 · uses FiniteDesign , Cov , prodDesign
theorem Cov_prod_disjoint_zero reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

Disjoint-block covariance vanishing (two-block form). For a family of independent coordinate designs D and real-valued functions f and g, suppose the index sets S and T are disjoint, f depends only on the coordinates in S, and g depends only on the coordinates in T. Then their covariance under the product design is zero.

Formal statement
ι :
Type u_1
ι → Type u_2
shared
D :
∀ i, FiniteDesign (α i)
S T :
hST :
f g :
(∀ i, α i) → ℝ
hf :
∀ w w' : ∀ i
if
α i, (∀ i ∈ S, w i = w' i)
then
f w = f w'
hg :
∀ w w' : ∀ i
if
α i, (∀ i ∈ T, w i = w' i)
then
g w = g w'
(prodDesign D).Cov f g = 0
Proof (Lean source)
theorem Cov_prod_disjoint_zero (D : ∀ i, FiniteDesign (α i)) (S T : Finset ι) (hST : Disjoint S T) (f g : (∀ i, α i) → ℝ) (hf : ∀ w w' : ∀ i, α i, (∀ i ∈ S, w i = w' i) → f w = f w') (hg : ∀ w w' : ∀ i, α i, (∀ i ∈ T, w i = w' i) → g w = g w') : (prodDesign D).Cov f g = 0 := by -- `g` depends only on `T ⊆ Sᶜ`, hence only on the coordinates outside `S`. refine Cov_prod_block_zero D S f g hf (fun w w' h => hg w w' (fun i hiT => ?_)) exact h i (fun hiS => (Finset.disjoint_left.mp hST hiS) hiT)
Causalean.Experimentation.DesignBased.FiniteDesign.Cov_prod_disjoint_zero · Causalean/Experimentation/DesignBased/ProductBlock.lean:122 · uses FiniteDesign , Cov , prodDesign
1 supporting declaration (lemmas, instances)
  • nonempty_of_design theorem — Every coordinate type carrying a finite design is nonempty.
    ι :
    Type u_1
    ι → Type u_2
    shared
    D :
    ∀ i, FiniteDesign (α i)
    i :
    Nonempty (α i)
    Proof (Lean source)
    theorem nonempty_of_design (D : ∀ i, FiniteDesign (α i)) : ∀ i, Nonempty (α i) := by intro i by_contra h rw [not_nonempty_iff] at h have := (D i).p_sum rw [Finset.univ_eq_empty, Finset.sum_empty] at this exact one_ne_zero this.symm
    Causalean.Experimentation.DesignBased.FiniteDesign.nonempty_of_design · Causalean/Experimentation/DesignBased/ProductBlock.lean:55
Product­Reindex 1 core · 0 supporting Permuting coordinate labels only relabels probabilities under a product design. ★ prodDesign_Pr_reindex

Reindexing product designs

Permuting coordinate labels only relabels probabilities under a product design.

The theorem FiniteDesign.prodDesign_Pr_reindex is a finite-sum reindexing identity: for a coordinate permutation sigma, the probability of a permuted predicate under prodDesign D equals the probability of the original predicate under the correspondingly permuted product design. It is used to express selection symmetry in identical-group two-stage arguments without invoking measure theory.

theorem prodDesign_Pr_reindex reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

Relabeling a product design by a coordinate permutation. For a family of designs D over a common coordinate space W, indexed by ι, and a permutation σ : ι ≃ ι, the probability under prodDesign D of the predicate w ↦ P (w ∘ σ) equals the probability under the permuted product prodDesign (D ∘ σ) of P.

Formal statement
ι :
W :
Type*
σ :
ι ≃ ι
D :
ι → FiniteDesign W
P :
(ι → W) → Prop
(prodDesign D).Pr (fun w => P (fun i => w (σ i))) = (prodDesign (fun i => D (σ i))).Pr P
Proof (Lean source)
theorem prodDesign_Pr_reindex {ι : Type*} [Fintype ι] [DecidableEq ι] {W : Type*} [Fintype W] (σ : ι ≃ ι) (D : ι → FiniteDesign W) (P : (ι → W) → Prop) [DecidablePred P] : (prodDesign D).Pr (fun w => P (fun i => w (σ i))) = (prodDesign (fun i => D (σ i))).Pr P := by classical -- Precomposition by `σ.symm` is a bijection on the assignment space `ι → W`; it carries the -- permuted predicate back to the plain predicate. let e : (ι → W) ≃ (ι → W) := Equiv.arrowCongr σ (Equiv.refl W) have he : ∀ (w : ι → W) (i : ι), e w i = w (σ.symm i) := by intro w i; simp [e, Equiv.arrowCongr] -- Unfold `Pr`/`E`/`ind` to a finite sum over the assignment space and reindex by `e`. simp only [Pr, E, ind, prodDesign_p] rw [← Equiv.sum_comp e] refine Finset.sum_congr rfl (fun w _ => ?_) -- The predicate argument `fun i => (e w) (σ i)` equals `w`, and the probability product -- reindexes coordinate-by-coordinate. have hpred : (fun i => e w (σ i)) = w := by funext i; rw [he w (σ i), σ.symm_apply_apply] have hprob : (∏ i, (D i).p (e w i)) = ∏ i, (D (σ i)).p (w i) := by rw [← Equiv.prod_comp σ (fun i => (D i).p (e w i))] refine Finset.prod_congr rfl (fun i _ => ?_) rw [he w (σ i), σ.symm_apply_apply] rw [hprob] simp only [hpred]
Causalean.Experimentation.DesignBased.FiniteDesign.prodDesign_Pr_reindex · Causalean/Experimentation/DesignBased/ProductReindex.lean:45 · uses FiniteDesign , Pr , prodDesign
Product­Variance 1 core · 3 supporting Distinct coordinates of a finite product design are uncorrelated. ★ Var_prod_linear_comb

Product-design variance identities

Distinct coordinates of a finite product design are uncorrelated.

FiniteDesign.E_prod_apply₂ factors expectations of products of statistics on two distinct coordinates, yielding FiniteDesign.Var_prod_apply for one-coordinate variances and FiniteDesign.Cov_prod_apply_of_ne for zero cross-coordinate covariance. The payload FiniteDesign.Var_prod_linear_comb states that the variance of a linear combination of single-coordinate statistics is the sum of squared coefficients times the marginal variances.

lemma Var_prod_linear_comb reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

The payload. Under the product design formed from a family of per-coordinate finite designs, the variance of a linear combination ∑ᵢ cᵢ·gᵢ(wᵢ) of single-coordinate functions gᵢ, with coefficients c, equals the sum over coordinates of the squared coefficient times the coordinate's own variance — cross-coordinate covariances vanish.

Formal statement
ι :
Type u_1
ι → Type u_2
shared
D :
∀ i, FiniteDesign (α i)
c :
ι → ℝ
g :
∀ i
if
α i
then
ℝ
(prodDesign D).Var (fun w => ∑ i, c i * g i (w i)) = ∑ i, (c i) ^ 2 * (D i).Var (g i)
Proof (Lean source)
lemma Var_prod_linear_comb (D : ∀ i, FiniteDesign (α i)) (c : ι → ℝ) (g : ∀ i, α i → ℝ) : (prodDesign D).Var (fun w => ∑ i, c i * g i (w i)) = ∑ i, (c i) ^ 2 * (D i).Var (g i) := by rw [(prodDesign D).Var_linear_comb univ c (fun i w => g i (w i))] apply Finset.sum_congr rfl intro i _ -- The inner sum over `j` collapses to the diagonal `j = i`. rw [Finset.sum_eq_single i] · -- diagonal term rw [Cov_self, Var_prod_apply] ring · -- off-diagonal terms vanish intro j _ hji rw [Cov_prod_apply_of_ne D (Ne.symm hji) (g i) (g j)] ring · intro hi; exact absurd (Finset.mem_univ i) hi
Causalean.Experimentation.DesignBased.FiniteDesign.Var_prod_linear_comb · Causalean/Experimentation/DesignBased/ProductVariance.lean:89 · uses FiniteDesign , Var , prodDesign
3 supporting declarations (lemmas, instances)
  • E_prod_apply₂ lemma — Two-coordinate factorization: under the product design, the expectation of a product of a function of one coordinate and a function of a distinct coordinate factors into the product of the two marginal expectations.
    ι :
    Type u_1
    ι → Type u_2
    shared
    D :
    ∀ i, FiniteDesign (α i)
    i j :
    ι
    h :
    i ≠ j
    g :
    α i → ℝ
    hfun :
    α j → ℝ
    (prodDesign D).E (fun w => g (w i) * hfun (w j)) = (D i).E g * (D j).E hfun
    Proof (Lean source)
    lemma E_prod_apply₂ (D : ∀ i, FiniteDesign (α i)) {i j : ι} (h : i ≠ j) (g : α i → ℝ) (hfun : α j → ℝ) : (prodDesign D).E (fun w => g (w i) * hfun (w j)) = (D i).E g * (D j).E hfun := by rw [E_prod_block_mul D {i} (fun w => g (w i)) (fun w => hfun (w j))] · rw [E_prod_apply D i g, E_prod_apply D j hfun] · intro w w' hw exact congrArg g (hw i (by simp)) · intro w w' hw exact congrArg hfun (hw j (by simpa using h.symm))
    Causalean.Experimentation.DesignBased.FiniteDesign.E_prod_apply₂ · Causalean/Experimentation/DesignBased/ProductVariance.lean:52
  • Var_prod_apply lemma — Single-coordinate variance: under the product design, the variance of a function of one coordinate equals the variance of that function under the coordinate's own design.
    ι :
    Type u_1
    ι → Type u_2
    shared
    D :
    ∀ i, FiniteDesign (α i)
    j :
    ι
    g :
    α j → ℝ
    (prodDesign D).Var (fun w => g (w j)) = (D j).Var g
    Proof (Lean source)
    lemma Var_prod_apply (D : ∀ i, FiniteDesign (α i)) (j : ι) (g : α j → ℝ) : (prodDesign D).Var (fun w => g (w j)) = (D j).Var g := by rw [Var_eq, Var_eq] congr 1 · -- E[(g (w j))^2] = (D j).E (fun a => g a ^ 2) have : (fun w : ∀ i, α i => g (w j) ^ 2) = (fun w => (fun a => g a ^ 2) (w j)) := rfl rw [this, E_prod_apply D j (fun a => g a ^ 2)] · -- (prodDesign D).E (fun w => g (w j)) = (D j).E g rw [E_prod_apply D j g]
    Causalean.Experimentation.DesignBased.FiniteDesign.Var_prod_apply · Causalean/Experimentation/DesignBased/ProductVariance.lean:66
  • Cov_prod_apply_of_ne lemma — Cross-coordinate independence: under the product design, functions of two distinct coordinates have zero covariance.
    ι :
    Type u_1
    ι → Type u_2
    shared
    D :
    ∀ i, FiniteDesign (α i)
    i j :
    ι
    h :
    i ≠ j
    g :
    α i → ℝ
    hfun :
    α j → ℝ
    (prodDesign D).Cov (fun w => g (w i)) (fun w => hfun (w j)) = 0
    Proof (Lean source)
    lemma Cov_prod_apply_of_ne (D : ∀ i, FiniteDesign (α i)) {i j : ι} (h : i ≠ j) (g : α i → ℝ) (hfun : α j → ℝ) : (prodDesign D).Cov (fun w => g (w i)) (fun w => hfun (w j)) = 0 := by rw [Cov_eq] rw [show (fun w : ∀ i, α i => g (w i) * hfun (w j)) = (fun w => g (w i) * hfun (w j)) from rfl, E_prod_apply₂ D h g hfun, E_prod_apply D i g, E_prod_apply D j hfun] ring
    Causalean.Experimentation.DesignBased.FiniteDesign.Cov_prod_apply_of_ne · Causalean/Experimentation/DesignBased/ProductVariance.lean:78
Ratio­Linearization 2 core · 2 supporting Exact design-mean identities for mean-normalized (Horvitz–Thompson / Hájek) ratio statistics and their products, computed directly from FiniteDesign.E. ★ ratio_remainder_capped_bound★ E_centered_ratio_mul

Finite-sample delta-method identities for the design-based layer

Exact design-mean identities for mean-normalized (Horvitz–Thompson / Hájek) ratio statistics and their products, computed directly from FiniteDesign.E.

These are the finite-design counterpart of the measure-theoretic ratio delta method (Causalean.Stat's deltaMethod_ratio): rather than a limiting distributional statement, they give the exact finite-n linearization kernel of a ratio estimator, so a design-based variance computation never has to leave the FiniteDesign world.

* E_centered_ratio — a plug-in ratio X / E[X] is exactly centered. * E_centered_ratio_mul — the exact covariance of two normalized ratios; the linearization kernel for any ratio / Hájek variance. * E_lin_expand — distributes the design mean over a product of two two-term linear forms, the bilinear bookkeeping step for a two-arm linearized variance. * ratio_remainder_capped_bound — the capped second-order remainder of a single scaled ratio estimator, the per-arm building block of a ratio/Hájek CLT's asymptotic-linearity argument.

lemma ratio_remainder_capped_bound reviewed
Causalean.Experimentation.DesignBased

For a positive target scale, a square-root scale whose square is the target scale, a numerator and positive denominator, a target and its centered numerator identity, and a capped inverse-denominator ratio, the scaled ratio remainder is bounded by twice the product of the centered score magnitude and the relative denominator error.

Formal statement
n sn A D μ G :
ℝ
hn :
0 < n
hsn_sq :
sn ^ 2 = n
hD :
0 < D
hcap :
n / D ≤ 2
hG :
G = A - μ * D
|sn * (A / D - μ) - sn⁻¹ * G| ≤ 2 * |sn⁻¹ * G| * |n⁻¹ * D - 1|
Proof (Lean source)
lemma ratio_remainder_capped_bound {n sn A D μ G : ℝ} (hn : 0 < n) (hsn_sq : sn ^ 2 = n) (hD : 0 < D) (hcap : n / D ≤ 2) (hG : G = A - μ * D) : |sn * (A / D - μ) - sn⁻¹ * G| ≤ 2 * |sn⁻¹ * G| * |n⁻¹ * D - 1| := by have hsn0 : sn ≠ 0 := by intro h rw [h, pow_two, mul_zero] at hsn_sq exact absurd hsn_sq.symm (ne_of_gt hn) have hD0 : D ≠ 0 := ne_of_gt hD have hrem : sn * (A / D - μ) - sn⁻¹ * G = sn⁻¹ * G * (n / D - 1) := by have hquot : A / D - μ = G / D := by rw [hG]; field_simp rw [hquot] field_simp rw [hsn_sq] have hbound : |sn⁻¹ * G * (n / D - 1)| ≤ 2 * |sn⁻¹ * G| * |n⁻¹ * D - 1| := by have hid : n / D - 1 = -((n / D) * (n⁻¹ * D - 1)) := by field_simp; ring have hnonneg : 0 ≤ n / D := le_of_lt (div_pos hn hD) have hratio : |n / D - 1| ≤ 2 * |n⁻¹ * D - 1| := by rw [hid, abs_neg, abs_mul, abs_of_nonneg hnonneg] exact mul_le_mul_of_nonneg_right hcap (abs_nonneg _) rw [abs_mul] calc |sn⁻¹ * G| * |n / D - 1| ≤ |sn⁻¹ * G| * (2 * |n⁻¹ * D - 1|) := mul_le_mul_of_nonneg_left hratio (abs_nonneg _) _ = 2 * |sn⁻¹ * G| * |n⁻¹ * D - 1| := by ring rw [hrem] exact hbound
Causalean.Experimentation.DesignBased.ratio_remainder_capped_bound · Causalean/Experimentation/DesignBased/RatioLinearization.lean:39
lemma E_centered_ratio_mul reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

For a finite design, two design statistics, their two means and cross moment, nonzero mean denominators, and the asserted first- and cross-moment identities, the mean product of the two normalized centered ratios equals the normalized cross moment minus one.

Formal statement
Ω :
Type u_1
shared
D :
shared
X Y :
Ω → ℝ
a b c :
ℝ
ha :
a ≠ 0
hb :
b ≠ 0
hEX :
D.E X = a
hEY :
D.E Y = b
hEXY :
D.E (fun z => X z * Y z) = c
D.E (fun z => (X z / a - 1) * (Y z / b - 1)) = c / (a * b) - 1
Proof (Lean source)
lemma E_centered_ratio_mul (X Y : Ω → ℝ) (a b c : ℝ) (ha : a ≠ 0) (hb : b ≠ 0) (hEX : D.E X = a) (hEY : D.E Y = b) (hEXY : D.E (fun z => X z * Y z) = c) : D.E (fun z => (X z / a - 1) * (Y z / b - 1)) = c / (a * b) - 1 := by have hpoint : (fun z => (X z / a - 1) * (Y z / b - 1)) = (fun z => ((1 / (a * b)) * (X z * Y z) - (1 / a) * X z) - (1 / b) * Y z + 1) := by funext z field_simp [ha, hb] ring rw [D.E_congr (by intro z; exact congrFun hpoint z)] rw [D.E_add, D.E_sub, D.E_sub, D.E_const_mul, D.E_const_mul, D.E_const_mul, D.E_const] rw [hEX, hEY, hEXY] field_simp [ha, hb] ring
Causalean.Experimentation.DesignBased.FiniteDesign.E_centered_ratio_mul · Causalean/Experimentation/DesignBased/RatioLinearization.lean:91 · uses FiniteDesign , E
2 supporting declarations (lemmas, instances)
  • E_centered_ratio lemma — Centering of a plug-in ratio. In a finite design, the mean-normalized ratio X / E[X] − 1 has design mean zero whenever the mean E[X] is nonzero — the first-order (linearization) fact that a ratio statistic is exactly centered at its plug-in point.
    Ω :
    Type u_1
    shared
    D :
    shared
    X :
    Ω → ℝ
    a :
    ℝ
    ha :
    a ≠ 0
    hEX :
    D.E X = a
    D.E (fun z => X z / a - 1) = 0
    Proof (Lean source)
    lemma E_centered_ratio (X : Ω → ℝ) (a : ℝ) (ha : a ≠ 0) (hEX : D.E X = a) : D.E (fun z => X z / a - 1) = 0 := by have hpoint : (fun z => X z / a - 1) = (fun z => (1 / a) * X z - 1) := by funext z ring rw [D.E_congr (by intro z; exact congrFun hpoint z)] rw [D.E_sub, D.E_const_mul, D.E_const, hEX] field_simp [ha] ring
    Causalean.Experimentation.DesignBased.FiniteDesign.E_centered_ratio · Causalean/Experimentation/DesignBased/RatioLinearization.lean:78
  • E_lin_expand lemma — Bilinear expansion of a design mean. In a finite design, suppose the mean of A·C equals AA, the mean of A·F equals AB, the mean of B·C equals BA, and the mean of B·F equals BB — the four pairwise cross-moments of the two-term linear forms (A·ai − B·bi) and (C·aj − F·bj). Then the mean of the product (A·ai − B·bi)(C·aj − F·bj) equals AA·ai·aj − AB·ai·bj − BA·bi·aj + BB·bi·bj. This is the generic bookkeeping step assembling a two-arm (e.g. treated/control) linearized variance from its component moments.
    Ω :
    Type u_1
    shared
    D :
    shared
    A B C F :
    Ω → ℝ
    ai bi aj bj AA AB BA BB :
    ℝ
    hAA :
    D.E (fun z => A z * C z) = AA
    hAB :
    D.E (fun z => A z * F z) = AB
    hBA :
    D.E (fun z => B z * C z) = BA
    hBB :
    D.E (fun z => B z * F z) = BB
    D.E (fun z => (A z * ai - B z * bi) * (C z * aj - F z * bj))
    = AA * ai * aj - AB * ai * bj - BA * bi * aj + BB * bi * bj
    Proof (Lean source)
    lemma E_lin_expand (A B C F : Ω → ℝ) (ai bi aj bj AA AB BA BB : ℝ) (hAA : D.E (fun z => A z * C z) = AA) (hAB : D.E (fun z => A z * F z) = AB) (hBA : D.E (fun z => B z * C z) = BA) (hBB : D.E (fun z => B z * F z) = BB) : D.E (fun z => (A z * ai - B z * bi) * (C z * aj - F z * bj)) = AA * ai * aj - AB * ai * bj - BA * bi * aj + BB * bi * bj := by have hpoint : (fun z => (A z * ai - B z * bi) * (C z * aj - F z * bj)) = (fun z => ((ai * aj) * (A z * C z) - (ai * bj) * (A z * F z)) - (bi * aj) * (B z * C z) + (bi * bj) * (B z * F z)) := by funext z ring rw [D.E_congr (by intro z; exact congrFun hpoint z)] rw [D.E_add, D.E_sub, D.E_sub] repeat rw [D.E_const_mul] rw [hAA, hAB, hBA, hBB] ring
    Causalean.Experimentation.DesignBased.FiniteDesign.E_lin_expand · Causalean/Experimentation/DesignBased/RatioLinearization.lean:111
Slutsky 1 core · 0 supporting The finite-design counterpart of the classical converging-together / Slutsky theorem, stated directly on FiniteDesign.Pr at the level of pointwise CDF convergence. ★ finiteDesign_cdf_converging_together

Design-based converging-together (CDF-level Slutsky)

The finite-design counterpart of the classical converging-together / Slutsky theorem, stated directly on FiniteDesign.Pr at the level of pointwise CDF convergence. If Sₙ and Tₙ are asymptotically indistinguishable in probability and the CDFs of Tₙ converge to a continuous limit CDF Φ, then the CDFs of Sₙ converge to the same Φ. It transfers a limiting CDF across an in-probability-negligible perturbation — the exact step a studentized design-based estimator needs to pass from an oracle statistic to its feasible (plug-in standard error) version — without leaving the finite-design layer for the measure-theoretic weak-convergence API.

lemma finiteDesign_cdf_converging_together reviewed
Causalean.Experimentation.DesignBased

Finite-design CDF converging-together. Along a sequence of finite designs on two sequences of real-valued statistics Sₙ and Tₙ, suppose Sₙ is asymptotically indistinguishable from Tₙ in probability: for every η > 0, Pr(η ≤ |Sₙ − Tₙ|) → 0, the CDFs of Tₙ converge pointwise to a limit function Φ, and Φ is continuous. Then the CDFs of Sₙ converge pointwise to the same Φ.

Formal statement
Ω :
ℕ → Type u_1
shared
D :
∀ n, FiniteDesign (Ω n)
S T :
∀ n
if
Ω n
then
ℝ
Φ :
ℝ → ℝ
hApprox :
∀ η : ℝ
if
0 < η
then
Tendsto (fun n => (D n).Pr (fun z => η ≤ |S n z - T n z|)) atTop (𝓝 0)
hT :
∀ x : ℝ, Tendsto (fun n => (D n).Pr (fun z => T n z ≤ x)) atTop (𝓝 (Φ x))
hΦ :
x :
ℝ
Tendsto (fun n => (D n).Pr (fun z => S n z ≤ x)) atTop (𝓝 (Φ x))
Proof (Lean source)
lemma finiteDesign_cdf_converging_together (D : ∀ n, FiniteDesign (Ω n)) (S T : ∀ n, Ω n → ℝ) (Φ : ℝ → ℝ) (hApprox : ∀ η : ℝ, 0 < η → Tendsto (fun n => (D n).Pr (fun z => η ≤ |S n z - T n z|)) atTop (𝓝 0)) (hT : ∀ x : ℝ, Tendsto (fun n => (D n).Pr (fun z => T n z ≤ x)) atTop (𝓝 (Φ x))) (hΦ : Continuous Φ) : ∀ x : ℝ, Tendsto (fun n => (D n).Pr (fun z => S n z ≤ x)) atTop (𝓝 (Φ x)) := by classical intro x rw [Metric.tendsto_atTop] intro ε hε have hε4 : 0 < ε / 4 := by linarith obtain ⟨η, hηpos, hη⟩ := (Metric.continuousAt_iff.mp hΦ.continuousAt) (ε / 4) hε4 set γ : ℝ := η / 2 with hγdef have hγpos : 0 < γ := by rw [hγdef]; linarith have hγ_lt_η : γ < η := by rw [hγdef]; linarith have hΦ_plus_abs : dist (Φ (x + γ)) (Φ x) < ε / 4 := by apply hη rw [Real.dist_eq] have : x + γ - x = γ := by ring rw [this, abs_of_pos hγpos] exact hγ_lt_η have hΦ_minus_abs : dist (Φ (x - γ)) (Φ x) < ε / 4 := by apply hη rw [Real.dist_eq] have : x - γ - x = -γ := by ring rw [this, abs_neg, abs_of_pos hγpos] exact hγ_lt_η rw [Real.dist_eq] at hΦ_plus_abs hΦ_minus_abs have hΦ_plus_lt : Φ (x + γ) < Φ x + ε / 4 := by linarith [(abs_lt.mp hΦ_plus_abs).2] have hΦ_minus_gt : Φ x - ε / 4 < Φ (x - γ) := by linarith [(abs_lt.mp hΦ_minus_abs).1] have hR := hApprox γ hγpos have hTplus := hT (x + γ) have hTminus := hT (x - γ) have hRev : ∀ᶠ n in atTop, (D n).Pr (fun z => γ ≤ |S n z - T n z|) < ε / 4 := by have h := (Metric.tendsto_nhds.mp hR) (ε / 4) hε4 filter_upwards [h] with n hn rw [Real.dist_eq] at hn have hnonneg : 0 ≤ (D n).Pr (fun z => γ ≤ |S n z - T n z|) := (D n).Pr_nonneg _ have habs : |((D n).Pr (fun z => γ ≤ |S n z - T n z|)) - 0| = (D n).Pr (fun z => γ ≤ |S n z - T n z|) := by rw [sub_zero, abs_of_nonneg hnonneg] rwa [habs] at hn have hTplus_ev : ∀ᶠ n in atTop, (D n).Pr (fun z => T n z ≤ x + γ) < Φ (x + γ) + ε / 4 := by have h := (Metric.tendsto_nhds.mp hTplus) (ε / 4) hε4 filter_upwards [h] with n hn rw [Real.dist_eq] at hn linarith [(abs_lt.mp hn).2] have hTminus_ev : ∀ᶠ n in atTop, Φ (x - γ) - ε / 4 < (D n).Pr (fun z => T n z ≤ x - γ) := by have h := (Metric.tendsto_nhds.mp hTminus) (ε / 4) hε4 filter_upwards [h] with n hn rw [Real.dist_eq] at hn linarith [(abs_lt.mp hn).1] refine Filter.eventually_atTop.1 ?_ filter_upwards [hRev, hTplus_ev, hTminus_ev] with n hRn hTpn hTmn rw [Real.dist_eq, abs_sub_lt_iff] constructor · have hupper_event : (D n).Pr (fun z => S n z ≤ x) ≤ (D n).Pr (fun z => T n z ≤ x + γ) + (D n).Pr (fun z => γ ≤ |S n z - T n z|) := by calc (D n).Pr (fun z => S n z ≤ x) ≤ (D n).Pr (fun z => T n z ≤ x + γ ∨ γ ≤ |S n z - T n z|) := by apply (D n).Pr_mono intro z hzS by_cases hfar : γ ≤ |S n z - T n z| · exact inr hfar · left rw [not_le] at hfar have hdist : |T n z - S n z| < γ := by rwa [abs_sub_comm] at hfar have hle : T n z ≤ S n z + γ := by rw [abs_sub_lt_iff] at hdist linarith linarith _ ≤ (D n).Pr (fun z => T n z ≤ x + γ) + (D n).Pr (fun z => γ ≤ |S n z - T n z|) := FiniteDesign.Pr_or_le (D n) _ _ linarith · have hlower_event : (D n).Pr (fun z => T n z ≤ x - γ) ≤ (D n).Pr (fun z => S n z ≤ x) + (D n).Pr (fun z => γ ≤ |S n z - T n z|) := by calc (D n).Pr (fun z => T n z ≤ x - γ) ≤ (D n).Pr (fun z => S n z ≤ x ∨ γ ≤ |S n z - T n z|) := by apply (D n).Pr_mono intro z hzT by_cases hfar : γ ≤ |S n z - T n z| · exact inr hfar · left rw [not_le] at hfar have hdist : |S n z - T n z| < γ := hfar have hle : S n z ≤ T n z + γ := by rw [abs_sub_lt_iff] at hdist linarith linarith _ ≤ (D n).Pr (fun z => S n z ≤ x) + (D n).Pr (fun z => γ ≤ |S n z - T n z|) := FiniteDesign.Pr_or_le (D n) _ _ linarith
Causalean.Experimentation.DesignBased.finiteDesign_cdf_converging_together · Causalean/Experimentation/DesignBased/Slutsky.lean:33 · uses FiniteDesign , Pr
Wald­Coverage 1 core · 2 supporting A paper-agnostic asymptotic-coverage transfer for two-sided Wald intervals built from a *random feasible* standard error. ★ conservative_wald_liminf_of_feasible_studentized_cdf

Design-based conservative Wald-interval coverage

A paper-agnostic asymptotic-coverage transfer for two-sided Wald intervals built from a random feasible standard error. It is stated over abstract per-stage sequences — a design D n, an estimator est n, a target θ n, the true variance scale v n, a conservative (dominating) variance v̂ n, and the normalization size m n — so every design-based paper with a studentized CLT and a conservative variance estimator can instantiate it in one line instead of re-cloning the liminf/Pr_split/coverage argument (as the exposure-mapping, two-stage, and bipartite-interference formalizations each previously did).

theorem conservative_wald_liminf_of_feasible_studentized_cdf reviewed
Causalean.Experimentation.DesignBased

Feasible conservative Wald-interval liminf coverage. For finite designs, an estimator and target, positive normalization and oracle variance scales, and a random feasible variance estimator, suppose its probability of undershooting (1-η)v tends to zero for every positive slack. If the oracle-studentized statistic has standard-normal CDF limits at every threshold, and z is a nonnegative Gaussian quantile, then the random Wald interval based on vhat has coverage liminf at least 1-α.

Formal statement
Ω :
ℕ → Type u_1
shared
D :
∀ n, FiniteDesign (Ω n)
est :
∀ n
if
Ω n
then
ℝ
θ v m :
ℕ → ℝ
vhat :
∀ n
if
Ω n
then
ℝ
hmpos :
∀ n, 0 < m n
hvarpos :
∀ n, 0 < v n
hVhat :
∀ η : ℝ
if
0 < η
then
Tendsto (fun n => (D n).Pr (fun ω => vhat n ω < (1 - η) * v n)) atTop (𝓝 0)
α z :
ℝ
hclt :
∀ t : ℝ,
Tendsto (fun n => (D n).Pr (fun ω => sqrt (m n) * (est n ω - θ n) / sqrt (v n) ≤ t)) atTop (𝓝 (stdNormalCdf t))
hz0 :
0 ≤ z
hz :
stdNormalCdf z = 1 - α / 2
1 - α
≤ liminf (fun n => (D n).Pr (fun ω => |θ n - est n ω| ≤ z * sqrt (vhat n ω / m n))) atTop
Proof (Lean source)
theorem conservative_wald_liminf_of_feasible_studentized_cdf (D : ∀ n, FiniteDesign (Ω n)) (est : ∀ n, Ω n → ℝ) (θ v m : ℕ → ℝ) (vhat : ∀ n, Ω n → ℝ) (hmpos : ∀ n, 0 < m n) (hvarpos : ∀ n, 0 < v n) (hVhat : ∀ η : ℝ, 0 < η → Tendsto (fun n => (D n).Pr (fun ω => vhat n ω < (1 - η) * v n)) atTop (𝓝 0)) (α z : ℝ) (hclt : ∀ t : ℝ, Tendsto (fun n => (D n).Pr (fun ω => sqrt (m n) * (est n ω - θ n) / sqrt (v n) ≤ t)) atTop (𝓝 (stdNormalCdf t))) (hz0 : 0 ≤ z) (hz : stdNormalCdf z = 1 - α / 2) : 1 - α ≤ liminf (fun n => (D n).Pr (fun ω => |θ n - est n ω| ≤ z * sqrt (vhat n ω / m n))) atTop := by classical let T : ∀ n, Ω n → ℝ := fun n ω => sqrt (m n) * (est n ω - θ n) / sqrt (v n) let I : ℕ → ℝ := fun n => (D n).Pr (fun ω => |θ n - est n ω| ≤ z * sqrt (vhat n ω / m n)) have hIcobdd : IsCoboundedUnder (· ≥ ·) atTop I := isCoboundedUnder_ge_of_le atTop (x := (1 : ℝ)) (fun n => (D n).Pr_le_one _) have key : ∀ η : ℝ, 0 < η → η < 1 → 2 * stdNormalCdf (z * sqrt (1 - η)) - 1 ≤ liminf I atTop := by intro η hη0 hη1 let c : ℝ := z * sqrt (1 - η) have h1m : 0 < 1 - η := by linarith have hc : 0 ≤ c := mul_nonneg hz0 (Real.sqrt_nonneg _) let B : ℕ → ℝ := fun n => (D n).Pr (fun ω => -c ≤ T n ω ∧ T n ω ≤ c) let A : ℕ → ℝ := fun n => (D n).Pr (fun ω => vhat n ω < (1 - η) * v n) have hB : Tendsto B atTop (𝓝 (stdNormalCdf c - stdNormalCdf (-c))) := finiteDesign_symmetricBand_tendsto D T stdNormalCdf (fun x => by simpa [T] using hclt x) continuous_stdNormalCdf c hc have hA : Tendsto A atTop (𝓝 0) := by simpa [A] using hVhat η hη0 have hstep : ∀ n, B n - A n ≤ I n := by intro n let Bad : Ω n → Prop := fun ω => vhat n ω < (1 - η) * v n let Band : Ω n → Prop := fun ω => -c ≤ T n ω ∧ T n ω ≤ c have hsplit := (D n).Pr_split Band Bad have hbad : (D n).Pr (fun ω => Band ω ∧ Bad ω) ≤ A n := by apply (D n).Pr_mono exact fun _ h => h.2 have hremain : B n - A n ≤ (D n).Pr (fun ω => Band ω ∧ ¬ Bad ω) := by have hBeq : B n = (D n).Pr (fun ω => Band ω ∧ Bad ω) + (D n).Pr (fun ω => Band ω ∧ ¬ Bad ω) := by simpa [B] using hsplit linarith refine hremain.trans ?_ apply (D n).Pr_mono intro ω hω rcases hω with ⟨⟨hlo, hhi⟩, hgood⟩ change ¬ vhat n ω < (1 - η) * v n at hgood rw [not_lt] at hgood have habsT : |T n ω| ≤ c := abs_le.mpr ⟨hlo, hhi⟩ have hsqrtv : 0 < sqrt (v n) := Real.sqrt_pos.mpr (hvarpos n) have hsqrtm : 0 < sqrt (m n) := Real.sqrt_pos.mpr (hmpos n) have habsEst : |est n ω - θ n| ≤ c * sqrt (v n) / sqrt (m n) := by change |sqrt (m n) * (est n ω - θ n) / sqrt (v n)| ≤ c at habsT rw [abs_div, abs_mul, abs_of_pos hsqrtv, abs_of_nonneg (Real.sqrt_nonneg _), div_le_iff₀ hsqrtv] at habsT have hmul : sqrt (m n) * |est n ω - θ n| ≤ c * sqrt (v n) := by simpa [mul_comm, mul_left_comm, mul_assoc] using habsT exact (le_div_iff₀ hsqrtm).2 (by simpa [mul_comm, mul_left_comm, mul_assoc] using hmul) have hscaleEq : c * sqrt (v n) / sqrt (m n) = z * sqrt (((1 - η) * v n) / m n) := by rw [show c = z * sqrt (1 - η) by rfl, mul_assoc, ← Real.sqrt_mul h1m.le] calc z * sqrt ((1 - η) * v n) / sqrt (m n) = z * (sqrt ((1 - η) * v n) / sqrt (m n)) := by ring _ = z * sqrt (((1 - η) * v n) / m n) := by rw [Real.sqrt_div (mul_nonneg h1m.le (hvarpos n).le)] have hratio : ((1 - η) * v n) / m n ≤ vhat n ω / m n := div_le_div_of_nonneg_right hgood (hmpos n).le have hscale : c * sqrt (v n) / sqrt (m n) ≤ z * sqrt (vhat n ω / m n) := by rw [hscaleEq] exact mul_le_mul_of_nonneg_left (Real.sqrt_le_sqrt hratio) hz0 rw [abs_sub_comm] exact habsEst.trans hscale have hBA : Tendsto (fun n => B n - A n) atTop (𝓝 (stdNormalCdf c - stdNormalCdf (-c))) := by simpa using hB.sub hA have hbelow : IsBoundedUnder (· ≥ ·) atTop (fun n => B n - A n) := hBA.isBoundedUnder_ge have hliminf : stdNormalCdf c - stdNormalCdf (-c) ≤ liminf I atTop := by calc stdNormalCdf c - stdNormalCdf (-c) = liminf (fun n => B n - A n) atTop := hBA.liminf_eq.symm _ ≤ liminf I atTop := Filter.liminf_le_liminf (Filter.Eventually.of_forall hstep) hbelow hIcobdd calc 2 * stdNormalCdf (z * sqrt (1 - η)) - 1 = stdNormalCdf c - stdNormalCdf (-c) := by rw [stdNormalCdf_neg c] simp [c] ring _ ≤ liminf I atTop := hliminf let g : ℝ → ℝ := fun η => 2 * stdNormalCdf (z * sqrt (1 - η)) - 1 have hg : Tendsto g (𝓝 0) (𝓝 (1 - α)) := by have hsqrt : Tendsto (fun η : ℝ => sqrt (1 - η)) (𝓝 0) (𝓝 1) := by have hsub : Tendsto (fun η : ℝ => (1 : ℝ) - η) (𝓝 0) (𝓝 ((1 : ℝ) - 0)) := tendsto_const_nhds.sub tendsto_id rw [sub_zero] at hsub have hs := (Real.continuous_sqrt.tendsto (1 : ℝ)).comp hsub rw [Real.sqrt_one] at hs exact hs have harg : Tendsto (fun η : ℝ => z * sqrt (1 - η)) (𝓝 0) (𝓝 z) := by simpa using tendsto_const_nhds.mul hsqrt have hPhi := (continuous_stdNormalCdf.tendsto z).comp harg have hg' : Tendsto g (𝓝 0) (𝓝 (2 * stdNormalCdf z - 1)) := by simpa [g] using (tendsto_const_nhds.mul hPhi).sub tendsto_const_nhds have : 2 * stdNormalCdf z - 1 = 1 - α := by rw [hz]; ring rwa [this] at hg' have hseq : Tendsto (fun k : ℕ => (1 : ℝ) / (k + 1)) atTop (𝓝 0) := tendsto_one_div_add_atTop_nhds_zero_nat have hgseq : Tendsto (fun k : ℕ => g (1 / (k + 1))) atTop (𝓝 (1 - α)) := hg.comp hseq have hev : ∀ᶠ k : ℕ in atTop, g (1 / (k + 1)) ≤ liminf I atTop := by rw [Filter.eventually_atTop] refine ⟨1, fun k hk => ?_⟩ have hk1 : (1 : ℝ) ≤ k := by exact_mod_cast hk have hden : (0 : ℝ) < k + 1 := by linarith have hpos : (0 : ℝ) < 1 / (k + 1) := by positivity have hlt : (1 : ℝ) / (k + 1) < 1 := by rw [div_lt_one hden]; linarith simpa [g] using key (1 / (k + 1)) hpos hlt exact le_of_tendsto hgseq hev
Causalean.Experimentation.DesignBased.conservative_wald_liminf_of_feasible_studentized_cdf · Causalean/Experimentation/DesignBased/WaldCoverage.lean:241 · uses FiniteDesign , Pr , stdNormalCdf
2 supporting declarations (lemmas, instances)
  • conservative_wald_liminf_of_studentized_cdf theorem — Conservative Wald-interval liminf coverage. Consider a sequence of finite designs with an estimator est n of a target θ n. Suppose the normalization size m n is eventually positive, the true variance scale v n is eventually positive, and a deterministic conservative variance v̂ n eventually dominates v n. Suppose further that the studentized statistic √(m n)·(est n − θ n)/√(v n) has design-probability CDF converging to the standard-normal CDF at z and at −z, where z is nonnegative and satisfies Φ(z) = 1 − α/2. Then the two-sided interval |θ n − est n| ≤ z·√(v̂ n / m n) has asymptotic (liminf) coverage at least 1 − α.
    Ω :
    ℕ → Type u_1
    shared
    D :
    ∀ n, FiniteDesign (Ω n)
    est :
    ∀ n
    if
    Ω n
    then
    ℝ
    θ v vhat m :
    ℕ → ℝ
    hmpos :
    ∀ᶠ n in atTop, 0 < m n
    hvarpos :
    ∀ᶠ n in atTop, 0 < v n
    hvar_le :
    ∀ᶠ n in atTop, v n ≤ vhat n
    α z :
    ℝ
    hclt :
    Tendsto (fun n => (D n).Pr (fun zz => sqrt (m n) * (est n zz - θ n) / sqrt (v n) ≤ z)) atTop (𝓝 (stdNormalCdf z))
    hclt_neg :
    Tendsto (fun n => (D n).Pr (fun zz => sqrt (m n) * (est n zz - θ n) / sqrt (v n) ≤ -z)) atTop (𝓝 (stdNormalCdf (-z)))
    hz0 :
    0 ≤ z
    hz :
    stdNormalCdf z = 1 - α / 2
    1 - α
    ≤ liminf (fun n => (D n).Pr (fun zz => |θ n - est n zz| ≤ z * sqrt (vhat n / m n))) atTop
    Proof (Lean source)
    theorem conservative_wald_liminf_of_studentized_cdf (D : ∀ n, FiniteDesign (Ω n)) (est : ∀ n, Ω n → ℝ) (θ v vhat m : ℕ → ℝ) (hmpos : ∀ᶠ n in atTop, 0 < m n) (hvarpos : ∀ᶠ n in atTop, 0 < v n) (hvar_le : ∀ᶠ n in atTop, v n ≤ vhat n) (α z : ℝ) (hclt : Tendsto (fun n => (D n).Pr (fun zz => sqrt (m n) * (est n zz - θ n) / sqrt (v n) ≤ z)) atTop (𝓝 (stdNormalCdf z))) (hclt_neg : Tendsto (fun n => (D n).Pr (fun zz => sqrt (m n) * (est n zz - θ n) / sqrt (v n) ≤ -z)) atTop (𝓝 (stdNormalCdf (-z)))) (hz0 : 0 ≤ z) (hz : stdNormalCdf z = 1 - α / 2) : 1 - α ≤ liminf (fun n => (D n).Pr (fun zz => |θ n - est n zz| ≤ z * sqrt (vhat n / m n))) atTop := by classical set S : ℕ → ℝ := fun n => (D n).Pr (fun zz => sqrt (m n) * (est n zz - θ n) / sqrt (v n) ≤ z) with hSdef set Lo : ℕ → ℝ := fun n => (D n).Pr (fun zz => sqrt (m n) * (est n zz - θ n) / sqrt (v n) ≤ -z) with hLodef set Iv : ℕ → ℝ := fun n => (D n).Pr (fun zz => |θ n - est n zz| ≤ z * sqrt (vhat n / m n)) with hIdef have hS : Tendsto S atTop (𝓝 (stdNormalCdf z)) := by simpa [S] using hclt have hLo : Tendsto Lo atTop (𝓝 (stdNormalCdf (-z))) := by simpa [Lo] using hclt_neg have hlim : Tendsto (fun n => S n - Lo n) atTop (𝓝 (1 - α)) := by have h := hS.sub hLo rw [stdNormalCdf_neg z, hz] at h have he : (1 - α / 2) - (1 - (1 - α / 2)) = 1 - α := by ring rwa [he] at h have hbound : ∀ᶠ n in atTop, S n - Lo n ≤ Iv n := by filter_upwards [hvarpos, hmpos, hvar_le] with n hvpos hmposn hvarlen set W : Ω n → ℝ := fun zz => sqrt (m n) * (est n zz - θ n) / sqrt (v n) with hWdef have hsplit := (D n).Pr_split (fun zz => W zz ≤ z) (fun zz => W zz ≤ -z) have hfirst : (D n).Pr (fun zz => W zz ≤ z ∧ W zz ≤ -z) = Lo n := by apply (D n).Pr_congr intro zz constructor · exact fun h => h.2 · intro h2 exact ⟨le_trans h2 (by linarith [hz0]), h2⟩ have hSLo : S n - Lo n = (D n).Pr (fun zz => W zz ≤ z ∧ ¬ W zz ≤ -z) := by have : S n = (D n).Pr (fun zz => W zz ≤ z ∧ W zz ≤ -z) + (D n).Pr (fun zz => W zz ≤ z ∧ ¬ W zz ≤ -z) := by simpa [S, W, hWdef] using hsplit rw [this, hfirst] ring rw [hSLo] apply (D n).Pr_mono intro zz hzz obtain ⟨hzhi, hzlo_not⟩ := hzz rw [not_le] at hzlo_not have habsW : |W zz| ≤ z := abs_le.mpr ⟨le_of_lt hzlo_not, hzhi⟩ set vn : ℝ := v n with hvndef set vhatn : ℝ := vhat n with hvhatndef set cardR : ℝ := m n with hcardRdef have hcardposR : 0 < cardR := by simpa [cardR] using hmposn have hsvar : 0 < sqrt vn := Real.sqrt_pos.mpr (by simpa [vn] using hvpos) have hscard : 0 < sqrt cardR := Real.sqrt_pos.mpr hcardposR have habs_est : |est n zz - θ n| ≤ z * sqrt vn / sqrt cardR := by rw [hWdef, abs_div, abs_mul, abs_of_pos hsvar, abs_of_nonneg (Real.sqrt_nonneg cardR), div_le_iff₀ hsvar] at habsW have hmul : sqrt cardR * |est n zz - θ n| ≤ z * sqrt vn := by simpa [vn, cardR, mul_comm, mul_left_comm, mul_assoc] using habsW exact (le_div_iff₀ hscard).mpr (by simpa [mul_comm, mul_left_comm, mul_assoc] using hmul) have hsqrt_le : sqrt vn / sqrt cardR ≤ sqrt (vhatn / cardR) := by rw [← Real.sqrt_div (le_of_lt (by simpa [vn] using hvpos)) cardR] exact Real.sqrt_le_sqrt (div_le_div_of_nonneg_right (by simpa [vn, vhatn] using hvarlen) hcardposR.le) have hscale_le : z * sqrt vn / sqrt cardR ≤ z * sqrt (vhatn / cardR) := by rw [mul_div_assoc] exact mul_le_mul_of_nonneg_left hsqrt_le hz0 have habs_tau : |θ n - est n zz| ≤ z * sqrt (vhatn / cardR) := by rw [abs_sub_comm] exact habs_est.trans hscale_le simpa [Iv, vhatn, cardR] using habs_tau have hbdd : IsBoundedUnder (· ≥ ·) atTop (fun n => S n - Lo n) := hlim.isBoundedUnder_ge have hcobdd : IsCoboundedUnder (· ≥ ·) atTop Iv := isCoboundedUnder_ge_of_le atTop (x := (1 : ℝ)) (fun n => (D n).Pr_le_one _) calc 1 - α = liminf (fun n => S n - Lo n) atTop := hlim.liminf_eq.symm _ ≤ liminf Iv atTop := Filter.liminf_le_liminf hbound hbdd hcobdd _ = liminf (fun n => (D n).Pr (fun zz => |θ n - est n zz| ≤ z * sqrt (vhat n / m n))) atTop := by rfl
    Causalean.Experimentation.DesignBased.conservative_wald_liminf_of_studentized_cdf · Causalean/Experimentation/DesignBased/WaldCoverage.lean:36
  • finiteDesign_symmetricBand_tendsto lemma — For a sequence of finite-design laws and real-valued statistics, if their CDFs converge pointwise to a limit CDF, the limit CDF is continuous, and the symmetric-band radius is nonnegative, then the closed symmetric-band probabilities converge to the difference of the limiting CDF at the two endpoints.
    Ω :
    ℕ → Type u_1
    shared
    D :
    ∀ n, FiniteDesign (Ω n)
    T :
    ∀ n
    if
    Ω n
    then
    ℝ
    F :
    ℝ → ℝ
    hT :
    ∀ x : ℝ, Tendsto (fun n => (D n).Pr (fun z => T n z ≤ x)) atTop (𝓝 (F x))
    hF :
    c :
    ℝ
    hc :
    0 ≤ c
    Tendsto (fun n => (D n).Pr (fun z => -c ≤ T n z ∧ T n z ≤ c)) atTop (𝓝 (F c - F (-c)))
    Proof (Lean source)
    lemma finiteDesign_symmetricBand_tendsto (D : ∀ n, FiniteDesign (Ω n)) (T : ∀ n, Ω n → ℝ) (F : ℝ → ℝ) (hT : ∀ x : ℝ, Tendsto (fun n => (D n).Pr (fun z => T n z ≤ x)) atTop (𝓝 (F x))) (hF : Continuous F) (c : ℝ) (hc : 0 ≤ c) : Tendsto (fun n => (D n).Pr (fun z => -c ≤ T n z ∧ T n z ≤ c)) atTop (𝓝 (F c - F (-c))) := by classical rw [Metric.tendsto_atTop] intro ε hε have hε8 : 0 < ε / 8 := by linarith obtain ⟨δ, hδ, hcont⟩ := (Metric.continuousAt_iff.1 hF.continuousAt) (ε / 8) hε8 let d : ℝ := δ / 2 have hd : 0 < d := by dsimp [d]; linarith have hdlt : dist (-c - d) (-c) < δ := by rw [Real.dist_eq] dsimp [d] rw [show -c - δ / 2 - -c = -(δ / 2) by ring, abs_neg, abs_of_pos (by linarith : 0 < δ / 2)] linarith have hFd : |F (-c - d) - F (-c)| < ε / 8 := by simpa [Real.dist_eq] using hcont hdlt let S : ℕ → ℝ := fun n => (D n).Pr (fun z => T n z ≤ c) let L : ℕ → ℝ := fun n => (D n).Pr (fun z => T n z ≤ -c) let Ld : ℕ → ℝ := fun n => (D n).Pr (fun z => T n z ≤ -c - d) let J : ℕ → ℝ := fun n => (D n).Pr (fun z => -c ≤ T n z ∧ T n z ≤ c) have hS := hT c have hL := hT (-c) have hLd := hT (-c - d) have hevS : ∀ᶠ n in atTop, |S n - F c| < ε / 8 := by simpa [S, Real.dist_eq] using (Metric.tendsto_nhds.1 hS) (ε / 8) hε8 have hevL : ∀ᶠ n in atTop, |L n - F (-c)| < ε / 8 := by simpa [L, Real.dist_eq] using (Metric.tendsto_nhds.1 hL) (ε / 8) hε8 have hevLd : ∀ᶠ n in atTop, |Ld n - F (-c - d)| < ε / 8 := by simpa [Ld, Real.dist_eq] using (Metric.tendsto_nhds.1 hLd) (ε / 8) hε8 have hbounds : ∀ n, S n - L n ≤ J n ∧ J n ≤ S n - Ld n := by intro n have hlo := (D n).Pr_split (fun z => T n z ≤ c) (fun z => T n z ≤ -c) have hld := (D n).Pr_split (fun z => T n z ≤ c) (fun z => T n z ≤ -c - d) have hlofirst : (D n).Pr (fun z => T n z ≤ c ∧ T n z ≤ -c) = L n := by apply (D n).Pr_congr intro z constructor · exact fun h => h.2 · intro h exact ⟨h.trans (by linarith), h⟩ have hldfirst : (D n).Pr (fun z => T n z ≤ c ∧ T n z ≤ -c - d) = Ld n := by apply (D n).Pr_congr intro z constructor · exact fun h => h.2 · intro h exact ⟨h.trans (by linarith), h⟩ have hloeq : S n - L n = (D n).Pr (fun z => T n z ≤ c ∧ ¬ T n z ≤ -c) := by have : S n = (D n).Pr (fun z => T n z ≤ c ∧ T n z ≤ -c) + (D n).Pr (fun z => T n z ≤ c ∧ ¬ T n z ≤ -c) := by simpa [S, L] using hlo rw [this, hlofirst] ring have hldeq : S n - Ld n = (D n).Pr (fun z => T n z ≤ c ∧ ¬ T n z ≤ -c - d) := by have : S n = (D n).Pr (fun z => T n z ≤ c ∧ T n z ≤ -c - d) + (D n).Pr (fun z => T n z ≤ c ∧ ¬ T n z ≤ -c - d) := by simpa [S, Ld] using hld rw [this, hldfirst] ring constructor · rw [hloeq] apply (D n).Pr_mono intro z hz exact ⟨le_of_not_ge hz.2, hz.1⟩ · rw [hldeq] apply (D n).Pr_mono intro z hz constructor · exact hz.2 · rw [not_le] linarith apply Filter.eventually_atTop.1 filter_upwards [hevS, hevL, hevLd] with n hnS hnL hnLd rw [Real.dist_eq, abs_lt] rcases hbounds n with ⟨hlower, hupper⟩ rcases abs_lt.1 hnS with ⟨hnSlo, hnShi⟩ rcases abs_lt.1 hnL with ⟨hnLlo, hnLhi⟩ rcases abs_lt.1 hnLd with ⟨hnLdlo, hnLdhi⟩ rcases abs_lt.1 hFd with ⟨hFdlo, hFdhi⟩ constructor <;> linarith
    Causalean.Experimentation.DesignBased.finiteDesign_symmetricBand_tendsto · Causalean/Experimentation/DesignBased/WaldCoverage.lean:148
Wald­Pipeline 1 core · 0 supporting dependency_wald_coverage chains the design-based dependency CLT (dependency_studentized_cdf) into the feasible Wald-coverage transfer. ★ dependency_wald_coverage

Design-based Wald-interval pipeline

dependency_wald_coverage chains the design-based dependency CLT (dependency_studentized_cdf) into the feasible Wald-coverage transfer. Given unit contributions X n whose standardized sum depSum(X n) is asymptotically equivalent to the scaled centered estimator √(m n)·(est n − θ n), and a random variance estimator vhat n whose probability of materially undershooting v n vanishes, the Wald interval |θ n − est n| ≤ z·√(vhat n / m n) has liminf coverage at least 1 − α.

theorem dependency_wald_coverage reviewed
Causalean.Experimentation.DesignBased

Design-based Wald-interval coverage from dependency-graph primitives. Consider a sequence of finite designs together with per-unit contributions X n i governed by a dependency graph Dep n on those contributions whose neighbourhoods have cardinality at most Dmax, where the contributions are uniformly bounded by a nonnegative constant M and have design mean zero. Suppose the standardizing quantity v n equals the design second moment of the contributions' sum depSum(X n), is bounded below by a positive constant c times the number of units eventually, and the number of units diverges. Suppose further that the standardized sum is asymptotically equivalent in probability to √(m n)·(est n − θ n) for an estimator est n of a target θ n, the normalization and oracle variance are positive, and a random feasible variance estimator has vanishing probability of material underestimation, with z the nonnegative quantile satisfying Φ(z) = 1 − α/2. Then the two-sided Wald interval |θ n − est n| ≤ z·√(v̂ n / m n) has asymptotic (liminf) coverage at least 1 − α.

Formal statement
Ω :
ℕ → Type*
∀ n, Fintype (Ω n)
∀ n, MeasurableSpace (Ω n)
D :
∀ n, FiniteDesign (Ω n)
ι :
ℕ → Type*
∀ n, Fintype (ι n)
X :
∀ n
if
ι n
and
Ω n
then
ℝ
Dep :
∀ n, DepGraph (X n) (D n).toMeasure
Dmax :
ℕ
hdeg :
∀ n i, ((Dep n).nbhd i).card ≤ Dmax
M :
ℝ
hM :
0 ≤ M
hbound :
∀ n i ω, |X n i ω| ≤ M
hmean :
∀ n i, (D n).E (X n i) = 0
v :
ℕ → ℝ
hv :
∀ n, (D n).E (fun ω => depSum (X n) ω ^ 2) = v n
c :
ℝ
hc :
0 < c
hvc :
∀ᶠ n in atTop, c * (card (ι n) : ℝ) ≤ v n
hcard :
Tendsto (fun n => card (ι n)) atTop atTop
est :
∀ n
if
Ω n
then
ℝ
θ m :
ℕ → ℝ
hlinkApprox :
∀ η : ℝ
if
0 < η
then
Tendsto (fun n => (D n).Pr (fun ω => η ≤ |sqrt (m n) * (est n ω - θ n) / sqrt (v n) - depSum (X n) ω / sqrt (v n)|)) atTop (𝓝 0)
hmpos :
∀ n, 0 < m n
hvpos :
∀ n, 0 < v n
vhat :
∀ n
if
Ω n
then
ℝ
hVhat :
∀ η : ℝ
if
0 < η
then
Tendsto (fun n => (D n).Pr (fun ω => vhat n ω < (1 - η) * v n)) atTop (𝓝 0)
α z :
ℝ
hz0 :
0 ≤ z
hz :
stdNormalCdf z = 1 - α / 2
1 - α
≤ liminf (fun n => (D n).Pr (fun ω => |θ n - est n ω| ≤ z * sqrt (vhat n ω / m n))) atTop
Proof (Lean source)
theorem dependency_wald_coverage {Ω : ℕ → Type*} [∀ n, Fintype (Ω n)] [∀ n, MeasurableSpace (Ω n)] [∀ n, MeasurableSingletonClass (Ω n)] (D : ∀ n, FiniteDesign (Ω n)) {ι : ℕ → Type*} [∀ n, Fintype (ι n)] (X : ∀ n, ι n → Ω n → ℝ) (Dep : ∀ n, DepGraph (X n) (D n).toMeasure) (Dmax : ℕ) (hdeg : ∀ n i, ((Dep n).nbhd i).card ≤ Dmax) (M : ℝ) (hM : 0 ≤ M) (hbound : ∀ n i ω, |X n i ω| ≤ M) (hmean : ∀ n i, (D n).E (X n i) = 0) (v : ℕ → ℝ) (hv : ∀ n, (D n).E (fun ω => depSum (X n) ω ^ 2) = v n) (c : ℝ) (hc : 0 < c) (hvc : ∀ᶠ n in atTop, c * (card (ι n) : ℝ) ≤ v n) (hcard : Tendsto (fun n => card (ι n)) atTop atTop) (est : ∀ n, Ω n → ℝ) (θ m : ℕ → ℝ) (hlinkApprox : ∀ η : ℝ, 0 < η → Tendsto (fun n => (D n).Pr (fun ω => η ≤ |sqrt (m n) * (est n ω - θ n) / sqrt (v n) - depSum (X n) ω / sqrt (v n)|)) atTop (𝓝 0)) (hmpos : ∀ n, 0 < m n) (hvpos : ∀ n, 0 < v n) (vhat : ∀ n, Ω n → ℝ) (hVhat : ∀ η : ℝ, 0 < η → Tendsto (fun n => (D n).Pr (fun ω => vhat n ω < (1 - η) * v n)) atTop (𝓝 0)) (α z : ℝ) (hz0 : 0 ≤ z) (hz : stdNormalCdf z = 1 - α / 2) : 1 - α ≤ liminf (fun n => (D n).Pr (fun ω => |θ n - est n ω| ≤ z * sqrt (vhat n ω / m n))) atTop := by classical have horacle : ∀ s : ℝ, Tendsto (fun n => (D n).Pr (fun ω => depSum (X n) ω / sqrt (v n) ≤ s)) atTop (𝓝 (stdNormalCdf s)) := by intro s exact dependency_studentized_cdf D X Dep Dmax hdeg M hM hbound hmean v hv c hc hvc hcard s have hclt : ∀ s : ℝ, Tendsto (fun n => (D n).Pr (fun ω => sqrt (m n) * (est n ω - θ n) / sqrt (v n) ≤ s)) atTop (𝓝 (stdNormalCdf s)) := finiteDesign_cdf_converging_together D (fun n ω => sqrt (m n) * (est n ω - θ n) / sqrt (v n)) (fun n ω => depSum (X n) ω / sqrt (v n)) stdNormalCdf hlinkApprox horacle continuous_stdNormalCdf exact conservative_wald_liminf_of_feasible_studentized_cdf D est θ v m vhat hmpos hvpos hVhat α z hclt hz0 hz