Stat.Finite­Design

FiniteDesign — DesignCore, FiniteDesignMeasure, Product, ProductMeasure.

Design­Core 9 core · 37 supporting This file defines FiniteDesign, its finite-sum expectation, variance, covariance, event probability, and pushforward, together with their elementary algebraic identities. ★ FiniteDesign★ E_sum★ E_ind

Finite probability distributions and moments

This file defines FiniteDesign, its finite-sum expectation, variance, covariance, event probability, and pushforward, together with their elementary algebraic identities. Because the sample space is finite, none of these results needs measure-theoretic integrability assumptions.

structure FiniteDesign reviewed
Causalean.Experimentation.DesignBased

A probability distribution on a finite type: a probability mass function p on a finite type Ω whose values are nonnegative and sum to one.

Definition (Lean source)
Ω :
Type*
Probability mass at the outcome `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/Stat/FiniteDesign/DesignCore.lean:32
def E reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

For a finite probability distribution and a real-valued statistic of the realized outcome, the expectation is the probability-weighted sum of that statistic over all assignments.

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

For a finite probability distribution and a real-valued statistic of the realized outcome, the variance is the design expectation of the statistic's squared deviation from its expectation.

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

For a finite probability distribution and two real-valued statistics of the realized outcome, the covariance is the design expectation of the product of their deviations from their respective expectations.

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

For an event with decidable membership, its indicator statistic assigns one to assignments in the event and zero to all other assignments.

Definition (Lean source)
Ω :
Type u_1
shared
A :
Ω → Prop
ind A :
Ω → ℝ
fun z => if A z then 1 else 0
Causalean.Experimentation.DesignBased.FiniteDesign.ind · Causalean/Stat/FiniteDesign/DesignCore.lean:64
def Pr reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

For a finite probability distribution and an event with decidable membership, the design probability of the event is the design expectation of its indicator statistic.

Definition (Lean source)
Ω :
Type u_1
shared
D :
shared
A :
Ω → Prop
Pr D A :
ℝ
D.E (ind A)
Causalean.Experimentation.DesignBased.FiniteDesign.Pr · Causalean/Stat/FiniteDesign/DesignCore.lean:68 · 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 expectations ∑ᵢ∈s E[fᵢ].

Formal statement
Ω :
Type u_1
shared
D :
shared
ι :
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/Stat/FiniteDesign/DesignCore.lean:101 · uses FiniteDesign , E
lemma E_ind reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

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

Formal statement
Ω :
Type u_1
shared
D :
shared
A :
Ω → Prop
D.E (ind A) = D.Pr A
Proof (Lean source)
@[simp, indicator_simps] lemma E_ind (A : Ω → Prop) [DecidablePred A] : D.E (ind A) = D.Pr A := rfl
Causalean.Experimentation.DesignBased.FiniteDesign.E_ind · Causalean/Stat/FiniteDesign/DesignCore.lean:233 · uses FiniteDesign , E , Pr , ind
def map reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

For a finite probability distribution and a transformation from that space to another finite type, the pushforward distribution is the law of the transformed assignment: each transformed assignment receives the total probability of all original assignments mapped to it.

Definition (Lean source)
Ω :
Type u_1
shared
D :
shared
Ω' :
Type*
f :
Ω → Ω'
map D f :
by classical exact { p := fun y => ∑ z, if f z = y then D.p z else 0 p_nonneg := fun y => Finset.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/Stat/FiniteDesign/DesignCore.lean:308 · uses FiniteDesign
37 supporting declarations (lemmas, instances)
  • E_const lemma — The expectation of a constant random variable is that constant.
    Ω :
    Type u_1
    shared
    D :
    shared
    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/Stat/FiniteDesign/DesignCore.lean:75
  • E_add lemma — The expectation of a sum is the sum of expectations.
    Ω :
    Type u_1
    shared
    D :
    shared
    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/Stat/FiniteDesign/DesignCore.lean:79
  • E_sub lemma — The expectation of a difference is the difference of expectations.
    Ω :
    Type u_1
    shared
    D :
    shared
    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/Stat/FiniteDesign/DesignCore.lean:83
  • E_const_mul lemma — Multiplying a random variable by a constant on the left multiplies its expectation by that constant.
    Ω :
    Type u_1
    shared
    D :
    shared
    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/Stat/FiniteDesign/DesignCore.lean:87
  • E_mul_const lemma — Multiplying a random variable by a constant on the right multiplies its expectation by that constant.
    Ω :
    Type u_1
    shared
    D :
    shared
    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/Stat/FiniteDesign/DesignCore.lean:92
  • E_neg lemma — The expectation of a negated random variable is the negated expectation.
    Ω :
    Type u_1
    shared
    D :
    shared
    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/Stat/FiniteDesign/DesignCore.lean:97
  • E_congr lemma — Congruence: pointwise-equal random variables have equal expectation.
    Ω :
    Type u_1
    shared
    D :
    shared
    X Y :
    Ω → ℝ
    h :
    ∀ z, X z = Y z
    D.E X = D.E Y
    Proof (Lean source)
    lemma E_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/Stat/FiniteDesign/DesignCore.lean:110
  • Var_congr lemma — Congruence: pointwise-equal random variables have equal variance.
    Ω :
    Type u_1
    shared
    D :
    shared
    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/Stat/FiniteDesign/DesignCore.lean:114
  • Cov_congr lemma — Congruence: pointwise-equal random variables have equal covariance.
    Ω :
    Type u_1
    shared
    D :
    shared
    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/Stat/FiniteDesign/DesignCore.lean:119
  • Var_eq lemma — Variance identity. For any statistic X, its variance equals the expectation of X² minus the square of its expectation.
    Ω :
    Type u_1
    shared
    D :
    shared
    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/Stat/FiniteDesign/DesignCore.lean:128
  • Cov_eq lemma — Covariance identity. For any two statistics X and Y under the design, their covariance equals the expectation of X·Y minus the product of their expectations.
    Ω :
    Type u_1
    shared
    D :
    shared
    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/Stat/FiniteDesign/DesignCore.lean:136
  • Cov_self lemma — The covariance of a random variable with itself is its variance.
    Ω :
    Type u_1
    shared
    D :
    shared
    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/Stat/FiniteDesign/DesignCore.lean:146
  • Cov_comm lemma — Covariance is symmetric in its two arguments.
    Ω :
    Type u_1
    shared
    D :
    shared
    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/Stat/FiniteDesign/DesignCore.lean:150
  • Cov_const_mul_left lemma — Multiplying the left random variable by a constant multiplies covariance by that constant.
    Ω :
    Type u_1
    shared
    D :
    shared
    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/Stat/FiniteDesign/DesignCore.lean:156
  • Cov_sum_left lemma — Covariance with a finite sum in the left argument is the finite sum of covariances.
    Ω :
    Type u_1
    shared
    D :
    shared
    ι :
    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/Stat/FiniteDesign/DesignCore.lean:164
  • Cov_sum_right lemma — Covariance with a finite sum in the right argument is the finite sum of covariances.
    Ω :
    Type u_1
    shared
    D :
    shared
    ι :
    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/Stat/FiniteDesign/DesignCore.lean:173
  • Cov_const_mul_right lemma — Multiplying the right random variable by a constant multiplies covariance by that constant.
    Ω :
    Type u_1
    shared
    D :
    shared
    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/Stat/FiniteDesign/DesignCore.lean:179
  • Cov_sub_left lemma — Covariance is linear over differences in its left argument.
    Ω :
    Type u_1
    shared
    D :
    shared
    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/Stat/FiniteDesign/DesignCore.lean:184
  • Cov_sub_right lemma — Covariance is linear over differences in its right argument.
    Ω :
    Type u_1
    shared
    D :
    shared
    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/Stat/FiniteDesign/DesignCore.lean:192
  • Var_sub lemma — Variance of a difference: Var(X−Y) = Var X + Var Y − 2 Cov(X,Y).
    Ω :
    Type u_1
    shared
    D :
    shared
    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/Stat/FiniteDesign/DesignCore.lean:197
  • Var_const_mul lemma — Variance scales by the square of a constant: Var(c·X) = c²·Var X.
    Ω :
    Type u_1
    shared
    D :
    shared
    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/Stat/FiniteDesign/DesignCore.lean:203
  • Cov_linear_comb lemma — 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 covariance equals the double sum over s×t of the weighted covariances cᵢeⱼ·Cov(Xᵢ,Yⱼ).
    Ω :
    Type u_1
    shared
    D :
    shared
    ι κ :
    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/Stat/FiniteDesign/DesignCore.lean:208
  • Var_linear_comb lemma — 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 variance equals the double sum of weighted covariances ∑ᵢ∈s∑ⱼ∈s cᵢcⱼ·Cov(Xᵢ,Xⱼ).
    Ω :
    Type u_1
    shared
    D :
    shared
    ι :
    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/Stat/FiniteDesign/DesignCore.lean:222
  • ind_sq lemma — 1_A ^ 2 = 1_A, the idempotence of an indicator.
    Ω :
    Type u_1
    shared
    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/Stat/FiniteDesign/DesignCore.lean:239
  • Var_ind lemma — Variance of an indicator. For any event A, the variance of its indicator equals the design probability of A times one minus that probability.
    Ω :
    Type u_1
    shared
    D :
    shared
    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/Stat/FiniteDesign/DesignCore.lean:244
  • E_nonneg lemma — Expectation of a nonnegative random variable is nonnegative.
    Ω :
    Type u_1
    shared
    D :
    shared
    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 := Finset.sum_nonneg (fun z _ => mul_nonneg (D.p_nonneg z) (h z))
    Causalean.Experimentation.DesignBased.FiniteDesign.E_nonneg · Causalean/Stat/FiniteDesign/DesignCore.lean:252
  • E_le_one lemma — Expectation of a random variable bounded above by one is at most one.
    Ω :
    Type u_1
    shared
    D :
    shared
    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/Stat/FiniteDesign/DesignCore.lean:256
  • ind_nonneg lemma — An event indicator is always nonnegative.
    Ω :
    Type u_1
    shared
    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/Stat/FiniteDesign/DesignCore.lean:264
  • ind_le_one lemma — An event indicator is always at most one.
    Ω :
    Type u_1
    shared
    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/Stat/FiniteDesign/DesignCore.lean:269
  • Pr_nonneg lemma — A probability lies in [0,1]: nonnegativity.
    Ω :
    Type u_1
    shared
    D :
    shared
    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/Stat/FiniteDesign/DesignCore.lean:273
  • Pr_le_one lemma — A probability lies in [0,1]: at most one.
    Ω :
    Type u_1
    shared
    D :
    shared
    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/Stat/FiniteDesign/DesignCore.lean:277
  • Pr_congr lemma — Probability respects pointwise-equivalent events.
    Ω :
    Type u_1
    shared
    D :
    shared
    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/Stat/FiniteDesign/DesignCore.lean:281
  • Pr_mono lemma — Monotonicity of probability: a smaller event has smaller probability.
    Ω :
    Type u_1
    shared
    D :
    shared
    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/Stat/FiniteDesign/DesignCore.lean:286
  • Pr_split lemma — Finite additivity: splitting an event by a second event.
    Ω :
    Type u_1
    shared
    D :
    shared
    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/Stat/FiniteDesign/DesignCore.lean:297
  • map_p lemma — The pushforward weight of y is the fiber sum ∑_{z} 1[f z = y] · D.p z.
    Ω :
    Type u_1
    shared
    D :
    shared
    Ω' :
    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/Stat/FiniteDesign/DesignCore.lean:326
  • 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 u_1
    shared
    D :
    shared
    Ω' :
    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/Stat/FiniteDesign/DesignCore.lean:332
  • 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 u_1
    shared
    D :
    shared
    Ω' :
    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/Stat/FiniteDesign/DesignCore.lean:346
Finite­Design­Measure 4 core · 2 supporting Finite probability distributions 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 probability distributions 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

For a finite probability distribution on a finite type equipped with a σ-algebra, the induced probability measure assigns to each assignment a point mass equal to that assignment's design probability, and sums these point masses over all assignments.

Definition (Lean source)
Ω :
Type u_1
shared
D :
shared
toMeasure D :
∑ z, ofReal (D.p z) • Measure.dirac z
Causalean.Experimentation.DesignBased.FiniteDesign.toMeasure · Causalean/Stat/FiniteDesign/FiniteDesignMeasure.lean:38 · uses FiniteDesign
theorem integral_toMeasure reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

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

Formal statement
Ω :
Type u_1
shared
D :
shared
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/Stat/FiniteDesign/FiniteDesignMeasure.lean:63 · 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
Ω :
Type u_1
shared
D :
shared
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/Stat/FiniteDesign/FiniteDesignMeasure.lean:78 · uses FiniteDesign , Pr , toMeasure
theorem variance_toMeasure reviewed
Causalean.Experimentation.DesignBased.FiniteDesign

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

Formal statement
Ω :
Type u_1
shared
D :
shared
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/Stat/FiniteDesign/FiniteDesignMeasure.lean:88 · uses FiniteDesign , Var , toMeasure
2 supporting declarations (lemmas, instances)
  • toMeasure_apply lemma — The measure induced by a finite probability distribution assigns each set the sum, over assignments, of each assignment's probability times the point mass of that assignment on the set.
    Ω :
    Type u_1
    shared
    D :
    shared
    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/Stat/FiniteDesign/FiniteDesignMeasure.lean:44
  • instIsProbabilityMeasureToMeasure instance — For every finite probability distribution on a finite type equipped with a σ-algebra, the measure induced by that design is a probability measure: its total mass is one.
    Ω :
    Type u_1
    shared
    D :
    shared
    instIsProbabilityMeasureToMeasure D :
    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/Stat/FiniteDesign/FiniteDesignMeasure.lean:52
Product 3 core · 1 supporting This file constructs prodDesign, the finite product of a family of independent randomization designs. ★ prodDesign★ prodDesign_p★ E_prod_apply

Products of finite probability distributions

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

For a finite, equality-comparable index set whose coordinate finite types are finite, a family of coordinate-specific finite probability distributions defines the product design, which randomizes all coordinates independently: the probability of an assignment vector is the product of the probabilities assigned to its coordinate values by their respective designs.

Definition (Lean source)
ι :
Type u_1
ι → Type u_2
shared
D :
∀ i, FiniteDesign (α i)
prodDesign D :
FiniteDesign (∀ i, α i)
clause 1
p w := ∏ i, (D i).p (w i)
clause 2
p_nonneg w := Finset.prod_nonneg (fun i _ => (D i).p_nonneg (w i))
clause 3
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/Stat/FiniteDesign/Product.lean:33 · 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
ι :
Type u_1
ι → Type u_2
shared
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/Stat/FiniteDesign/Product.lean:45 · uses FiniteDesign , 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
ι :
Type u_1
ι → Type u_2
shared
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/Stat/FiniteDesign/Product.lean:64 · uses FiniteDesign , E , prodDesign
1 supporting declaration (lemmas, instances)
  • E_prod_prod lemma — 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).
    ι :
    Type u_1
    ι → Type u_2
    shared
    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/Stat/FiniteDesign/Product.lean:53
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
Ω :
Type u_1
shared
D :
shared
X :
Ω → ℝ
ε :
ℝ
hε :
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 (Finset.mem_insert_self x t)) (ih a b (fun i hi => h i (Finset.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/Stat/FiniteDesign/Chebyshev.lean:33 · 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.
    Ω :
    Type u_1
    shared
    D :
    shared
    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/Stat/FiniteDesign/Chebyshev.lean:73
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

Measure-theoretic bridges for finite-design 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 standard side conditions needed to reuse measure-theoretic results with finite designs.

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
Ω :
Type u_1
shared
D :
shared
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/Stat/FiniteDesign/MeasureBridge.lean:83 · uses FiniteDesign , Cov , Var
7 supporting declarations (lemmas, instances)
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
ι :
Type u_1
ι → Type u_2
shared
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/Stat/FiniteDesign/ProductMeasure.lean:57 · 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
ι :
Type u_1
ι → Type u_2
shared
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/Stat/FiniteDesign/ProductMeasure.lean:89 · 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/Stat/FiniteDesign/ProductMeasure.lean:40
  • 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.)
    ι :
    Type u_1
    ι → Type u_2
    shared
    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/Stat/FiniteDesign/ProductMeasure.lean:74
  • 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.
    ι :
    Type u_1
    ι → Type u_2
    shared
    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/Stat/FiniteDesign/ProductMeasure.lean:83
  • 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.
    ι :
    Type u_1
    ι → Type u_2
    shared
    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/Stat/FiniteDesign/ProductMeasure.lean:101
  • 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.
    ι :
    Type u_1
    ι → Type u_2
    shared
    β γ :
    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'
    IndepFun F G (prodDesign D).toMeasure
    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/Stat/FiniteDesign/ProductMeasure.lean:116