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 15 core · 30 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 5 core · 3 supporting · 1 submodule Entry point for paper-agnostic estimators of finite-population causal estimands and their randomization properties. HT 13 core · 0 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.
Design­Core 14 core · 32 supporting A FiniteDesign Ω is a probability mass function on a finite assignment space Ω. ★ FiniteDesign★ E_sum★ Var_eq★ Cov_eq★ Cov_linear_comb★ Var_linear_comb★ E_ind★ Var_ind

Finite randomization design

A FiniteDesign Ω is a probability mass function on a finite assignment space Ω. All estimators below are real-valued functions of the realized assignment z : Ω, and E, Var, Cov are their finite-sum moments under the design.

structure FiniteDesign reviewed
Causalean.Experimentation.DesignBased

A randomization design: a probability mass function p on a finite assignment space Ω whose values are nonnegative and sum to one.

Definition (Lean source)
Ω :
Type*
Design probability of assignment `z`.
p :
Ω → ℝ
Design probabilities are nonnegative.
p_nonneg :
∀ z, 0 ≤ p z
Design probabilities sum to one.
p_sum :
∑ z, p z = 1
Causalean.Experimentation.DesignBased.FiniteDesign · Causalean/Experimentation/DesignBased/DesignCore.lean:43
def E reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

Expectation of a random variable X : Ω → ℝ under the design.

Definition (Lean source)
def E (X : Ω → ℝ) : ℝ := ∑ z, D.p z * X z
Causalean.Experimentation.DesignBased.FiniteDesign.E · Causalean/Experimentation/DesignBased/DesignCore.lean:57 · uses FiniteDesign
def Var reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

Variance of X under the design.

Definition (Lean source)
def Var (X : Ω → ℝ) : ℝ := D.E (fun z => (X z - D.E X) ^ 2)
Causalean.Experimentation.DesignBased.FiniteDesign.Var · Causalean/Experimentation/DesignBased/DesignCore.lean:60 · uses FiniteDesign
def Cov reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

Covariance of X and Y under the design.

Definition (Lean source)
def Cov (X Y : Ω → ℝ) : ℝ := D.E (fun z => (X z - D.E X) * (Y z - D.E Y))
Causalean.Experimentation.DesignBased.FiniteDesign.Cov · Causalean/Experimentation/DesignBased/DesignCore.lean:63 · uses FiniteDesign
def ind reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

Indicator of an event A, as a {0,1}-valued random variable.

Definition (Lean source)
def ind (A : Ω → Prop) [DecidablePred A] : Ω → ℝ := fun z => if A z then 1 else 0
Causalean.Experimentation.DesignBased.FiniteDesign.ind · Causalean/Experimentation/DesignBased/DesignCore.lean:66
def Pr reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

Probability of an event A under the design.

Definition (Lean source)
def Pr (A : Ω → Prop) [DecidablePred A] : ℝ := D.E (ind A)
Causalean.Experimentation.DesignBased.FiniteDesign.Pr · Causalean/Experimentation/DesignBased/DesignCore.lean:69 · uses FiniteDesign
lemma E_sum reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

Linearity of expectation over a finite sum. For a finite index set s over an index type ι and a family of random variables f, the design expectation of the finite sum ∑ᵢ∈s fᵢ equals the finite sum of the design expectations ∑ᵢ∈s E[fᵢ].

Formal statement
ι :
Type*
s :
f :
ι → Ω → ℝ
D.E (fun z => ∑ i ∈ s, f i z) = ∑ i ∈ s, D.E (f i)
Proof (Lean source)
lemma E_sum {ι : Type*} (s : Finset ι) (f : ι → Ω → ℝ) : D.E (fun z => ∑ i ∈ s, f i z) = ∑ i ∈ s, D.E (f i) := by simp only [E, Finset.mul_sum] rw [Finset.sum_comm]
Causalean.Experimentation.DesignBased.FiniteDesign.E_sum · Causalean/Experimentation/DesignBased/DesignCore.lean:100 · uses FiniteDesign , E
lemma Var_eq reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

Variance identity. For any statistic X, its design variance equals the design expectation of minus the square of its design expectation.

Formal statement
X :
Ω → ℝ
D.Var X = D.E (fun z => (X z) ^ 2) - (D.E X) ^ 2
Proof (Lean source)
lemma Var_eq (X : Ω → ℝ) : D.Var X = D.E (fun z => (X z) ^ 2) - (D.E X) ^ 2 := by have h : (fun z => (X z - D.E X) ^ 2) = (fun z => (X z) ^ 2 + ((-(2 * D.E X)) * X z + (D.E X) ^ 2)) := by funext z; ring rw [Var, h, E_add, E_add, E_const_mul, E_const]; ring
Causalean.Experimentation.DesignBased.FiniteDesign.Var_eq · Causalean/Experimentation/DesignBased/DesignCore.lean:127 · uses FiniteDesign , E , Var
lemma Cov_eq reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

Covariance identity. For any two statistics X and Y under the design, their design covariance equals the design expectation of X·Y minus the product of their design expectations.

Formal statement
X Y :
Ω → ℝ
D.Cov X Y = D.E (fun z => X z * Y z) - D.E X * D.E Y
Proof (Lean source)
lemma Cov_eq (X Y : Ω → ℝ) : D.Cov X Y = D.E (fun z => X z * Y z) - D.E X * D.E Y := by have h : (fun z => (X z - D.E X) * (Y z - D.E Y)) = (fun z => X z * Y z + ((-(D.E Y)) * X z + ((-(D.E X)) * Y z + D.E X * D.E Y))) := by funext z; ring rw [Cov, h, E_add, E_add, E_add, E_const_mul, E_const_mul, E_const]; ring
Causalean.Experimentation.DesignBased.FiniteDesign.Cov_eq · Causalean/Experimentation/DesignBased/DesignCore.lean:135 · uses FiniteDesign , Cov , E
lemma Cov_linear_comb reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

Bilinear expansion of covariance for linear combinations. For finite weighted sums ∑ᵢ∈s cᵢXᵢ and ∑ⱼ∈t eⱼYⱼ, built from index sets s ⊆ ι, t ⊆ κ, weights c, e, and random-variable families X, Y, their design covariance equals the double sum over s×t of the weighted covariances cᵢeⱼ·Cov(Xᵢ,Yⱼ).

Formal statement
ι κ :
Type*
s :
t :
c :
ι → ℝ
e :
κ → ℝ
X :
ι → Ω → ℝ
Y :
κ → Ω → ℝ
D.Cov (fun z => ∑ i ∈ s, c i * X i z) (fun z => ∑ j ∈ t, e j * Y j z)
= ∑ i ∈ s, ∑ j ∈ t, c i * e j * D.Cov (X i) (Y j)
Proof (Lean source)
lemma Cov_linear_comb {ι κ : Type*} (s : Finset ι) (t : Finset κ) (c : ι → ℝ) (e : κ → ℝ) (X : ι → Ω → ℝ) (Y : κ → Ω → ℝ) : D.Cov (fun z => ∑ i ∈ s, c i * X i z) (fun z => ∑ j ∈ t, e j * Y j z) = ∑ i ∈ s, ∑ j ∈ t, c i * e j * D.Cov (X i) (Y j) := by rw [Cov_sum_left] apply Finset.sum_congr rfl; intro i _ rw [Cov_const_mul_left, Cov_sum_right, Finset.mul_sum] apply Finset.sum_congr rfl; intro j _ rw [Cov_const_mul_right]; ring
Causalean.Experimentation.DesignBased.FiniteDesign.Cov_linear_comb · Causalean/Experimentation/DesignBased/DesignCore.lean:207 · uses FiniteDesign , Cov
lemma Var_linear_comb reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

Variance of a finite linear combination. For a finite weighted sum ∑ᵢ∈s cᵢXᵢ, built from an index set s ⊆ ι, weights c, and a random-variable family X, its design variance equals the double sum of weighted covariances ∑ᵢ∈s∑ⱼ∈s cᵢcⱼ·Cov(Xᵢ,Xⱼ).

Formal statement
ι :
Type*
s :
c :
ι → ℝ
X :
ι → Ω → ℝ
D.Var (fun z => ∑ i ∈ s, c i * X i z) = ∑ i ∈ s, ∑ j ∈ s, c i * c j * D.Cov (X i) (X j)
Proof (Lean source)
lemma Var_linear_comb {ι : Type*} (s : Finset ι) (c : ι → ℝ) (X : ι → Ω → ℝ) : D.Var (fun z => ∑ i ∈ s, c i * X i z) = ∑ i ∈ s, ∑ j ∈ s, c i * c j * D.Cov (X i) (X j) := by rw [← Cov_self]; exact D.Cov_linear_comb s s c c X X
Causalean.Experimentation.DesignBased.FiniteDesign.Var_linear_comb · Causalean/Experimentation/DesignBased/DesignCore.lean:221 · uses FiniteDesign , Cov , Var
lemma E_ind reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

Expectation of an indicator. For any event A, the design expectation of its indicator equals the design probability of A.

Formal statement
A :
Ω → Prop
D.E (ind A) = D.Pr A
Proof (Lean source)
@[simp] lemma E_ind (A : Ω → Prop) [DecidablePred A] : D.E (ind A) = D.Pr A := rfl
Causalean.Experimentation.DesignBased.FiniteDesign.E_ind · Causalean/Experimentation/DesignBased/DesignCore.lean:232 · uses FiniteDesign , E , Pr , ind
lemma Var_ind reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

Variance of an indicator. For any event A, the design variance of its indicator equals the design probability of A times one minus that probability.

Formal statement
A :
Ω → Prop
D.Var (ind A) = D.Pr A * (1 - D.Pr A)
Proof (Lean source)
lemma Var_ind (A : Ω → Prop) [DecidablePred A] : D.Var (ind A) = D.Pr A * (1 - D.Pr A) := by rw [Var_eq, ind_sq, E_ind]; ring
Causalean.Experimentation.DesignBased.FiniteDesign.Var_ind · Causalean/Experimentation/DesignBased/DesignCore.lean:242 · uses FiniteDesign , Pr , Var , ind
def map reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

The pushforward design f_* D of D along f : Ω → Ω': the law of the transformed assignment f z when z is drawn from D. Its weight on y is the total design weight of the fiber f⁻¹{y}.

Definition (Lean source)
noncomputable def map {Ω' : Type*} [Fintype Ω'] (f : Ω → Ω') : FiniteDesign Ω' := by classical exact { p := fun y => ∑ z, if f z = y then D.p z else 0 p_nonneg := fun y => sum_nonneg fun z _ => by by_cases h : f z = y <;> simp [h, D.p_nonneg z] p_sum := by rw [Finset.sum_comm] simp only [Finset.sum_ite_eq, Finset.mem_univ, if_true] exact D.p_sum }
Causalean.Experimentation.DesignBased.FiniteDesign.map · Causalean/Experimentation/DesignBased/DesignCore.lean:306 · uses FiniteDesign
32 supporting declarations (lemmas, instances)
  • E_const lemma — The expectation of a constant random variable is that constant.
    c :
    D.E (fun _ => c) = c
    Proof (Lean source)
    @[simp] lemma E_const (c : ℝ) : D.E (fun _ => c) = c := by simp only [E, ← Finset.sum_mul, D.p_sum, one_mul]
    Causalean.Experimentation.DesignBased.FiniteDesign.E_const · Causalean/Experimentation/DesignBased/DesignCore.lean:74
  • E_add lemma — The expectation of a sum is the sum of expectations.
    X Y :
    Ω → ℝ
    D.E (fun z => X z + Y z) = D.E X + D.E Y
    Proof (Lean source)
    lemma E_add (X Y : Ω → ℝ) : D.E (fun z => X z + Y z) = D.E X + D.E Y := by simp only [E, mul_add, Finset.sum_add_distrib]
    Causalean.Experimentation.DesignBased.FiniteDesign.E_add · Causalean/Experimentation/DesignBased/DesignCore.lean:78
  • E_sub lemma — The expectation of a difference is the difference of expectations.
    X Y :
    Ω → ℝ
    D.E (fun z => X z - Y z) = D.E X - D.E Y
    Proof (Lean source)
    lemma E_sub (X Y : Ω → ℝ) : D.E (fun z => X z - Y z) = D.E X - D.E Y := by simp only [E, mul_sub, Finset.sum_sub_distrib]
    Causalean.Experimentation.DesignBased.FiniteDesign.E_sub · Causalean/Experimentation/DesignBased/DesignCore.lean:82
  • E_const_mul lemma — Multiplying a random variable by a constant on the left multiplies its expectation by that constant.
    c :
    X :
    Ω → ℝ
    D.E (fun z => c * X z) = c * D.E X
    Proof (Lean source)
    lemma E_const_mul (c : ℝ) (X : Ω → ℝ) : D.E (fun z => c * X z) = c * D.E X := by simp only [E, Finset.mul_sum]; congr 1; funext z; ring
    Causalean.Experimentation.DesignBased.FiniteDesign.E_const_mul · Causalean/Experimentation/DesignBased/DesignCore.lean:86
  • E_mul_const lemma — Multiplying a random variable by a constant on the right multiplies its expectation by that constant.
    X :
    Ω → ℝ
    c :
    D.E (fun z => X z * c) = D.E X * c
    Proof (Lean source)
    lemma E_mul_const (X : Ω → ℝ) (c : ℝ) : D.E (fun z => X z * c) = D.E X * c := by simp only [E, Finset.sum_mul]; congr 1; funext z; ring
    Causalean.Experimentation.DesignBased.FiniteDesign.E_mul_const · Causalean/Experimentation/DesignBased/DesignCore.lean:91
  • E_neg lemma — The expectation of a negated random variable is the negated expectation.
    X :
    Ω → ℝ
    D.E (fun z => -X z) = -D.E X
    Proof (Lean source)
    lemma E_neg (X : Ω → ℝ) : D.E (fun z => -X z) = -D.E X := by simp only [E, mul_neg, Finset.sum_neg_distrib]
    Causalean.Experimentation.DesignBased.FiniteDesign.E_neg · Causalean/Experimentation/DesignBased/DesignCore.lean:96
  • E_congr lemma — Congruence: pointwise-equal random variables have equal expectation.
    X Y :
    Ω → ℝ
    h :
    ∀ z, X z = Y z
    D.E X = D.E Y
    Proof (Lean source)
    lemma E_congr {X Y : Ω → ℝ} (h : ∀ z, X z = Y z) : D.E X = D.E Y := by unfold E; exact Finset.sum_congr rfl (fun z _ => by rw [h z])
    Causalean.Experimentation.DesignBased.FiniteDesign.E_congr · Causalean/Experimentation/DesignBased/DesignCore.lean:109
  • Var_congr lemma — Congruence: pointwise-equal random variables have equal variance.
    X Y :
    Ω → ℝ
    h :
    ∀ z, X z = Y z
    D.Var X = D.Var Y
    Proof (Lean source)
    lemma Var_congr {X Y : Ω → ℝ} (h : ∀ z, X z = Y z) : D.Var X = D.Var Y := by have hE : D.E X = D.E Y := D.E_congr h unfold Var; rw [hE]; exact D.E_congr (fun z => by rw [h z])
    Causalean.Experimentation.DesignBased.FiniteDesign.Var_congr · Causalean/Experimentation/DesignBased/DesignCore.lean:113
  • Cov_congr lemma — Congruence: pointwise-equal random variables have equal covariance.
    X Y X' Y' :
    Ω → ℝ
    hX :
    ∀ z, X z = X' z
    hY :
    ∀ z, Y z = Y' z
    D.Cov X Y = D.Cov X' Y'
    Proof (Lean source)
    lemma Cov_congr {X Y X' Y' : Ω → ℝ} (hX : ∀ z, X z = X' z) (hY : ∀ z, Y z = Y' z) : D.Cov X Y = D.Cov X' Y' := by have hEX : D.E X = D.E X' := D.E_congr hX have hEY : D.E Y = D.E Y' := D.E_congr hY unfold Cov; rw [hEX, hEY]; exact D.E_congr (fun z => by rw [hX z, hY z])
    Causalean.Experimentation.DesignBased.FiniteDesign.Cov_congr · Causalean/Experimentation/DesignBased/DesignCore.lean:118
  • Cov_self lemma — The covariance of a random variable with itself is its variance.
    X :
    Ω → ℝ
    D.Cov X X = D.Var X
    Proof (Lean source)
    lemma Cov_self (X : Ω → ℝ) : D.Cov X X = D.Var X := by unfold Cov Var; exact D.E_congr (fun z => by ring)
    Causalean.Experimentation.DesignBased.FiniteDesign.Cov_self · Causalean/Experimentation/DesignBased/DesignCore.lean:145
  • Cov_comm lemma — Covariance is symmetric in its two arguments.
    X Y :
    Ω → ℝ
    D.Cov X Y = D.Cov Y X
    Proof (Lean source)
    lemma Cov_comm (X Y : Ω → ℝ) : D.Cov X Y = D.Cov Y X := by unfold Cov; exact D.E_congr (fun z => by ring)
    Causalean.Experimentation.DesignBased.FiniteDesign.Cov_comm · Causalean/Experimentation/DesignBased/DesignCore.lean:149
  • Cov_const_mul_left lemma — Multiplying the left random variable by a constant multiplies covariance by that constant.
    c :
    X Y :
    Ω → ℝ
    D.Cov (fun z => c * X z) Y = c * D.Cov X Y
    Proof (Lean source)
    lemma Cov_const_mul_left (c : ℝ) (X Y : Ω → ℝ) : D.Cov (fun z => c * X z) Y = c * D.Cov X Y := by rw [Cov_eq, Cov_eq, E_const_mul] have : D.E (fun z => c * X z * Y z) = c * D.E (fun z => X z * Y z) := by rw [← E_const_mul]; exact D.E_congr (fun z => by ring) rw [this]; ring
    Causalean.Experimentation.DesignBased.FiniteDesign.Cov_const_mul_left · Causalean/Experimentation/DesignBased/DesignCore.lean:155
  • Cov_sum_left lemma — Covariance with a finite sum in the left argument is the finite sum of covariances.
    ι :
    Type*
    s :
    f :
    ι → Ω → ℝ
    Y :
    Ω → ℝ
    D.Cov (fun z => ∑ i ∈ s, f i z) Y = ∑ i ∈ s, D.Cov (f i) Y
    Proof (Lean source)
    lemma Cov_sum_left {ι : Type*} (s : Finset ι) (f : ι → Ω → ℝ) (Y : Ω → ℝ) : D.Cov (fun z => ∑ i ∈ s, f i z) Y = ∑ i ∈ s, D.Cov (f i) Y := by have hEY : D.E (fun z => (∑ i ∈ s, f i z) * Y z) = ∑ i ∈ s, D.E (fun z => f i z * Y z) := by rw [← E_sum]; exact D.E_congr (fun z => by rw [Finset.sum_mul]) simp only [Cov_eq] rw [hEY, E_sum, Finset.sum_mul, ← Finset.sum_sub_distrib]
    Causalean.Experimentation.DesignBased.FiniteDesign.Cov_sum_left · Causalean/Experimentation/DesignBased/DesignCore.lean:163
  • Cov_sum_right lemma — Covariance with a finite sum in the right argument is the finite sum of covariances.
    ι :
    Type*
    s :
    X :
    Ω → ℝ
    g :
    ι → Ω → ℝ
    D.Cov X (fun z => ∑ i ∈ s, g i z) = ∑ i ∈ s, D.Cov X (g i)
    Proof (Lean source)
    lemma Cov_sum_right {ι : Type*} (s : Finset ι) (X : Ω → ℝ) (g : ι → Ω → ℝ) : D.Cov X (fun z => ∑ i ∈ s, g i z) = ∑ i ∈ s, D.Cov X (g i) := by rw [Cov_comm, Cov_sum_left] exact Finset.sum_congr rfl (fun i _ => D.Cov_comm _ _)
    Causalean.Experimentation.DesignBased.FiniteDesign.Cov_sum_right · Causalean/Experimentation/DesignBased/DesignCore.lean:172
  • Cov_const_mul_right lemma — Multiplying the right random variable by a constant multiplies covariance by that constant.
    c :
    X Y :
    Ω → ℝ
    D.Cov X (fun z => c * Y z) = c * D.Cov X Y
    Proof (Lean source)
    lemma Cov_const_mul_right (c : ℝ) (X Y : Ω → ℝ) : D.Cov X (fun z => c * Y z) = c * D.Cov X Y := by rw [Cov_comm, Cov_const_mul_left, Cov_comm]
    Causalean.Experimentation.DesignBased.FiniteDesign.Cov_const_mul_right · Causalean/Experimentation/DesignBased/DesignCore.lean:178
  • Cov_sub_left lemma — Covariance is linear over differences in its left argument.
    X Y Z :
    Ω → ℝ
    D.Cov (fun z => X z - Y z) Z = D.Cov X Z - D.Cov Y Z
    Proof (Lean source)
    lemma Cov_sub_left (X Y Z : Ω → ℝ) : D.Cov (fun z => X z - Y z) Z = D.Cov X Z - D.Cov Y Z := by have h1 : D.E (fun z => (X z - Y z) * Z z) = D.E (fun z => X z * Z z) - D.E (fun z => Y z * Z z) := by rw [← E_sub]; exact D.E_congr (fun z => by ring) rw [Cov_eq, Cov_eq, Cov_eq, E_sub, h1]; ring
    Causalean.Experimentation.DesignBased.FiniteDesign.Cov_sub_left · Causalean/Experimentation/DesignBased/DesignCore.lean:183
  • Cov_sub_right lemma — Covariance is linear over differences in its right argument.
    X Y Z :
    Ω → ℝ
    D.Cov X (fun z => Y z - Z z) = D.Cov X Y - D.Cov X Z
    Proof (Lean source)
    lemma Cov_sub_right (X Y Z : Ω → ℝ) : D.Cov X (fun z => Y z - Z z) = D.Cov X Y - D.Cov X Z := by rw [Cov_comm, Cov_sub_left, D.Cov_comm Y X, D.Cov_comm Z X]
    Causalean.Experimentation.DesignBased.FiniteDesign.Cov_sub_right · Causalean/Experimentation/DesignBased/DesignCore.lean:191
  • Var_sub lemma — Variance of a difference: Var(X−Y) = Var X + Var Y − 2 Cov(X,Y).
    X Y :
    Ω → ℝ
    D.Var (fun z => X z - Y z) = D.Var X + D.Var Y - 2 * D.Cov X Y
    Proof (Lean source)
    lemma Var_sub (X Y : Ω → ℝ) : D.Var (fun z => X z - Y z) = D.Var X + D.Var Y - 2 * D.Cov X Y := by rw [← Cov_self, Cov_sub_left, Cov_sub_right, Cov_sub_right, Cov_self, Cov_self, D.Cov_comm Y X] ring
    Causalean.Experimentation.DesignBased.FiniteDesign.Var_sub · Causalean/Experimentation/DesignBased/DesignCore.lean:196
  • Var_const_mul lemma — Variance scales by the square of a constant: Var(c·X) = c²·Var X.
    c :
    X :
    Ω → ℝ
    D.Var (fun z => c * X z) = c ^ 2 * D.Var X
    Proof (Lean source)
    lemma Var_const_mul (c : ℝ) (X : Ω → ℝ) : D.Var (fun z => c * X z) = c ^ 2 * D.Var X := by rw [← Cov_self, Cov_const_mul_left, Cov_const_mul_right, Cov_self]; ring
    Causalean.Experimentation.DesignBased.FiniteDesign.Var_const_mul · Causalean/Experimentation/DesignBased/DesignCore.lean:202
  • ind_sq lemma — 1_A ^ 2 = 1_A, the idempotence of an indicator.
    A :
    Ω → Prop
    (fun z => (ind A z) ^ 2) = ind A
    Proof (Lean source)
    lemma ind_sq (A : Ω → Prop) [DecidablePred A] : (fun z => (ind A z) ^ 2) = ind A := by funext z; unfold ind; by_cases h : A z <;> simp [h]
    Causalean.Experimentation.DesignBased.FiniteDesign.ind_sq · Causalean/Experimentation/DesignBased/DesignCore.lean:237
  • E_nonneg lemma — Expectation of a nonnegative random variable is nonnegative.
    X :
    Ω → ℝ
    h :
    ∀ z, 0 ≤ X z
    0 ≤ D.E X
    Proof (Lean source)
    lemma E_nonneg {X : Ω → ℝ} (h : ∀ z, 0 ≤ X z) : 0 ≤ D.E X := sum_nonneg (fun z _ => mul_nonneg (D.p_nonneg z) (h z))
    Causalean.Experimentation.DesignBased.FiniteDesign.E_nonneg · Causalean/Experimentation/DesignBased/DesignCore.lean:250
  • E_le_one lemma — Expectation of a random variable bounded above by one is at most one.
    X :
    Ω → ℝ
    h1 :
    ∀ z, X z ≤ 1
    D.E X ≤ 1
    Proof (Lean source)
    lemma E_le_one {X : Ω → ℝ} (h1 : ∀ z, X z ≤ 1) : D.E X ≤ 1 := by calc D.E X = ∑ z, D.p z * X z := rfl _ ≤ ∑ z, D.p z * 1 := Finset.sum_le_sum (fun z _ => mul_le_mul_of_nonneg_left (h1 z) (D.p_nonneg z)) _ = 1 := by simp [D.p_sum]
    Causalean.Experimentation.DesignBased.FiniteDesign.E_le_one · Causalean/Experimentation/DesignBased/DesignCore.lean:254
  • ind_nonneg lemma — An event indicator is always nonnegative.
    A :
    Ω → Prop
    z :
    Ω
    0 ≤ ind A z
    Proof (Lean source)
    lemma ind_nonneg (A : Ω → Prop) [DecidablePred A] (z : Ω) : 0 ≤ ind A z := by unfold ind; by_cases h : A z <;> simp [h]
    Causalean.Experimentation.DesignBased.FiniteDesign.ind_nonneg · Causalean/Experimentation/DesignBased/DesignCore.lean:262
  • ind_le_one lemma — An event indicator is always at most one.
    A :
    Ω → Prop
    z :
    Ω
    ind A z ≤ 1
    Proof (Lean source)
    lemma ind_le_one (A : Ω → Prop) [DecidablePred A] (z : Ω) : ind A z ≤ 1 := by unfold ind; by_cases h : A z <;> simp [h]
    Causalean.Experimentation.DesignBased.FiniteDesign.ind_le_one · Causalean/Experimentation/DesignBased/DesignCore.lean:267
  • Pr_nonneg lemma — A probability lies in [0,1]: nonnegativity.
    A :
    Ω → Prop
    0 ≤ D.Pr A
    Proof (Lean source)
    lemma Pr_nonneg (A : Ω → Prop) [DecidablePred A] : 0 ≤ D.Pr A := D.E_nonneg (fun z => ind_nonneg A z)
    Causalean.Experimentation.DesignBased.FiniteDesign.Pr_nonneg · Causalean/Experimentation/DesignBased/DesignCore.lean:271
  • Pr_le_one lemma — A probability lies in [0,1]: at most one.
    A :
    Ω → Prop
    D.Pr A ≤ 1
    Proof (Lean source)
    lemma Pr_le_one (A : Ω → Prop) [DecidablePred A] : D.Pr A ≤ 1 := D.E_le_one (fun z => ind_le_one A z)
    Causalean.Experimentation.DesignBased.FiniteDesign.Pr_le_one · Causalean/Experimentation/DesignBased/DesignCore.lean:275
  • Pr_congr lemma — Probability respects pointwise-equivalent events.
    A B :
    h :
    ∀ z, A z ↔ B z
    D.Pr A = D.Pr B
    Proof (Lean source)
    lemma Pr_congr (A B : Ω → Prop) [DecidablePred A] [DecidablePred B] (h : ∀ z, A z ↔ B z) : D.Pr A = D.Pr B := by unfold Pr; exact D.E_congr (fun z => by unfold ind; simp only [h z])
    Causalean.Experimentation.DesignBased.FiniteDesign.Pr_congr · Causalean/Experimentation/DesignBased/DesignCore.lean:279
  • Pr_mono lemma — Monotonicity of probability: a smaller event has smaller probability.
    A B :
    h :
    ∀ z
    if
    A z
    then
    B z
    D.Pr A ≤ D.Pr B
    Proof (Lean source)
    lemma Pr_mono (A B : Ω → Prop) [DecidablePred A] [DecidablePred B] (h : ∀ z, A z → B z) : D.Pr A ≤ D.Pr B := by unfold Pr E ind apply Finset.sum_le_sum intro z _ apply mul_le_mul_of_nonneg_left _ (D.p_nonneg z) by_cases hA : A z · simp [hA, h z hA] · by_cases hB : B z <;> simp [hA, hB]
    Causalean.Experimentation.DesignBased.FiniteDesign.Pr_mono · Causalean/Experimentation/DesignBased/DesignCore.lean:284
  • Pr_split lemma — Finite additivity: splitting an event by a second event.
    B A :
    D.Pr B = D.Pr (fun z => B z ∧ A z) + D.Pr (fun z => B z ∧ ¬ A z)
    Proof (Lean source)
    lemma Pr_split (B A : Ω → Prop) [DecidablePred A] [DecidablePred B] : D.Pr B = D.Pr (fun z => B z ∧ A z) + D.Pr (fun z => B z ∧ ¬ A z) := by unfold Pr E ind rw [← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro z _ by_cases hB : B z <;> by_cases hA : A z <;> simp [hB, hA]
    Causalean.Experimentation.DesignBased.FiniteDesign.Pr_split · Causalean/Experimentation/DesignBased/DesignCore.lean:295
  • map_p lemma — The pushforward weight of y is the fiber sum ∑_{z} 1[f z = y] · D.p z.
    Ω' :
    Type*
    f :
    Ω → Ω'
    y :
    Ω'
    (D.map f).p y = ∑ z, @ite ℝ (f z = y) (propDecidable _) (D.p z) 0
    Proof (Lean source)
    @[simp] lemma map_p {Ω' : Type*} [Fintype Ω'] (f : Ω → Ω') (y : Ω') : (D.map f).p y = ∑ z, @ite ℝ (f z = y) (propDecidable _) (D.p z) 0 := by classical rfl
    Causalean.Experimentation.DesignBased.FiniteDesign.map_p · Causalean/Experimentation/DesignBased/DesignCore.lean:321
  • E_map lemma — Transfer of expectation across a pushforward. The expectation of g under the pushforward f_* D equals the expectation of the composite g ∘ f under D.
    Ω' :
    Type*
    f :
    Ω → Ω'
    g :
    Ω' → ℝ
    (D.map f).E g = D.E (fun z => g (f z))
    Proof (Lean source)
    lemma E_map {Ω' : Type*} [Fintype Ω'] (f : Ω → Ω') (g : Ω' → ℝ) : (D.map f).E g = D.E (fun z => g (f z)) := by classical unfold E map simp only [Finset.sum_mul] rw [Finset.sum_comm] refine Finset.sum_congr rfl fun z _ => ?_ have hpt : ∀ y, (if f z = y then D.p z else 0) * g y = if f z = y then D.p z * g y else 0 := fun y => by by_cases h : f z = y <;> simp [h] simp only [hpt, Finset.sum_ite_eq, Finset.mem_univ, if_true]
    Causalean.Experimentation.DesignBased.FiniteDesign.E_map · Causalean/Experimentation/DesignBased/DesignCore.lean:327
  • Pr_map lemma — Transfer of probability across a pushforward. The probability of an event A under the pushforward f_* D equals the probability of its preimage under D.
    Ω' :
    Type*
    f :
    Ω → Ω'
    A :
    Ω' → Prop
    (D.map f).Pr A = D.Pr (fun z => A (f z))
    Proof (Lean source)
    lemma Pr_map {Ω' : Type*} [Fintype Ω'] (f : Ω → Ω') (A : Ω' → Prop) [DecidablePred A] : (D.map f).Pr A = D.Pr (fun z => A (f z)) := by classical unfold Pr; rw [E_map]; rfl
    Causalean.Experimentation.DesignBased.FiniteDesign.Pr_map · Causalean/Experimentation/DesignBased/DesignCore.lean:341
Finite­Design­Measure 4 core · 2 supporting Finite randomization designs can be viewed as ordinary probability measures, enabling reuse of measure-theoretic probability results. ★ integral_toMeasure★ toMeasure_real_setOf★ variance_toMeasure

Finite designs as probability measures

Finite randomization designs can be viewed as ordinary probability measures, enabling reuse of measure-theoretic probability results.

For a design D, FiniteDesign.toMeasure places mass D.p z at each assignment z. The induced measure is registered as an IsProbabilityMeasure, and the bridge theorems integral_toMeasure, toMeasure_real_setOf, and variance_toMeasure identify integrals, event probabilities, and variances under D.toMeasure with the finite-design operations D.E, D.Pr, and D.Var.

def toMeasure reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

The probability measure on Ω induced by the design: ∑_z (p z)·δ_z.

Definition (Lean source)
noncomputable def toMeasure : Measure Ω := ∑ z, ofReal (D.p z) • Measure.dirac z
Causalean.Experimentation.DesignBased.FiniteDesign.toMeasure · Causalean/Experimentation/DesignBased/FiniteDesignMeasure.lean:48 · uses FiniteDesign
theorem integral_toMeasure reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

Integral against the induced measure is the design expectation. For any statistic g, the measure-theoretic integral of g against the design's induced probability measure equals its design expectation.

Formal statement
g :
Ω → ℝ
∫ x, g x ∂D.toMeasure = D.E g
Proof (Lean source)
theorem integral_toMeasure (g : Ω → ℝ) : ∫ x, g x ∂D.toMeasure = D.E g := by rw [toMeasure, integral_finset_sum_measure] · have h : ∀ z ∈ (Finset.univ : Finset Ω), ∫ x, g x ∂(ofReal (D.p z) • Measure.dirac z) = D.p z * g z := by intro z _ rw [integral_smul_measure, integral_dirac, smul_eq_mul, ENNReal.toReal_ofReal (D.p_nonneg z)] rw [Finset.sum_congr rfl h] rfl · intro z _ exact (integrable_dirac (by simp)).smul_measure (by simp)
Causalean.Experimentation.DesignBased.FiniteDesign.integral_toMeasure · Causalean/Experimentation/DesignBased/FiniteDesignMeasure.lean:70 · uses FiniteDesign , E , toMeasure
theorem toMeasure_real_setOf reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

Induced measure matches the design probability. For any event A, the induced measure's probability of A equals the design probability of A.

Formal statement
A :
Ω → Prop
D.toMeasure.real {z | A z} = D.Pr A
Proof (Lean source)
theorem toMeasure_real_setOf (A : Ω → Prop) [DecidablePred A] : D.toMeasure.real {z | A z} = D.Pr A := by rw [← integral_indicator_one (Set.toFinite {z | A z}).measurableSet, Pr, ← integral_toMeasure] refine integral_congr_ae (Filter.Eventually.of_forall (fun z => ?_)) unfold ind by_cases h : A z <;> simp [indicator, h]
Causalean.Experimentation.DesignBased.FiniteDesign.toMeasure_real_setOf · Causalean/Experimentation/DesignBased/FiniteDesignMeasure.lean:85 · uses FiniteDesign , Pr , toMeasure
theorem variance_toMeasure reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

Measure-theoretic variance equals the design variance. For any statistic g, the measure-theoretic variance of g under the design's induced measure equals its design variance.

Formal statement
g :
Ω → ℝ
variance g D.toMeasure = D.Var g
Proof (Lean source)
theorem variance_toMeasure (g : Ω → ℝ) : variance g D.toMeasure = D.Var g := by rw [variance_eq_integral (measurable_of_finite g).aemeasurable, integral_toMeasure, integral_toMeasure] rfl
Causalean.Experimentation.DesignBased.FiniteDesign.variance_toMeasure · Causalean/Experimentation/DesignBased/FiniteDesignMeasure.lean:95 · uses FiniteDesign , Var , toMeasure
2 supporting declarations (lemmas, instances)
  • toMeasure_apply lemma — The measure induced by a finite randomization design assigns each set the sum, over assignments, of each assignment's probability times the point mass of that assignment on the set.
    s :
    Set Ω
    D.toMeasure s = ∑ z, ofReal (D.p z) * Measure.dirac z s
    Proof (Lean source)
    lemma toMeasure_apply (s : Set Ω) : D.toMeasure s = ∑ z, ofReal (D.p z) * Measure.dirac z s := by rw [toMeasure, Measure.finset_sum_apply] refine Finset.sum_congr rfl (fun z _ => ?_) rw [Measure.smul_apply, smul_eq_mul]
    Causalean.Experimentation.DesignBased.FiniteDesign.toMeasure_apply · Causalean/Experimentation/DesignBased/FiniteDesignMeasure.lean:52
  • instIsProbabilityMeasureToMeasure instance — The measure induced by a finite randomization design has total mass one.
    instance : IsProbabilityMeasure D.toMeasure := by refine ⟨?_⟩ rw [toMeasure_apply] have h : ∀ z ∈ (Finset.univ : Finset Ω), ofReal (D.p z) * Measure.dirac z univ = ofReal (D.p z) := by intro z _; rw [Measure.dirac_apply' z MeasurableSet.univ]; simp rw [Finset.sum_congr rfl h, ← ENNReal.ofReal_sum_of_nonneg (fun z _ => D.p_nonneg z), D.p_sum, ENNReal.ofReal_one]
    Causalean.Experimentation.DesignBased.FiniteDesign.instIsProbabilityMeasureToMeasure · Causalean/Experimentation/DesignBased/FiniteDesignMeasure.lean:60
Product 4 core · 0 supporting This file constructs prodDesign, the finite product of a family of independent randomization designs. ★ prodDesign★ prodDesign_p★ E_prod_prod★ E_prod_apply

Product finite randomization designs

This file constructs prodDesign, the finite product of a family of independent randomization designs. Its probability mass function is the product of the coordinate probabilities, recorded by prodDesign_p.

The main expectation identities are FiniteDesign.E_prod_prod, which factors expectations of products of coordinate functions, and FiniteDesign.E_prod_apply, which says a statistic depending on one coordinate has the expectation induced by that coordinate's marginal design.

def prodDesign reviewed
Causalean.Experimentation.DesignBased

The product design of a finite family D i : FiniteDesign (α i): each coordinate is randomized independently, with joint pmf w ↦ ∏ i, (D i).p (w i).

Definition (Lean source)
def prodDesign (D : ∀ i, FiniteDesign (α i)) : FiniteDesign (∀ i, α i) where p w := ∏ i, (D i).p (w i) p_nonneg w := Finset.prod_nonneg (fun i _ => (D i).p_nonneg (w i)) p_sum := by rw [show (∑ w : ∀ i, α i, ∏ i, (D i).p (w i)) = ∏ i, ∑ a : α i, (D i).p a from by rw [Finset.prod_univ_sum]; rw [Fintype.piFinset_univ]] simp only [FiniteDesign.p_sum, Finset.prod_const_one]
Causalean.Experimentation.DesignBased.prodDesign · Causalean/Experimentation/DesignBased/Product.lean:45 · uses FiniteDesign
lemma prodDesign_p reviewed
Causalean.Experimentation.DesignBased

For a family of independent coordinate designs D and an assignment w, the product-design probability of w equals the product of the coordinate probabilities ∏ᵢ (D i).p (w i).

Formal statement
D :
∀ i, FiniteDesign (α i)
w :
∀ i, α i
(prodDesign D).p w = ∏ i, (D i).p (w i)
Proof (Lean source)
@[simp] lemma prodDesign_p (D : ∀ i, FiniteDesign (α i)) (w : ∀ i, α i) : (prodDesign D).p w = ∏ i, (D i).p (w i) := rfl
Causalean.Experimentation.DesignBased.prodDesign_p · Causalean/Experimentation/DesignBased/Product.lean:55 · uses FiniteDesign , prodDesign
lemma E_prod_prod reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

For a family of independent coordinate designs D and single-coordinate functions g, the expectation under the product design of the product ∏ᵢ g i (w i) factors into the product of the individual coordinate expectations ∏ᵢ (D i).E (g i).

Formal statement
D :
∀ i, FiniteDesign (α i)
g :
∀ i
if
α i
then
(prodDesign D).E (fun w => ∏ i, g i (w i)) = ∏ i, (D i).E (g i)
Proof (Lean source)
lemma E_prod_prod (D : ∀ i, FiniteDesign (α i)) (g : ∀ i, α i → ℝ) : (prodDesign D).E (fun w => ∏ i, g i (w i)) = ∏ i, (D i).E (g i) := by simp only [FiniteDesign.E, prodDesign_p] rw [show (∑ w : ∀ i, α i, (∏ i, (D i).p (w i)) * ∏ i, g i (w i)) = ∑ w : ∀ i, α i, ∏ i, ((D i).p (w i) * g i (w i)) from Finset.sum_congr rfl (fun w _ => by rw [Finset.prod_mul_distrib])] rw [Finset.prod_univ_sum, Fintype.piFinset_univ]
Causalean.Experimentation.DesignBased.FiniteDesign.E_prod_prod · Causalean/Experimentation/DesignBased/Product.lean:63 · uses FiniteDesign , E , prodDesign
lemma E_prod_apply reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

For a family of independent coordinate designs D, the expectation under the product design of a function of a single coordinate j equals the expectation of that same function under coordinate j's own marginal design.

Formal statement
D :
∀ i, FiniteDesign (α i)
j :
ι
g :
α j → ℝ
(prodDesign D).E (fun w => g (w j)) = (D j).E g
Proof (Lean source)
lemma E_prod_apply (D : ∀ i, FiniteDesign (α i)) (j : ι) (g : α j → ℝ) : (prodDesign D).E (fun w => g (w j)) = (D j).E g := by have hg : (fun w : ∀ i, α i => g (w j)) = (fun w => ∏ i, (fun (i : ι) (a : α i) => if h : i = j then g (h ▸ a) else 1) i (w i)) := by funext w simp only rw [Finset.prod_dite_eq' univ j (fun i h => g (h ▸ w i))] simp rw [hg, E_prod_prod D (fun (i : ι) (a : α i) => if h : i = j then g (h ▸ a) else 1)] rw [Finset.prod_eq_single j] · congr 1 funext a simp · intro i _ hij have hF : (fun a : α i => (if h : i = j then g (h ▸ a) else (1 : ℝ))) = (fun _ => 1) := by funext a; rw [dif_neg hij] rw [hF, (D i).E_const] · intro h; exact absurd (Finset.mem_univ j) h
Causalean.Experimentation.DesignBased.FiniteDesign.E_prod_apply · Causalean/Experimentation/DesignBased/Product.lean:74 · uses FiniteDesign , E , prodDesign
Gaussian­CDF 3 core · 4 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

Standard normal cumulative distribution function Φ(t) = P[Z ≤ t], Z ∼ 𝒩(0,1), in the (gaussianReal 0 1).real (Iic t) presentation used by the design-based interval theorems. Definitionally the canonical Causalean.Mathlib.stdNormalCDF (see stdNormalCdf_eq).

Definition (Lean source)
noncomputable def stdNormalCdf (t : ℝ) : ℝ := (gaussianReal 0 1).real (Iic t)
Causalean.Experimentation.DesignBased.stdNormalCdf · Causalean/Experimentation/DesignBased/GaussianCDF.lean:37
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:60 · 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)
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:65 · uses stdNormalCdf
4 supporting declarations (lemmas, instances)
Exposure 9 core · 2 supporting Exposure mappings turn assignments and unit traits into treatment conditions, and generalized exposure probabilities are the design probabilities of those conditions. ★ prop★ E_expoInd★ Cov_expoInd_same★ Cov_expoInd_cross★ sum_prop_eq_one

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

The exposure unit i receives under assignment z: f z (θ i).

Definition (Lean source)
def expo (f : Ω → Θ → Δ) (θ : ι → Θ) (i : ι) (z : Ω) : Δ := f z (θ i)
Causalean.Experimentation.DesignBased.expo · Causalean/Experimentation/DesignBased/Exposure.lean:45
def expoInd reviewed
Causalean.Experimentation.DesignBased

Indicator that unit i is in exposure condition d under assignment z.

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

Generalized probability of exposure: π_i(d) = Pr[expo i = d].

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

Joint exposure probability π_{ij}(d) = E[1(expo i = d)·1(expo j = d)].

Definition (Lean source)
def propPairSame (D : FiniteDesign Ω) (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:58 · uses FiniteDesign
def propPairCross reviewed
Causalean.Experimentation.DesignBased

Cross joint exposure probability π_{ij}(d,d') = E[1(expo i = d)·1(expo j = d')].

Definition (Lean source)
def propPairCross (D : FiniteDesign Ω) (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:62 · 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
D :
f :
Ω → Θ → Δ
θ :
ι → Θ
i :
ι
d :
Δ
D.E (expoInd f θ i d) = prop D f θ i d
Proof (Lean source)
@[simp] 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:66 · 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
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
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]
Causalean.Experimentation.DesignBased.Cov_expoInd_cross · Causalean/Experimentation/DesignBased/Exposure.lean:84 · uses FiniteDesign , Cov , expoInd , prop , propPairCross
lemma sum_prop_eq_one reviewed
Causalean.Experimentation.DesignBased

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.

Formal statement
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:115 · uses FiniteDesign , prop
2 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.
    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:96
  • propPairCross_self_of_ne lemma — The self cross-exposure joint probability vanishes for distinct exposures.
    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:105
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

Bias of an estimator est for the target μ under the design: E[est] − μ.

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

Mean squared error of est for the target μ under the design: E[(est − μ)²].

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

An estimator is unbiased for μ under the design when its expectation equals μ.

Definition (Lean source)
def Unbiased (est : Ω → ℝ) (μ : ℝ) : Prop := D.E est = μ
Causalean.Experimentation.DesignBased.FiniteDesign.Unbiased · Causalean/Experimentation/DesignBased/Risk.lean:47 · 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
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:50 · 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.
    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:61
  • bias_of_unbiased lemma — The bias of an unbiased estimator is zero.
    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:68
  • mse_nonneg lemma — Mean squared error is nonnegative.
    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:73
  • Var_nonneg lemma — Variance is nonnegative (it is the mean squared error of the centered estimator).
    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:77
  • var_le_mse lemma — Mean squared error is bounded below by the variance.
    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:82
  • mse_congr lemma — Congruence: pointwise-equal estimators have equal mean squared error.
    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:87
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

Generic conditional composition of a first-stage finite design with a finite second-stage design chosen after observing the first-stage outcome.

Definition (Lean source)
def compoundCore {Ω₂ : Type*} [Fintype Ω₂] (D₁ : FiniteDesign Ω₁) (D₂ : Ω₁ → FiniteDesign Ω₂) : FiniteDesign (Ω₁ × Ω₂) where p sw := D₁.p sw.1 * (D₂ sw.1).p sw.2 p_nonneg sw := mul_nonneg (D₁.p_nonneg sw.1) ((D₂ sw.1).p_nonneg sw.2) 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:47 · uses FiniteDesign
def compound reviewed
Causalean.Experimentation.DesignBased

The compound (two-stage) design: stage-1 design D₁ on Ω₁, then, conditionally on the stage-1 outcome s, the independent within-coordinate designs D₂ s i.

Definition (Lean source)
def compound (D₁ : FiniteDesign Ω₁) (D₂ : Ω₁ → ∀ i, FiniteDesign (α i)) : FiniteDesign (Ω₁ × ∀ i, α i) := compoundCore D₁ (fun s => prodDesign (D₂ s))
Causalean.Experimentation.DesignBased.compound · Causalean/Experimentation/DesignBased/TwoStage.lean:61 · 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
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:69 · 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
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:81 · uses FiniteDesign , E , compound
Chebyshev 1 core · 1 supporting This file proves FiniteDesign.chebyshev, the finite-design Chebyshev inequality Pr[ε ≤ |X - E X|] ≤ Var X / ε ^ 2 for a statistic on a finite assignment space. ★ chebyshev

Finite Chebyshev inequality

This file proves FiniteDesign.chebyshev, the finite-design Chebyshev inequality Pr[ε ≤ |X - E X|] ≤ Var X / ε ^ 2 for a statistic on a finite assignment space. The proof works directly from FiniteDesign.Pr, FiniteDesign.E, and FiniteDesign.Var, so it can be used in design-based consistency arguments without moving through the measure-theoretic probability layer.

theorem chebyshev reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

Finite-design Chebyshev inequality. In a finite design, for any statistic X and a strictly positive threshold ε, the design probability that X differs from its design mean by at least ε is at most the design variance of X divided by ε².

Formal statement
X :
Ω → ℝ
ε :
:
0 < ε
D.Pr (fun z => ε ≤ |X z - D.E X|) ≤ D.Var X / ε ^ 2
Proof (Lean source)
theorem chebyshev (X : Ω → ℝ) {ε : ℝ} (hε : 0 < ε) : D.Pr (fun z => ε ≤ |X z - D.E X|) ≤ D.Var X / ε ^ 2 := by have hε2 : (0 : ℝ) < ε ^ 2 := pow_pos hε 2 -- Monotonicity of a finite sum (proved from scratch: the ordered-`BigOperators` -- module is not in scope here, only the basic algebraic one). have hmono : ∀ (s : Finset Ω) (a b : Ω → ℝ), (∀ i ∈ s, a i ≤ b i) → ∑ i ∈ s, a i ≤ ∑ i ∈ s, b i := by intro s induction s using Finset.induction with | empty => intro a b _; simp | insert x t hx ih => intro a b h rw [Finset.sum_insert hx, Finset.sum_insert hx] exact add_le_add (h x (mem_insert_self x t)) (ih a b (fun i hi => h i (mem_insert_of_mem hi))) -- Core inequality: `ε² * Pr(event) ≤ Var X`. have hcore : ε ^ 2 * D.Pr (fun z => ε ≤ |X z - D.E X|) ≤ D.Var X := by -- Write both sides as `∑ z, D.p z * (…)`, then compare term by term. have hlhs : ε ^ 2 * D.Pr (fun z => ε ≤ |X z - D.E X|) = ∑ z, D.p z * (ε ^ 2 * (if ε ≤ |X z - D.E X| then (1 : ℝ) else 0)) := by unfold FiniteDesign.Pr FiniteDesign.E FiniteDesign.ind rw [Finset.mul_sum] exact Finset.sum_congr rfl (fun z _ => by ring) have hrhs : D.Var X = ∑ z, D.p z * (X z - D.E X) ^ 2 := rfl rw [hlhs, hrhs] refine hmono univ _ _ (fun z _ => ?_) refine mul_le_mul_of_nonneg_left ?_ (D.p_nonneg z) by_cases hz' : ε ≤ |X z - D.E X| · simp only [hz', if_true, mul_one] rw [← sq_abs (X z - D.E X)] exact pow_le_pow_left₀ hε.le hz' 2 · simp only [hz', if_false, mul_zero] exact sq_nonneg _ rw [le_div_iff₀ hε2, mul_comm] exact hcore
Causalean.Experimentation.DesignBased.FiniteDesign.chebyshev · Causalean/Experimentation/DesignBased/Chebyshev.lean:37 · uses FiniteDesign , E , Pr , Var
1 supporting declaration (lemmas, instances)
  • Pr_eq_zero_le lemma — Zero-hitting bound for a nonzero-mean statistic. In a finite design, a statistic whose design mean is nonzero equals zero with probability at most its design variance divided by the square of its mean. This is the Chebyshev corollary that controls degeneracy of a random Horvitz–Thompson / Hájek denominator: a zero value is exactly a deviation from the mean of size equal to the mean, so it is Var / mean²-rare.
    X :
    Ω → ℝ
    h :
    D.E X ≠ 0
    D.Pr (fun z => X z = 0) ≤ D.Var X / (D.E X) ^ 2
    Proof (Lean source)
    lemma Pr_eq_zero_le (X : Ω → ℝ) (h : D.E X ≠ 0) : D.Pr (fun z => X z = 0) ≤ D.Var X / (D.E X) ^ 2 := by have hpos : (0 : ℝ) < |D.E X| := abs_pos.mpr h have hmono : D.Pr (fun z => X z = 0) ≤ D.Pr (fun z => |D.E X| ≤ |X z - D.E X|) := by apply D.Pr_mono intro z hz have habs : |X z - D.E X| = |D.E X| := by rw [hz, zero_sub, abs_neg] exact le_of_eq habs.symm have hcheb : D.Pr (fun z => |D.E X| ≤ |X z - D.E X|) ≤ D.Var X / |D.E X| ^ 2 := D.chebyshev X hpos rw [sq_abs] at hcheb exact hmono.trans hcheb
    Causalean.Experimentation.DesignBased.FiniteDesign.Pr_eq_zero_le · Causalean/Experimentation/DesignBased/Chebyshev.lean:77
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
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:64 · uses FiniteDesign , E , Var , compound , prodDesign
1 supporting declaration (lemmas, instances)
Concentration 1 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 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.

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 Bernstein bound.

Formal statement
X :
Ω → ℝ
c v ε :
hc :
0 ≤ c
hmean :
D.E X = 0
hbound :
∀ z, |X z| ≤ c
hvar :
D.Var X ≤ v
:
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:71 · uses FiniteDesign , E , Pr , Var
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.
    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:40
  • bernstein_ge theorem — Bernstein tail for a bounded design statistic (one-sided). 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ε))), far sharper than Chebyshev.
    X :
    Ω → ℝ
    c v ε :
    hc :
    0 ≤ c
    hmean :
    D.E X = 0
    hbound :
    ∀ z, |X z| ≤ c
    hvar :
    D.Var X ≤ v
    :
    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:58
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_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 · 3 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*
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)) := sum_nonneg (fun k _ => mul_nonneg (χ_nonneg _) (sum_nonneg (fun l _ => χ_nonneg _))) have hjsum_nn : (0 : ℝ) ≤ ∑ j, χ (G i j) := 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)) := sum_nonneg (fun l _ => mul_nonneg (χ_nonneg _) (sum_nonneg (fun k _ => χ_nonneg _))) have hjsum_nn : (0 : ℝ) ≤ ∑ j, χ (G i j) := 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:95 · uses FiniteDesign , Cov , Var
3 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.
    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:42
  • 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.
    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:62
  • Cov_zero_left lemma — The covariance of the identically-zero random variable with anything is zero.
    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:83
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

The diagonal dependency graph for the per-coordinate summands X n i = fun w => g n i (w i) under the product-design measure: each coordinate depends only on itself (G a b := a = b). The independence field is the product-measure block independence indepFun_prodDesign_apply_blocks, since distinct coordinate-index sets are disjoint.

Definition (Lean source)
noncomputable def diagDepGraph (D : ∀ n, ∀ i, FiniteDesign (α n i)) (g : ∀ n, ∀ i, α n i → ℝ) (n : ℕ) : DepGraph (fun (i : ι n) (w : ∀ j, α n j) => g n i (w i)) (prodDesign (D n)).toMeasure where G a b := a = b decG := inferInstance refl _ := rfl symm _ _ h := h.symm meas i := (Measurable.of_discrete).comp (measurable_pi_apply i) indep A B hAB := by -- Distinct index sets are disjoint, so the coordinate-block evaluations are independent. 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
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 [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 rw [hdepSum n]; exact measurable_sum _ (fun i _ => hmeas n i) 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]
In­Prob 5 core · 6 supporting Finite-design convergence in probability tracks vanishing assignment-tail probabilities along a sequence of randomization designs. ★ tendstoInProb_of_var★ sub★ tendstoInProb_div_one

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

Convergence in probability along a sequence of finite designs: X m converges in probability to the target c m if Pr(|X m − c m| ≥ ε) → 0 for every ε > 0.

Definition (Lean source)
def TendstoInProb (D : ∀ m, FiniteDesign (Ω m)) (X : ∀ m, Ω m → ℝ) (c : ℕ → ℝ) : Prop := ∀ ε : ℝ, 0 < ε → 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:51 · 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
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:57 · uses FiniteDesign , E , TendstoInProb , Var
theorem sub reviewed
Causalean.Experimentation.DesignBased.FiniteDesign.TendstoInProb

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.

Formal statement
D :
∀ m, FiniteDesign (Ω m)
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:83 · uses FiniteDesign , TendstoInProb
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
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:156 · uses FiniteDesign , TendstoInProb
def BoundedInProb reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

Uniform tightness (bounded in probability). The statistics X m are uniformly tight if, for every tolerance η, there is a single threshold M past which the deviation probability Pr(M ≤ |X m|) is at most η for every index m. This is the O_p(1) counterpart of TendstoInProb, satisfied by a bounded (non-vanishing) factor of a delta-method remainder.

Definition (Lean source)
def BoundedInProb (D : ∀ m, FiniteDesign (Ω m)) (X : ∀ m, Ω m → ℝ) : Prop := ∀ η : ℝ, 0 < η → ∃ M : ℝ, ∀ᶠ m in atTop, (D m).Pr (fun z => M ≤ |X m z|) ≤ η
Causalean.Experimentation.DesignBased.FiniteDesign.BoundedInProb · Causalean/Experimentation/DesignBased/InProb.lean:261 · uses FiniteDesign
6 supporting declarations (lemmas, instances)
  • 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:71
  • add theorem — Convergence in probability is closed under sums.
    D :
    ∀ m, FiniteDesign (Ω m)
    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:118
  • abs theorem — If X m → 0 in probability then |X m| → 0 in probability.
    D :
    ∀ m, FiniteDesign (Ω m)
    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:149
  • 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.
    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:268
  • 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.
    D :
    ∀ m, FiniteDesign (Ω m)
    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:304
  • mul_boundedInProb theorem — Product-tightness (o_p × O_p = o_p). If U m converges to zero in probability and V m is uniformly tight (bounded in probability), then the product U m · V m converges to zero in probability. This is the engine that turns a delta-method remainder — a vanishing factor times a bounded factor — into an o_p(1) term.
    D :
    ∀ m, FiniteDesign (Ω m)
    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:324
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

A family of dependence blocks has degree at most d if no single unit's treatment is read by more than d of the blocks. When the blocks are the in-neighbourhoods of a dependency graph this is the bound on out-degree.

Definition (Lean source)
def BlockDegreeLE (N : U → Finset U) (d : ℕ) : Prop := ∀ j : U, (Finset.univ.filter fun i => j ∈ N i).card ≤ d
Causalean.Experimentation.DesignBased.BlockDegreeLE · Causalean/Experimentation/DesignBased/LocalDependenceVariance.lean:46
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
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:52 · uses BlockDegreeLE , DependsOnBlock , E , bernoulliDesign
Measure­Bridge 1 core · 7 supporting For a finite design D, FiniteDesign.E, FiniteDesign.Var, and FiniteDesign.Pr are the design expectation, variance, and event probability. ★ abs_Cov_le

Descent bundle: design operations as measure-theoretic operations

For a finite design D, FiniteDesign.E, FiniteDesign.Var, and FiniteDesign.Pr are the design expectation, variance, and event probability. This file exposes them as the integral, variance, and event measure of D.toMeasure, and proves that every statistic is Lᵖ under D.toMeasure (memLp_toMeasure) and strongly measurable (aestronglyMeasurable_toMeasure). These are the obligations that gate the reuse of measure-theoretic inference results, so discharging them once lets those results transfer to the design layer directly.

lemma abs_Cov_le reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

Cauchy–Schwarz for the design covariance. In any finite design, the absolute covariance of two statistics X and Y is at most the product of their design standard deviations, |Cov(X,Y)| ≤ √(Var X) · √(Var Y).

Formal statement
X Y :
Ω → ℝ
|D.Cov X Y| ≤ sqrt (D.Var X) * sqrt (D.Var Y)
Proof (Lean source)
lemma abs_Cov_le (X Y : Ω → ℝ) : |D.Cov X Y| ≤ sqrt (D.Var X) * sqrt (D.Var Y) := by rw [D.Cov_eq_covariance X Y, D.Var_eq_variance X, D.Var_eq_variance Y] exact abs_covariance_le_sqrt_mul (D.memLp_toMeasure X 2) (D.memLp_toMeasure Y 2)
Causalean.Experimentation.DesignBased.FiniteDesign.abs_Cov_le · Causalean/Experimentation/DesignBased/MeasureBridge.lean:90 · uses FiniteDesign , Cov , Var
7 supporting declarations (lemmas, instances)
Potential­Outcome 3 core · 3 supporting Exposure-indexed potential outcomes factor observed outcomes through a finite assignment's exposure. ★ Yobs_eq_sum

Potential outcomes under exposure mappings

Exposure-indexed potential outcomes factor observed outcomes through a finite assignment's exposure.

ProperlySpecified states that randomization potential outcomes factor through the exposure mapping, while Yobs evaluates the exposure-indexed potential outcome at the realized exposure. The lemmas Yobs_eq_sum, expoInd_mul_Yobs, expoInd_mul_Yobs_sq, and expoInd₂_mul_Yobs provide the consistency and on-event substitution identities used by Horvitz-Thompson and variance calculations.

def ProperlySpecified reviewed
Causalean.Experimentation.DesignBased

A properly specified exposure mapping: the randomization potential outcome yr factors through the exposure via exposure-indexed potential outcomes y.

Definition (Lean source)
def ProperlySpecified (y : ι → Δ → ℝ) (yr : ι → Ω → ℝ) (f : Ω → Θ → Δ) (θ : ι → Θ) : Prop := ∀ i z, yr i z = y i (expo f θ i z)
Causalean.Experimentation.DesignBased.ProperlySpecified · Causalean/Experimentation/DesignBased/PotentialOutcome.lean:43
def Yobs reviewed
Causalean.Experimentation.DesignBased

Observed outcome of unit i under assignment z: y i (expo i z).

Definition (Lean source)
def Yobs (y : ι → Δ → ℝ) (f : Ω → Θ → Δ) (θ : ι → Θ) (i : ι) (z : Ω) : ℝ := y i (expo f θ i z)
Causalean.Experimentation.DesignBased.Yobs · Causalean/Experimentation/DesignBased/PotentialOutcome.lean:48
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
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:55 · 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.
    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:67
  • expoInd_mul_Yobs_sq lemma — Squared on-event substitution: 1(expo i = d)·(Yobs i)² = 1(expo i = d)·(y i d)².
    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:75
  • 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.
    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:82
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
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:59 · 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
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:106 · 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
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:117 · uses FiniteDesign , Cov , prodDesign
1 supporting declaration (lemmas, instances)
  • nonempty_of_design theorem — Every coordinate type carrying a finite design is nonempty.
    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:50
Product­Measure 2 core · 5 supporting The measure induced by a finite product design is Mathlib's product measure. ★ prodDesign_toMeasure_eq_pi★ indepFun_prodDesign_blocks

Product-design measures

The measure induced by a finite product design is Mathlib's product measure.

prodDesign_toMeasure_eq_pi identifies (prodDesign D).toMeasure with Measure.pi (fun i => (D i).toMeasure), using FiniteDesign.toMeasure_singleton to compare singleton masses. The independence results iIndepFun_prodDesign_eval, indepFun_prodDesign_eval, indepFun_prodDesign_blocks, and indepFun_prodDesign_apply_blocks then expose Mathlib's product-measure independence for coordinate projections and disjoint coordinate blocks.

theorem prodDesign_toMeasure_eq_pi reviewed
Causalean.Experimentation.DesignBased

The product design IS Mathlib's product measure. For a family of independent coordinate designs D, the probability measure induced by the product design prodDesign D coincides exactly with Mathlib's product measure of the coordinate design measures. Both are finite measures on the Fintype ∀ i, α i, so they agree iff they agree on every singleton {w}; on a singleton both sides evaluate to ∏ i, (D i).p (w i).

Formal statement
D :
∀ i, FiniteDesign (α i)
(prodDesign D).toMeasure = Measure.pi (fun i => (D i).toMeasure)
Proof (Lean source)
theorem prodDesign_toMeasure_eq_pi (D : ∀ i, FiniteDesign (α i)) : (prodDesign D).toMeasure = Measure.pi (fun i => (D i).toMeasure) := by refine Measure.ext_of_singleton (fun w => ?_) -- LHS: the product-design measure of `{w}` is `∏ i, (D i).p (w i)`. rw [FiniteDesign.toMeasure_singleton (prodDesign D) w, prodDesign_p, ENNReal.ofReal_prod_of_nonneg (fun i _ => (D i).p_nonneg (w i))] -- RHS: `{w} = Set.univ.pi (fun i => {w i})`, so `Measure.pi … {w} = ∏ i, (D i).toMeasure {w i}`. have hsingleton : ({w} : Set (∀ i, α i)) = Set.univ.pi (fun i => {w i}) := by ext x; simp [funext_iff] rw [hsingleton, Measure.pi_pi] exact Finset.prod_congr rfl (fun i _ => (FiniteDesign.toMeasure_singleton (D i) (w i)).symm)
Causalean.Experimentation.DesignBased.prodDesign_toMeasure_eq_pi · Causalean/Experimentation/DesignBased/ProductMeasure.lean:69 · uses FiniteDesign , toMeasure , prodDesign
theorem indepFun_prodDesign_blocks reviewed
Causalean.Experimentation.DesignBased

Disjoint-block independence. For a family of independent coordinate designs D, suppose the finite index sets A and B are disjoint. Then the tuple of coordinates indexed by A is probabilistically independent of the tuple of coordinates indexed by B, under the measure induced by the product design. This is the form a diagonal dependency graph G a b := a = b consumes.

Formal statement
D :
∀ i, FiniteDesign (α i)
A B :
hAB :
IndepFun (fun (w : ∀ k, α k) (k : A) => w k) (fun w (k : B) => w k) (prodDesign D).toMeasure
Proof (Lean source)
theorem indepFun_prodDesign_blocks (D : ∀ i, FiniteDesign (α i)) {A B : Finset ι} (hAB : Disjoint A B) : IndepFun (fun (w : ∀ k, α k) (k : A) => w k) (fun w (k : B) => w k) (prodDesign D).toMeasure := (iIndepFun_prodDesign_eval D).indepFun_finset A B hAB (fun i => measurable_pi_apply i)
Causalean.Experimentation.DesignBased.indepFun_prodDesign_blocks · Causalean/Experimentation/DesignBased/ProductMeasure.lean:101 · uses FiniteDesign , toMeasure , prodDesign
5 supporting declarations (lemmas, instances)
  • toMeasure_singleton lemma — The design measure of a singleton equals that singleton's design probability: (D i).toMeasure {a} = (D i).p a. (The dirac sum collapses to the single term z = a.)
    D.toMeasure {a} = ofReal (D.p a)
    Proof (Lean source)
    lemma toMeasure_singleton {β : Type*} [Fintype β] [MeasurableSpace β] [MeasurableSingletonClass β] (D : FiniteDesign β) (a : β) : D.toMeasure {a} = ofReal (D.p a) := by rw [toMeasure, Measure.finset_sum_apply] rw [Finset.sum_eq_single a] · rw [Measure.smul_apply, smul_eq_mul, Measure.dirac_apply' a (measurableSet_singleton a)] simp · intro z _ hz rw [Measure.smul_apply, smul_eq_mul, Measure.dirac_apply' z (measurableSet_singleton a), Set.indicator_of_notMem (by simpa using hz)] simp · intro h; exact absurd (Finset.mem_univ a) h
    Causalean.Experimentation.DesignBased.FiniteDesign.toMeasure_singleton · Causalean/Experimentation/DesignBased/ProductMeasure.lean:52
  • iIndepFun_prodDesign_eval lemma — Coordinate evaluations are mutually independent under the product-design measure: viewing fun (i) (w) => w i as the family of coordinate projections, this family is iIndepFun under (prodDesign D).toMeasure. (The push-forward of iIndepFun_pi along prodDesign_toMeasure_eq_pi.)
    D :
    ∀ i, FiniteDesign (α i)
    iIndepFun (fun (i : ι) (w : ∀ j, α j) => w i) (prodDesign D).toMeasure
    Proof (Lean source)
    lemma iIndepFun_prodDesign_eval (D : ∀ i, FiniteDesign (α i)) : iIndepFun (fun (i : ι) (w : ∀ j, α j) => w i) (prodDesign D).toMeasure := by rw [prodDesign_toMeasure_eq_pi] exact iIndepFun_pi (X := fun _ => id) (fun i => aemeasurable_id)
    Causalean.Experimentation.DesignBased.iIndepFun_prodDesign_eval · Causalean/Experimentation/DesignBased/ProductMeasure.lean:86
  • indepFun_prodDesign_eval theorem — For i ≠ j, the two coordinate evaluations w ↦ w i and w ↦ w j are independent under the product-design measure.
    D :
    ∀ i, FiniteDesign (α i)
    i j :
    ι
    hij :
    i ≠ j
    IndepFun (fun w : ∀ k, α k => w i) (fun w => w j) (prodDesign D).toMeasure
    Proof (Lean source)
    theorem indepFun_prodDesign_eval (D : ∀ i, FiniteDesign (α i)) {i j : ι} (hij : i ≠ j) : IndepFun (fun w : ∀ k, α k => w i) (fun w => w j) (prodDesign D).toMeasure := (iIndepFun_prodDesign_eval D).indepFun hij
    Causalean.Experimentation.DesignBased.indepFun_prodDesign_eval · Causalean/Experimentation/DesignBased/ProductMeasure.lean:95
  • indepFun_prodDesign_apply_blocks theorem — Functions of disjoint coordinate blocks are independent. Applying separate measurable function families to the coordinates in two disjoint blocks preserves their independence, even when the two blocks have different coordinatewise output spaces.
    D :
    ∀ i, FiniteDesign (α i)
    β γ :
    ι → Type*
    ∀ i, MeasurableSpace (β i)
    ∀ i, MeasurableSpace (γ i)
    g :
    ∀ i
    if
    α i
    then
    β i
    h :
    ∀ i
    if
    α i
    then
    γ i
    hg :
    ∀ i, Measurable (g i)
    hh :
    ∀ i, Measurable (h i)
    A B :
    hAB :
    IndepFun (fun (w : ∀ k, α k) (k : A) => g k (w k)) (fun w (k : B) => h k (w k)) (prodDesign D).toMeasure
    Proof (Lean source)
    theorem indepFun_prodDesign_apply_blocks (D : ∀ i, FiniteDesign (α i)) {β γ : ι → Type*} [∀ i, MeasurableSpace (β i)] [∀ i, MeasurableSpace (γ i)] {g : ∀ i, α i → β i} {h : ∀ i, α i → γ i} (hg : ∀ i, Measurable (g i)) (hh : ∀ i, Measurable (h i)) {A B : Finset ι} (hAB : Disjoint A B) : IndepFun (fun (w : ∀ k, α k) (k : A) => g k (w k)) (fun w (k : B) => h k (w k)) (prodDesign D).toMeasure := (indepFun_prodDesign_blocks D hAB).comp (φ := fun (v : ∀ k : A, α k) (k : A) => g k (v k)) (ψ := fun (v : ∀ k : B, α k) (k : B) => h k (v k)) (by fun_prop) (by fun_prop)
    Causalean.Experimentation.DesignBased.indepFun_prodDesign_apply_blocks · Causalean/Experimentation/DesignBased/ProductMeasure.lean:113
  • indepFun_prodDesign_of_depends_on_disjoint_blocks theorem — General functions of disjoint coordinate blocks are independent. The strict generalization of indepFun_prodDesign_apply_blocks from coordinatewise-separable maps (g k (w k))_k to *arbitrary* measurable functions that each depend only on a block: if F is unchanged by any assignment that agrees on S, and G is unchanged by any assignment that agrees on the disjoint set T, then F and G are independent under the product-design measure. This is the hypothesis a dependency-graph construction actually consumes, where each summand depends jointly (not coordinatewise) on a neighbourhood block.
    β γ :
    D :
    ∀ i, FiniteDesign (α i)
    S T :
    hST :
    F :
    (∀ i, α i) → β
    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'
    Proof (Lean source)
    theorem indepFun_prodDesign_of_depends_on_disjoint_blocks {β γ : Type*} [MeasurableSpace β] [MeasurableSpace γ] (D : ∀ i, FiniteDesign (α i)) {S T : Finset ι} (hST : Disjoint S T) (F : (∀ i, α i) → β) (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') : IndepFun F G (prodDesign D).toMeasure := by classical have hne : ∀ 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 let x₀ : ∀ i, α i := fun i => (hne i).some let F₀ : (∀ k : (S : Finset ι), α k) → β := fun a => F (fun i => if h : i ∈ S then a ⟨i, h⟩ else x₀ i) let G₀ : (∀ k : (T : Finset ι), α k) → γ := fun b => G (fun i => if h : i ∈ T then b ⟨i, h⟩ else x₀ i) have hF₀ : ∀ w, F w = F₀ (fun k : (S : Finset ι) => w k) := by intro w refine hF _ _ (fun i hi => ?_) simp [hi] have hG₀ : ∀ w, G w = G₀ (fun k : (T : Finset ι) => w k) := by intro w refine hG _ _ (fun i hi => ?_) simp [hi] have hblk := (indepFun_prodDesign_blocks D hST).comp (φ := F₀) (ψ := G₀) (measurable_of_finite F₀) (measurable_of_finite G₀) exact hblk.congr (Filter.Eventually.of_forall fun w => (hF₀ w).symm) (Filter.Eventually.of_forall fun w => (hG₀ w).symm)
    Causalean.Experimentation.DesignBased.indepFun_prodDesign_of_depends_on_disjoint_blocks · Causalean/Experimentation/DesignBased/ProductMeasure.lean:128
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:40 · 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
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:86 · 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.
    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:49
  • 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.
    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:63
  • Cov_prod_apply_of_ne lemma — Cross-coordinate independence: under the product design, functions of two distinct coordinates have zero covariance.
    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:75
Ratio­Linearization 1 core · 3 supporting Exact design-mean identities for mean-normalized (Horvitz–Thompson / Hájek) ratio statistics and their products, computed directly from FiniteDesign.E. ★ E_lin_expand

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 E_lin_expand reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

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.

Formal statement
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:107 · uses FiniteDesign , E
3 supporting declarations (lemmas, instances)
  • ratio_remainder_capped_bound lemma — Capped ratio-remainder bound. Consider a ratio estimator A / D of a target μ, scaled by √n (here sn with sn² = n), and let G = A − μ·D be the centered numerator. The scaled second-order remainder √n·(A/D − μ) − √n⁻¹·G equals √n⁻¹·G·(n/D − 1), and on the event where the denominator is at least half its target (equivalently n/D ≤ 2) it is bounded by 2·|√n⁻¹·G|·|n⁻¹·D − 1|. This is the per-arm remainder control a design-based ratio / Hájek CLT uses to reduce the studentized estimator to its linear score.
    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:34
  • 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.
    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:74
  • E_centered_ratio_mul lemma — Covariance of two normalized ratios (the ratio linearization kernel). In a finite design, the mean of the product of two mean-normalized ratios (X/E[X] − 1)(Y/E[Y] − 1) equals E[XY] / (E[X]·E[Y]) − 1. This is the exact second cross-moment at the heart of every Horvitz–Thompson / Hájek ratio-variance linearization.
    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:87
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
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))
:
∀ 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:29 · uses FiniteDesign , Pr
Wald­Coverage 1 core · 0 supporting A paper-agnostic asymptotic-coverage transfer for two-sided Wald intervals built from a *deterministic conservative* standard error. ★ conservative_wald_liminf_of_studentized_cdf

Design-based conservative Wald-interval coverage

A paper-agnostic asymptotic-coverage transfer for two-sided Wald intervals built from a deterministic conservative 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).

lemma conservative_wald_liminf_of_studentized_cdf reviewed
Causalean.Experimentation.DesignBased

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

Formal statement
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)
lemma 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:32 · uses FiniteDesign , Pr , stdNormalCdf
Wald­Pipeline 1 core · 0 supporting dependency_wald_coverage chains the design-based dependency CLT (dependency_studentized_cdf) into the conservative Wald-coverage transfer (conservative_wald_liminf_of_studentized_cdf). ★ dependency_wald_coverage

Design-based Wald-interval pipeline

dependency_wald_coverage chains the design-based dependency CLT (dependency_studentized_cdf) into the conservative Wald-coverage transfer (conservative_wald_liminf_of_studentized_cdf). Given unit contributions X n whose standardized sum depSum(X n) eventually equals the scaled centered estimator √(m n)·(est n − θ n), and a deterministic variance vhat n that eventually dominates v n, 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 eventually equals √(m n)·(est n − θ n) for an estimator est n of a target θ n, the normalization m n is eventually positive, and a deterministic conservative variance v̂ n eventually dominates v n, 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 :
ℕ → ℝ
hlink :
∀ᶠ n in atTop, ∀ ω, depSum (X n) ω = sqrt (m n) * (est n ω - θ n)
hmpos :
∀ᶠ n in atTop, 0 < m n
vhat :
ℕ → ℝ
hvar_le :
∀ᶠ n in atTop, v n ≤ vhat n
α 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 : ℕ → ℝ) (hlink : ∀ᶠ n in atTop, ∀ ω, depSum (X n) ω = sqrt (m n) * (est n ω - θ n)) (hmpos : ∀ᶠ n in atTop, 0 < m n) (vhat : ℕ → ℝ) (hvar_le : ∀ᶠ n in atTop, v n ≤ vhat n) (α 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 hclt : ∀ s : ℝ, Tendsto (fun n => (D n).Pr (fun ω => sqrt (m n) * (est n ω - θ n) / sqrt (v n) ≤ s)) atTop (𝓝 (stdNormalCdf s)) := by intro s have h := dependency_studentized_cdf D X Dep Dmax hdeg M hM hbound hmean v hv c hc hvc hcard s refine h.congr' ?_ filter_upwards [hlink] with n hlinkn refine (D n).Pr_congr _ _ (fun ω => ?_) rw [hlinkn ω] have hvarpos : ∀ᶠ n in atTop, 0 < v n := by filter_upwards [hvc, (tendsto_atTop.1 hcard 1)] with n hvn hcardn have hcardpos : 0 < (card (ι n) : ℝ) := by exact_mod_cast (show 0 < card (ι n) from by omega) exact lt_of_lt_of_le (mul_pos hc hcardpos) hvn exact conservative_wald_liminf_of_studentized_cdf D est θ v vhat m hmpos hvarpos hvar_le α z (hclt z) (hclt (-z)) hz0 hz