Stat.Sample.Occupancy­Weighted­Mean.Observed­Risk

This module packages finite-cell matched-arm occupancy controls, real-mark residual algebra, and the observed-law collision-estimator mean-square bound.

Basic 11 core · 0 supporting The statistics and assumptions in this module depend only on one observed probability law and the measurable cell, arm, and real-outcome maps.

Observed finite-cell collision statistics

The statistics and assumptions in this module depend only on one observed probability law and the measurable cell, arm, and real-outcome maps. All sample ratios are guarded at zero. No potential-outcome variables occur here.

def cellMass reviewed
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk

The observed mass of a cell is the probability that the measured cell label equals it.

Definition (Lean source)
Ω :
Type u_1
shared
κ :
Type u_2
shared
μ :
X :
Ω → κ
k :
κ
cellMass μ X k :
ℝ
(μ (groupEvent X k)).toReal
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.cellMass · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/Basic.lean:22
def armCellMass reviewed
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk

The observed mass of an arm-cell pair is its joint probability under the observed law.

Definition (Lean source)
Ω :
Type u_1
shared
κ :
Type u_2
shared
μ :
X :
Ω → κ
A :
Ω → Bool
a :
k :
κ
armCellMass μ X A a k :
ℝ
(μ (armGroupEvent X A a k)).toReal
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.armCellMass · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/Basic.lean:26
abbrev armCount reviewed
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk

The guarded arm-cell count is the number of sample observations in that arm and cell.

Definition (Lean source)
Ω :
Type u_1
shared
κ :
Type u_2
shared
n :
ℕ
X :
Ω → κ
A :
Ω → Bool
z :
Fin n → Ω
a :
k :
κ
armCount X A z a k :
ℕ
groupArmCount X A z a k
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.armCount · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/Basic.lean:31
def armSum reviewed
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk

The guarded arm-cell sum adds real outcomes in the requested arm and cell.

Definition (Lean source)
Ω :
Type u_1
shared
κ :
Type u_2
shared
n :
ℕ
X :
Ω → κ
A :
Ω → Bool
Y :
Ω → ℝ
z :
Fin n → Ω
a :
k :
κ
armSum X A Y z a k :
ℝ
armResidualSum X A Y (fun _ _ => 0) z a k
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.armSum · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/Basic.lean:36
def armMean reviewed
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk

The guarded arm-cell mean is the arm-cell outcome sum divided by its positive count, and is zero when the count vanishes.

Definition (Lean source)
Ω :
Type u_1
shared
κ :
Type u_2
shared
n :
ℕ
X :
Ω → κ
A :
Ω → Bool
Y :
Ω → ℝ
z :
Fin n → Ω
a :
k :
κ
armMean X A Y z a k :
ℝ
armResidualMean X A Y (fun _ _ => 0) z a k
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.armMean · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/Basic.lean:41
abbrev matchedCell reviewed
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk

A cell is matched when both observed treatment arms appear in it.

Definition (Lean source)
Ω :
Type u_1
shared
κ :
Type u_2
shared
n :
ℕ
X :
Ω → κ
A :
Ω → Bool
z :
Fin n → Ω
k :
κ
matchedCell X A z k :
Prop
usableGroup X A z k
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.matchedCell · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/Basic.lean:47
abbrev usableTotal reviewed
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk

The usable total counts all observations in matched cells, and is zero if none match.

Definition (Lean source)
Ω :
Type u_1
shared
κ :
Type u_2
shared
n :
ℕ
X :
Ω → κ
A :
Ω → Bool
z :
Fin n → Ω
usableTotal X A z :
ℕ
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.usableTotal · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/Basic.lean:52
def collisionEstimator reviewed
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk

The cell-count-weighted collision estimator averages matched-cell arm contrasts, with value zero when no cell is matched.

Definition (Lean source)
Ω :
Type u_1
shared
κ :
Type u_2
shared
n :
ℕ
X :
Ω → κ
A :
Ω → Bool
Y :
Ω → ℝ
z :
Fin n → Ω
collisionEstimator X A Y z :
ℝ
by classical exact if 0 < usableTotal X A z then (∑ k : κ, if matchedCell X A z k then (groupCount X A z k : ℝ) * (armMean X A Y z true k - armMean X A Y z false k) else 0) / usableTotal X A z else 0
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.collisionEstimator · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/Basic.lean:57
def populationContrast reviewed
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk

The population contrast is the sum over cells of the cell's observed mass times the difference between the supplied treated-arm centre and control-arm centre of that cell.

Definition (Lean source)
Ω :
Type u_1
shared
κ :
Type u_2
shared
μ :
X :
Ω → κ
center :
Bool → κ → ℝ
populationContrast μ X center :
ℝ
∑ k : κ, cellMass μ X k * (center true k - center false k)
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.populationContrast · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/Basic.lean:69
def designCenter reviewed
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk

The design center replaces empirical arm means by their observed arm-cell centers, retaining the same matched-cell weights and zero-denominator guard.

Definition (Lean source)
Ω :
Type u_1
shared
κ :
Type u_2
shared
n :
ℕ
X :
Ω → κ
A :
Ω → Bool
center :
Bool → κ → ℝ
z :
Fin n → Ω
designCenter X A center z :
ℝ
by classical exact if 0 < usableTotal X A z then (∑ k : κ, if matchedCell X A z k then (groupCount X A z k : ℝ) * (center true k - center false k) else 0) / usableTotal X A z else 0
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.designCenter · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/Basic.lean:75
structure ObservedAssumptions reviewed
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk

The observed-law assumptions on a probability law with a cell label, a Boolean arm label, a real outcome, supplied arm-and-cell centres, an overlap margin ε, an envelope M and a heterogeneity level ρ require all of the following. The margin ε is strictly between zero and one half, and the cell label, arm label and outcome are measurable. Overlap: in every cell of positive mass, each arm-cell pair has mass at least ε times the cell mass. Every centre is at most M in absolute value. On each arm-cell event the residual (outcome minus that arm-cell's centre) is square-integrable, integrates to zero, and has integral of its square at most the arm-cell mass times M². Approximate homogeneity: in every cell of positive mass, the treated-minus-control centre contrast differs from the population contrast by at most M·ρ in absolute value. Nothing is required of cells of zero mass beyond the centre bound and the (then trivial) residual conditions.

Definition (Lean source)
X :
Ω → κ
A :
Ω → Bool
Y :
Ω → ℝ
center :
Bool → κ → ℝ
epsilon M rho :
ℝ
epsilon_pos :
0 < epsilon
epsilon_lt_half :
epsilon < 1 / 2
X_measurable :
A_measurable :
Y_measurable :
overlap :
∀ a k
if
0 < cellMass μ X k
then
epsilon * cellMass μ X k ≤ armCellMass μ X A a k
center_envelope :
∀ a k, |center a k| ≤ M
residual_L2 :
∀ a k, MemLp (supportedArmGroupResidual X A Y center a k) 2 μ
residual_centered :
∀ a k, ∫ ω in armGroupEvent X A a k, armGroupResidual Y center a k ω ∂μ = 0
residual_second_moment :
∀ a k,
∫ ω in armGroupEvent X A a k, (armGroupResidual Y center a k ω) ^ 2 ∂μ
≤ armCellMass μ X A a k * M ^ 2
homogeneity :
∀ k
if
0 < cellMass μ X k
then
|(center true k - center false k) - populationContrast μ X center| ≤ M * rho
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.ObservedAssumptions · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/Basic.lean:86
Poisson­Cell 3 core · 1 supporting These observed-design lemmas isolate the light- and heavy-cell estimates for two independent Poisson arm counts. ★ poissonCellLaplace_heavy_rate

One-cell Poisson occupancy estimates

These observed-design lemmas isolate the light- and heavy-cell estimates for two independent Poisson arm counts. They are the local inputs to the finite partition Laplace argument; neither potential outcomes nor a causal model appear in their statements.

def usablePoissonPairCount reviewed
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk

The usable count of an independent Poisson arm-count pair is their sum when both counts are positive, and zero otherwise.

Definition (Lean source)
r :
ℕ × ℕ
usablePoissonPairCount r :
ℕ
if 0 < r.1 ∧ 0 < r.2 then r.1 + r.2 else 0
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.usablePoissonPairCount · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/PoissonCell.lean:20
def poissonCellLaplace reviewed
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk

The one-cell Laplace factor averages the exponential of minus the usable count under independent Poisson arm counts.

Definition (Lean source)
u v :
ℝ≥0
poissonCellLaplace u v :
ℝ
∫ r : ℕ × ℕ, exp (-(usablePoissonPairCount r : ℝ)) ∂(poissonMeasure u).prod (poissonMeasure v)
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.poissonCellLaplace · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/PoissonCell.lean:25
theorem poissonCellLaplace_heavy_rate reviewed
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk

For an overlap margin ε strictly between zero and one half, there is a positive constant c, depending only on ε, such that for any two nonnegative Poisson arm intensities with total x, if each intensity is at least ε·x and the total x is at least one, then the one-cell Laplace factor (the expectation of exp(−usable count) under independent Poisson arm counts with those intensities) is at most exp(−c·x).

Formal statement
epsilon :
ℝ
hepsilon :
0 < epsilon
hepsilon_half :
epsilon < 1 / 2
∃ c : ℝ,
0 < c
conclusion 1
u v :
ℝ≥0
x :
ℝ
(u : ℝ) + (v : ℝ) = x
epsilon * x ≤ (u : ℝ)
epsilon * x ≤ (v : ℝ)
1 ≤ x
poissonCellLaplace u v ≤ exp (-(c * x))
Proof (Lean source)
theorem poissonCellLaplace_heavy_rate (epsilon : ℝ) (hepsilon : 0 < epsilon) (hepsilon_half : epsilon < 1 / 2) : ∃ c : ℝ, 0 < c ∧ ∀ (u v : ℝ≥0) (x : ℝ), (u : ℝ) + (v : ℝ) = x → epsilon * x ≤ (u : ℝ) → epsilon * x ≤ (v : ℝ) → 1 ≤ x → poissonCellLaplace u v ≤ exp (-(c * x)) := by -- For bounded x, the (1,1) atom gives a uniform strict gap below one. -- For sufficiently large x, split by whether both arms occur: the matched -- contribution is bounded by exp (-(1-exp (-1))*x), while either missing -- arm costs exp (-u) or exp (-v). Absorb the factor three beyond a fixed -- epsilon-dependent threshold and choose the smaller exponent constant. let T : ℝ := 4 / epsilon let a : ℝ := (1 - exp (-2)) * exp (-T) * epsilon ^ 2 let c : ℝ := min a (epsilon / 2) have hgap : 0 < 1 - exp (-2 : ℝ) := by have : exp (-2 : ℝ) < 1 := by rw [← Real.exp_zero] exact Real.exp_lt_exp.mpr (by norm_num) linarith have ha : 0 < a := by dsimp [a]; positivity have hc : 0 < c := lt_min ha (by positivity) refine ⟨c, hc, ?_⟩ intro u v x hx hu hv hx₁ have hx₀ : 0 ≤ x := le_trans (by norm_num) hx₁ have hprod : epsilon ^ 2 * x ^ 2 ≤ (u : ℝ) * (v : ℝ) := by have h := mul_le_mul hu hv (mul_nonneg hepsilon.le hx₀) (by positivity) nlinarith by_cases hbounded : x ≤ T · let μ := (poissonMeasure u).prod (poissonMeasure v) let ind : ℕ × ℕ → ℝ := fun r ↦ if r = (1, 1) then 1 else 0 have hpoint (r : ℕ × ℕ) : exp (-(usablePoissonPairCount r : ℝ)) ≤ 1 - (1 - exp (-2)) * ind r := by by_cases hr : r = (1, 1) · subst r norm_num [usablePoissonPairCount, ind] · simp only [ind, if_neg hr, mul_zero, sub_zero] rw [Real.exp_le_one_iff] exact neg_nonpos.mpr (Nat.cast_nonneg _) have hfun : Integrable (fun r : ℕ × ℕ ↦ exp (-(usablePoissonPairCount r : ℝ))) μ := by refine (integrable_const (1 : ℝ)).mono (by fun_prop) ?_ filter_upwards with r rw [Real.norm_eq_abs, abs_of_pos (Real.exp_pos _), norm_one] rw [Real.exp_le_one_iff] exact neg_nonpos.mpr (Nat.cast_nonneg _) have hind : Integrable ind μ := by refine (integrable_const (1 : ℝ)).mono (by fun_prop) ?_ filter_upwards with r dsimp [ind] split <;> simp have hmono : poissonCellLaplace u v ≤ 1 - (1 - exp (-2)) * (∫ r, ind r ∂μ) := by have henv : Integrable (fun r : ℕ × ℕ ↦ 1 - (1 - exp (-2)) * ind r) μ := (integrable_const (1 : ℝ)).sub (hind.const_mul _) have hle := integral_mono_ae hfun henv (Filter.Eventually.of_forall hpoint) unfold poissonCellLaplace calc _ ≤ ∫ r, (1 - (1 - exp (-2)) * ind r) ∂μ := hle _ = 1 - (1 - exp (-2)) * (∫ r, ind r ∂μ) := by rw [integral_sub (integrable_const (1 : ℝ)) (hind.const_mul _)] rw [integral_const_mul] simp have hOne (r : ℝ≥0) : (∫ n : ℕ, (if n = 1 then (1 : ℝ) else 0) ∂poissonMeasure r) = exp (-(r : ℝ)) * r := by rw [integral_poissonMeasure] simp only [smul_eq_mul] rw [tsum_eq_single 1] · norm_num · intro n hn simp [hn] have hatom : (∫ r, ind r ∂μ) = exp (-x) * (u : ℝ) * (v : ℝ) := by calc (∫ r, ind r ∂μ) = (∫ r : ℕ × ℕ, (if r.1 = 1 then (1 : ℝ) else 0) * (if r.2 = 1 then (1 : ℝ) else 0) ∂μ) := by congr with r rcases r with ⟨m, n⟩ simp only [ind, Prod.mk.injEq] by_cases hm : m = 1 <;> by_cases hn : n = 1 <;> simp [hm, hn] _ = (∫ m : ℕ, (if m = 1 then (1 : ℝ) else 0) ∂poissonMeasure u) * (∫ n : ℕ, (if n = 1 then (1 : ℝ) else 0) ∂poissonMeasure v) := by simpa only [μ] using (integral_prod_mul (μ := poissonMeasure u) (ν := poissonMeasure v) (L := ℝ) (fun m : ℕ ↦ if m = 1 then (1 : ℝ) else 0) (fun n : ℕ ↦ if n = 1 then (1 : ℝ) else 0)) _ = _ := by rw [hOne, hOne] have he : exp (-(u : ℝ)) * exp (-(v : ℝ)) = exp (-x) := by rw [← Real.exp_add] congr 1 linarith calc exp (-(u : ℝ)) * (u : ℝ) * (exp (-(v : ℝ)) * (v : ℝ)) = (exp (-(u : ℝ)) * exp (-(v : ℝ))) * (u : ℝ) * (v : ℝ) := by ring _ = _ := by rw [he] have hexp : exp (-T) ≤ exp (-x) := Real.exp_le_exp.mpr (neg_le_neg hbounded) have hcore : a * x ≤ (1 - exp (-2)) * (exp (-x) * (u : ℝ) * (v : ℝ)) := by have hx2 : x ≤ x ^ 2 := by nlinarith have h := mul_le_mul hexp hprod (by positivity) (Real.exp_pos _).le have hh := mul_le_mul_of_nonneg_left h hgap.le have hxa : a * x ≤ a * x ^ 2 := mul_le_mul_of_nonneg_left hx2 ha.le dsimp [a] at hxa ⊢ nlinarith have hca : c ≤ a := min_le_left _ _ calc poissonCellLaplace u v ≤ 1 - (1 - exp (-2)) * (exp (-x) * (u : ℝ) * (v : ℝ)) := by simpa only [hatom] using hmono _ ≤ 1 - c * x := by nlinarith [mul_le_mul_of_nonneg_right hca hx₀] _ ≤ exp (-(c * x)) := Real.one_sub_le_exp_neg _ · have hlarge : T < x := lt_of_not_ge hbounded have hpgf (r : ℝ≥0) : (∫ n : ℕ, exp (-(n : ℝ)) ∂poissonMeasure r) = exp (-(1 - exp (-1)) * (r : ℝ)) := by rw [integral_poissonMeasure] simp only [smul_eq_mul] calc ∑' n : ℕ, exp (-(r : ℝ)) * (r : ℝ) ^ n / factorial n * exp (-(n : ℝ)) = exp (-(r : ℝ)) * ∑' n : ℕ, (((r : ℝ) * exp (-1)) ^ n / factorial n) := by rw [← tsum_mul_left] apply tsum_congr intro n rw [show -(n : ℝ) = (n : ℝ) * (-1) by ring, Real.exp_nat_mul] ring _ = exp (-(r : ℝ)) * exp ((r : ℝ) * exp (-1)) := by have hs := (NormedSpace.expSeries_div_hasSum_exp ((r : ℝ) * exp (-1))).tsum_eq rw [← Real.exp_eq_exp_ℝ] at hs rw [hs] _ = _ := by rw [← Real.exp_add]; congr 1; ring have hzero (r : ℝ≥0) : (∫ n : ℕ, (if n = 0 then (1 : ℝ) else 0) ∂poissonMeasure r) = exp (-(r : ℝ)) := by rw [integral_poissonMeasure] simp only [smul_eq_mul] rw [tsum_eq_single 0] · norm_num · intro n hn simp [hn] let μ := (poissonMeasure u).prod (poissonMeasure v) let F : ℕ × ℕ → ℝ := fun r ↦ exp (-((r.1 : ℝ) + r.2)) let Z₀ : ℕ × ℕ → ℝ := fun r ↦ if r.1 = 0 then 1 else 0 let Z₁ : ℕ × ℕ → ℝ := fun r ↦ if r.2 = 0 then 1 else 0 have hpoint (r : ℕ × ℕ) : exp (-(usablePoissonPairCount r : ℝ)) ≤ F r + Z₀ r + Z₁ r := by rcases r with ⟨m, n⟩ by_cases hm : m = 0 · subst m simp only [usablePoissonPairCount, lt_self_iff_false, false_and, ↓reduceIte, Nat.cast_zero, neg_zero, Real.exp_zero, F, Z₀, Z₁] have he : 0 ≤ exp (-((0 : ℝ) + n)) := (Real.exp_pos _).le split <;> linarith by_cases hn : n = 0 · subst n simp only [usablePoissonPairCount, lt_self_iff_false, and_false, ↓reduceIte, Nat.cast_zero, add_zero, neg_zero, Real.exp_zero, F, Z₀, Z₁, hm] have he : 0 ≤ exp (-(m : ℝ)) := (Real.exp_pos _).le linarith have hmpos : 0 < m := Nat.pos_of_ne_zero hm have hnpos : 0 < n := Nat.pos_of_ne_zero hn simp [usablePoissonPairCount, F, Z₀, Z₁, hm, hn, hmpos, hnpos] have hfun : Integrable (fun r : ℕ × ℕ ↦ exp (-(usablePoissonPairCount r : ℝ))) μ := by refine (integrable_const (1 : ℝ)).mono (by fun_prop) ?_ filter_upwards with r rw [Real.norm_eq_abs, abs_of_pos (Real.exp_pos _), norm_one] rw [Real.exp_le_one_iff] exact neg_nonpos.mpr (Nat.cast_nonneg _) have hF : Integrable F μ := by refine (integrable_const (1 : ℝ)).mono (by fun_prop) ?_ filter_upwards with r rw [Real.norm_eq_abs, abs_of_pos (Real.exp_pos _), norm_one] rw [Real.exp_le_one_iff] exact neg_nonpos.mpr (add_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _)) have hZ₀ : Integrable Z₀ μ := by refine (integrable_const (1 : ℝ)).mono (by fun_prop) ?_ filter_upwards with r dsimp [Z₀] split <;> simp have hZ₁ : Integrable Z₁ μ := by refine (integrable_const (1 : ℝ)).mono (by fun_prop) ?_ filter_upwards with r dsimp [Z₁] split <;> simp have hFint : (∫ r, F r ∂μ) = exp (-(1 - exp (-1)) * x) := by calc (∫ r, F r ∂μ) = (∫ r : ℕ × ℕ, exp (-(r.1 : ℝ)) * exp (-(r.2 : ℝ)) ∂μ) := by congr with r dsimp [F] rw [← Real.exp_add] congr 1 ring _ = (∫ m : ℕ, exp (-(m : ℝ)) ∂poissonMeasure u) * (∫ n : ℕ, exp (-(n : ℝ)) ∂poissonMeasure v) := by simpa only [μ] using (integral_prod_mul (μ := poissonMeasure u) (ν := poissonMeasure v) (L := ℝ) (fun m : ℕ ↦ exp (-(m : ℝ))) (fun n : ℕ ↦ exp (-(n : ℝ)))) _ = _ := by rw [hpgf, hpgf, ← Real.exp_add] congr 1 rw [← hx] ring have hZ₀int : (∫ r, Z₀ r ∂μ) = exp (-(u : ℝ)) := by calc _ = (∫ m : ℕ, (if m = 0 then (1 : ℝ) else 0) ∂poissonMeasure u) * (∫ _n : ℕ, (1 : ℝ) ∂poissonMeasure v) := by simpa only [μ, Z₀, mul_one] using (integral_prod_mul (μ := poissonMeasure u) (ν := poissonMeasure v) (L := ℝ) (fun m : ℕ ↦ if m = 0 then (1 : ℝ) else 0) (fun _n : ℕ ↦ (1 : ℝ))) _ = _ := by rw [hzero]; simp have hZ₁int : (∫ r, Z₁ r ∂μ) = exp (-(v : ℝ)) := by calc _ = (∫ _m : ℕ, (1 : ℝ) ∂poissonMeasure u) * (∫ n : ℕ, (if n = 0 then (1 : ℝ) else 0) ∂poissonMeasure v) := by simpa only [μ, Z₁, one_mul] using (integral_prod_mul (μ := poissonMeasure u) (ν := poissonMeasure v) (L := ℝ) (fun _m : ℕ ↦ (1 : ℝ)) (fun n : ℕ ↦ if n = 0 then (1 : ℝ) else 0)) _ = _ := by rw [hzero]; simp have henv : Integrable (fun r ↦ F r + Z₀ r + Z₁ r) μ := (hF.add hZ₀).add hZ₁ have hbound : poissonCellLaplace u v ≤ exp (-(1 - exp (-1)) * x) + exp (-(u : ℝ)) + exp (-(v : ℝ)) := by have hle := integral_mono_ae hfun henv (Filter.Eventually.of_forall hpoint) -- … truncated; follow the source link for the rest …
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.poissonCellLaplace_heavy_rate · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/PoissonCell.lean:149 · uses poissonCellLaplace
1 supporting declaration (lemmas, instances)
  • poissonCellLaplace_light_rate theorem — If a cell's total Poisson intensity is at most one and each arm receives at least an epsilon fraction, its usable-count Laplace factor loses at least a positive multiple of the squared total intensity. The coefficient depends only on epsilon, including the zero-intensity case.
    epsilon :
    ℝ
    hepsilon :
    0 < epsilon
    ∃ c : ℝ,
    0 < c
    conclusion 1
    u v :
    ℝ≥0
    x :
    ℝ
    (u : ℝ) + (v : ℝ) = x
    epsilon * x ≤ (u : ℝ)
    epsilon * x ≤ (v : ℝ)
    x ≤ 1
    poissonCellLaplace u v ≤ exp (-(c * x ^ 2))
    Proof (Lean source)
    theorem poissonCellLaplace_light_rate (epsilon : ℝ) (hepsilon : 0 < epsilon) : ∃ c : ℝ, 0 < c ∧ ∀ (u v : ℝ≥0) (x : ℝ), (u : ℝ) + (v : ℝ) = x → epsilon * x ≤ (u : ℝ) → epsilon * x ≤ (v : ℝ) → x ≤ 1 → poissonCellLaplace u v ≤ exp (-(c * x ^ 2)) := by -- The (1,1) atom has mass exp (-x) * u * v. On x ≤ 1 this is -- uniformly at least exp (-1) * epsilon² * x². Bound 1-y by exp (-y). let c : ℝ := (1 - exp (-2)) * exp (-1) * epsilon ^ 2 have hc₀ : 0 ≤ 1 - exp (-2 : ℝ) := by have : exp (-2 : ℝ) ≤ 1 := by rw [Real.exp_le_one_iff]; norm_num linarith have hc : 0 < c := by have : exp (-2 : ℝ) < 1 := by rw [← Real.exp_zero] exact Real.exp_lt_exp.mpr (by norm_num) dsimp [c] positivity refine ⟨c, hc, ?_⟩ intro u v x hx hu hv hx₁ let μ := (poissonMeasure u).prod (poissonMeasure v) let ind : ℕ × ℕ → ℝ := fun r ↦ if r = (1, 1) then 1 else 0 have hpoint (r : ℕ × ℕ) : exp (-(usablePoissonPairCount r : ℝ)) ≤ 1 - (1 - exp (-2)) * ind r := by by_cases hr : r = (1, 1) · subst r norm_num [usablePoissonPairCount, ind] · simp only [ind, if_neg hr, mul_zero, sub_zero] rw [Real.exp_le_one_iff] exact neg_nonpos.mpr (Nat.cast_nonneg _) have hfun : Integrable (fun r : ℕ × ℕ ↦ exp (-(usablePoissonPairCount r : ℝ))) μ := by refine (integrable_const (1 : ℝ)).mono (by fun_prop) ?_ filter_upwards with r rw [Real.norm_eq_abs, abs_of_pos (Real.exp_pos _), norm_one] rw [Real.exp_le_one_iff] exact neg_nonpos.mpr (Nat.cast_nonneg _) have hind : Integrable ind μ := by refine (integrable_const (1 : ℝ)).mono (by fun_prop) ?_ filter_upwards with r dsimp [ind] split <;> simp have hmono : poissonCellLaplace u v ≤ 1 - (1 - exp (-2)) * (∫ r, ind r ∂μ) := by have henv : Integrable (fun r : ℕ × ℕ ↦ 1 - (1 - exp (-2)) * ind r) μ := (integrable_const (1 : ℝ)).sub (hind.const_mul _) have hle := integral_mono_ae hfun henv (Filter.Eventually.of_forall hpoint) unfold poissonCellLaplace calc _ ≤ ∫ r, (1 - (1 - exp (-2)) * ind r) ∂μ := hle _ = 1 - (1 - exp (-2)) * (∫ r, ind r ∂μ) := by rw [integral_sub (integrable_const (1 : ℝ)) (hind.const_mul _)] rw [integral_const_mul] simp have hOne (a : ℝ≥0) : (∫ n : ℕ, (if n = 1 then (1 : ℝ) else 0) ∂poissonMeasure a) = exp (-(a : ℝ)) * a := by rw [integral_poissonMeasure] simp only [smul_eq_mul] rw [tsum_eq_single 1] · norm_num · intro n hn simp [hn] have hatom : (∫ r, ind r ∂μ) = exp (-x) * (u : ℝ) * (v : ℝ) := by calc (∫ r, ind r ∂μ) = (∫ r : ℕ × ℕ, (if r.1 = 1 then (1 : ℝ) else 0) * (if r.2 = 1 then (1 : ℝ) else 0) ∂μ) := by congr with r rcases r with ⟨m, n⟩ simp only [ind, Prod.mk.injEq] by_cases hm : m = 1 <;> by_cases hn : n = 1 <;> simp [hm, hn] _ = (∫ m : ℕ, (if m = 1 then (1 : ℝ) else 0) ∂poissonMeasure u) * (∫ n : ℕ, (if n = 1 then (1 : ℝ) else 0) ∂poissonMeasure v) := by simpa only [μ] using (integral_prod_mul (μ := poissonMeasure u) (ν := poissonMeasure v) (L := ℝ) (fun m : ℕ ↦ if m = 1 then (1 : ℝ) else 0) (fun n : ℕ ↦ if n = 1 then (1 : ℝ) else 0)) _ = _ := by rw [hOne, hOne] have he : exp (-(u : ℝ)) * exp (-(v : ℝ)) = exp (-x) := by rw [← Real.exp_add] congr 1 linarith calc exp (-(u : ℝ)) * (u : ℝ) * (exp (-(v : ℝ)) * (v : ℝ)) = (exp (-(u : ℝ)) * exp (-(v : ℝ))) * (u : ℝ) * (v : ℝ) := by ring _ = _ := by rw [he] have hx₀ : 0 ≤ x := by rw [← hx]; positivity have hprod : epsilon ^ 2 * x ^ 2 ≤ (u : ℝ) * (v : ℝ) := by have h := mul_le_mul hu hv (mul_nonneg hepsilon.le hx₀) (by positivity) nlinarith have hexp : exp (-1) ≤ exp (-x) := Real.exp_le_exp.mpr (by linarith) have hcore : c * x ^ 2 ≤ (1 - exp (-2)) * (exp (-x) * (u : ℝ) * (v : ℝ)) := by dsimp [c] have h := mul_le_mul hexp hprod (by positivity) (Real.exp_pos _).le nlinarith [mul_le_mul_of_nonneg_left h hc₀] calc poissonCellLaplace u v ≤ 1 - (1 - exp (-2)) * (exp (-x) * (u : ℝ) * (v : ℝ)) := by simpa only [hatom] using hmono _ ≤ 1 - c * x ^ 2 := by linarith _ ≤ exp (-(c * x ^ 2)) := Real.one_sub_le_exp_neg _
    Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.poissonCellLaplace_light_rate · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/PoissonCell.lean:31
Laplace­Rate 1 core · 3 supporting These inequalities convert a birthday-scale exponential bound into the 1/n + d/n² rate and control the guarded reciprocal at zero. ★ birthday_reciprocal_rate

Scalar consequences of a usable-occupancy Laplace bound

These inequalities convert a birthday-scale exponential bound into the 1/n + d/n² rate and control the guarded reciprocal at zero. They do not depend on an observed law or on a choice of cell alphabet.

theorem birthday_reciprocal_rate reviewed
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk

For a positive exponent constant c, there is a positive constant B, depending only on c, such that for every positive sample size n and every cell count d, the scalar expression 2·max(n,d)/(c·n²) + 2·exp(−c·n²/(2·max(n,d))) is at most B·(1/n + d/n²). This is a purely numerical inequality: it converts a birthday-scale exponential bound into the 1/n + d/n² rate.

Formal statement
c :
ℝ
hc :
0 < c
∃ B : ℝ,
0 < B
conclusion 1
n d :
ℕ
0 < n
2 * max (n : ℝ) (d : ℝ) / (c * (n : ℝ) ^ 2)
+ 2 * exp (-(c * (n : ℝ) ^ 2 / (2 * max (n : ℝ) (d : ℝ))))
≤ B * (1 / (n : ℝ) + (d : ℝ) / (n : ℝ) ^ 2)
Proof (Lean source)
theorem birthday_reciprocal_rate (c : ℝ) (hc : 0 < c) : ∃ B : ℝ, 0 < B ∧ ∀ (n d : ℕ), 0 < n → 2 * max (n : ℝ) (d : ℝ) / (c * (n : ℝ) ^ 2) + 2 * exp (-(c * (n : ℝ) ^ 2 / (2 * max (n : ℝ) (d : ℝ)))) ≤ B * (1 / (n : ℝ) + (d : ℝ) / (n : ℝ) ^ 2) := by obtain ⟨B, hB, hrate⟩ := birthday_laplace_rate (c / 2) (by positivity) refine ⟨2 / c + B, by positivity, ?_⟩ intro n d hn let N : ℝ := n let D : ℝ := d have hN : 0 < N := by dsimp [N]; exact_mod_cast hn have hD : 0 ≤ D := Nat.cast_nonneg d have hM : max N D ≤ N + D := max_le (by linarith) (by linarith) have hC : 0 < c * N ^ 2 := mul_pos hc (sq_pos_of_pos hN) have hrec : 2 * max N D / (c * N ^ 2) ≤ (2 / c) * (1 / N + D / N ^ 2) := by have heq : (2 / c) * (1 / N + D / N ^ 2) = 2 * (N + D) / (c * N ^ 2) := by field_simp rw [heq] exact div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_left hM (by norm_num)) hC.le have htail := hrate n d hn have harg : -(c / 2 * N ^ 2 / max N D) = -(c * N ^ 2 / (2 * max N D)) := by ring change 2 * max N D / (c * N ^ 2) + 2 * exp (-(c * N ^ 2 / (2 * max N D))) ≤ (2 / c + B) * (1 / N + D / N ^ 2) rw [← harg] have htail' : 2 * exp (-(c / 2 * N ^ 2 / max N D)) ≤ B * (1 / N + D / N ^ 2) := htail nlinarith [hrec, htail']
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.birthday_reciprocal_rate · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/LaplaceRate.lean:99
3 supporting declarations (lemmas, instances)
  • birthday_laplace_rate theorem — A birthday-scale exponential bound is at most a constant times 1/n + d/n², uniformly over positive sample sizes and all finite dimensions, including dimension zero.
    c :
    ℝ
    hc :
    0 < c
    ∃ B : ℝ,
    0 < B
    conclusion 1
    n d :
    ℕ
    0 < n
    2 * exp (-(c * (n : ℝ) ^ 2 / max (n : ℝ) (d : ℝ)))
    ≤ B * (1 / (n : ℝ) + (d : ℝ) / (n : ℝ) ^ 2)
    Proof (Lean source)
    theorem birthday_laplace_rate (c : ℝ) (hc : 0 < c) : ∃ B : ℝ, 0 < B ∧ ∀ (n d : ℕ), 0 < n → 2 * exp (-(c * (n : ℝ) ^ 2 / max (n : ℝ) (d : ℝ))) ≤ B * (1 / (n : ℝ) + (d : ℝ) / (n : ℝ) ^ 2) := by refine ⟨2 / c, by positivity, ?_⟩ intro n d hn let N : ℝ := n let D : ℝ := d have hN : 0 < N := by dsimp [N]; exact_mod_cast hn have hD : 0 ≤ D := Nat.cast_nonneg d have hM : 0 < max N D := lt_of_lt_of_le hN (le_max_left _ _) have hC : 0 < c * N ^ 2 := mul_pos hc (sq_pos_of_pos hN) have hq : 0 < c * N ^ 2 / max N D := div_pos hC hM have hexp := Real.add_one_le_exp (c * N ^ 2 / max N D) have hprod : (c * N ^ 2 / max N D) * exp (-(c * N ^ 2 / max N D)) ≤ 1 := by have he := mul_le_mul_of_nonneg_right hexp (le_of_lt (Real.exp_pos (-(c * N ^ 2 / max N D)))) rw [add_mul, ← Real.exp_add] at he simp only [add_neg_cancel, Real.exp_zero, one_mul] at he nlinarith [Real.exp_pos (-(c * N ^ 2 / max N D))] have hbound : exp (-(c * N ^ 2 / max N D)) ≤ max N D / (c * N ^ 2) := by apply (le_div_iff₀ hC).2 have hh := (div_le_iff₀ hM).1 (show c * N ^ 2 * exp (-(c * N ^ 2 / max N D)) / max N D ≤ 1 by simpa [div_mul_eq_mul_div] using hprod) nlinarith have hmax : max N D ≤ N + D := max_le (by linarith) (by linarith) change 2 * exp (-(c * N ^ 2 / max N D)) ≤ (2 / c) * (1 / N + D / N ^ 2) have hrhs : (2 / c) * (1 / N + D / N ^ 2) = 2 * (N + D) / (c * N ^ 2) := by field_simp rw [hrhs] calc 2 * exp (-(c * N ^ 2 / max N D)) ≤ 2 * max N D / (c * N ^ 2) := by calc _ ≤ 2 * (max N D / (c * N ^ 2)) := mul_le_mul_of_nonneg_left hbound (by norm_num) _ = _ := by ring _ ≤ 2 * (N + D) / (c * N ^ 2) := div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_left hmax (by norm_num)) hC.le
    Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.birthday_laplace_rate · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/LaplaceRate.lean:16
  • guarded_inverse_le_exp theorem — The reciprocal of a positive integer, totalized to zero at zero, is bounded by a reciprocal threshold plus an exponential tail at that threshold.
    t :
    ℝ
    ht :
    0 < t
    m :
    ℕ
    (if 0 < m then (m : ℝ)⁻¹ else 0) ≤ t⁻¹ + exp t * exp (-(m : ℝ))
    Proof (Lean source)
    theorem guarded_inverse_le_exp (t : ℝ) (ht : 0 < t) (m : ℕ) : (if 0 < m then (m : ℝ)⁻¹ else 0) ≤ t⁻¹ + exp t * exp (-(m : ℝ)) := by by_cases hm : m = 0 · simpa [hm] using (show (0 : ℝ) ≤ t⁻¹ + exp t by positivity) have hm0 : 0 < m := Nat.pos_of_ne_zero hm have hmR : 0 < (m : ℝ) := by exact_mod_cast hm0 simp only [hm0, ↓reduceIte] by_cases htm : t ≤ (m : ℝ) · have hi : (m : ℝ)⁻¹ ≤ t⁻¹ := (inv_le_inv₀ hmR ht).2 htm nlinarith [Real.exp_pos t, Real.exp_pos (-(m : ℝ))] · have hmt : (m : ℝ) < t := lt_of_not_ge htm have hm1 : (1 : ℝ) ≤ m := by exact_mod_cast hm0 have hi : (m : ℝ)⁻¹ ≤ 1 := (inv_le_one₀ hmR).2 hm1 have he : 1 ≤ exp t * exp (-(m : ℝ)) := by rw [← Real.exp_add] exact Real.one_le_exp (by linarith) nlinarith [inv_nonneg.mpr ht.le]
    Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.guarded_inverse_le_exp · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/LaplaceRate.lean:67
  • zero_indicator_le_exp theorem — At zero occupancy, the indicator of the bad event is bounded by the Laplace kernel; at positive occupancy its left side is zero.
    m :
    ℕ
    (if m = 0 then (1 : ℝ) else 0) ≤ exp (-(m : ℝ))
    Proof (Lean source)
    theorem zero_indicator_le_exp (m : ℕ) : (if m = 0 then (1 : ℝ) else 0) ≤ exp (-(m : ℝ)) := by by_cases hm : m = 0 · simp [hm] · simp [hm, Real.exp_nonneg]
    Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.zero_indicator_le_exp · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/LaplaceRate.lean:91
Observed­Transport 1 core · 1 supporting These lemmas transport the finite cell-arm design bounds to measurable labels of an arbitrary observed probability space. ★ observed_reciprocal_occupancy_rate

Occupancy bounds for an observed law

These lemmas transport the finite cell-arm design bounds to measurable labels of an arbitrary observed probability space. The marks and their distribution play no role. In particular, null cells and zero usable totals retain the guards used by the design bounds.

theorem observed_reciprocal_occupancy_rate reviewed
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk

For an overlap margin ε strictly between zero and one half, there is a positive constant B, depending only on ε, such that the following holds for every probability law, every measurable label into a finite set of cells, every measurable Boolean arm label, and every positive sample size n: if in each cell of positive mass both arm-cell pairs have mass at least ε times the cell mass, then under n independent draws the expectation of the reciprocal of the usable total (the number of observations in cells containing both arms), with the reciprocal read as zero when the usable total is zero, is at most B·(1/n + card(κ)/n²), where card(κ) is the number of cells.

Formal statement
epsilon :
ℝ
hepsilon :
0 < epsilon
hepsilon_half :
epsilon < 1 / 2
∃ B : ℝ,
0 < B
conclusion 1
Ω κ :
Type
μ :
X :
Ω → κ
A :
Ω → Bool
n :
ℕ
0 < n
(∀ a k, 0 < cellMass μ X k → epsilon * cellMass μ X k ≤ armCellMass μ X A a k)
(∫ z : Fin n → Ω, inverseUsableGroupTotal X A z ∂Measure.pi (fun _ : Fin n => μ))
≤ B * (1 / (n : ℝ) + (Fintype.card κ : ℝ) / (n : ℝ) ^ 2)
Proof (Lean source)
theorem observed_reciprocal_occupancy_rate (epsilon : ℝ) (hepsilon : 0 < epsilon) (hepsilon_half : epsilon < 1 / 2) : ∃ B : ℝ, 0 < B ∧ ∀ (Ω κ : Type) [MeasurableSpace Ω] [Fintype κ] [DecidableEq κ] [MeasurableSpace κ] [MeasurableSingletonClass κ] (μ : Measure Ω) [IsProbabilityMeasure μ] (X : Ω → κ) (A : Ω → Bool) (n : ℕ), Measurable X → Measurable A → 0 < n → (∀ a k, 0 < cellMass μ X k → epsilon * cellMass μ X k ≤ armCellMass μ X A a k) → (∫ z : Fin n → Ω, inverseUsableGroupTotal X A z ∂Measure.pi (fun _ : Fin n => μ)) ≤ B * (1 / (n : ℝ) + (Fintype.card κ : ℝ) / (n : ℝ) ^ 2) := by classical obtain ⟨B, hB, hrate⟩ := reciprocal_occupancy_rate epsilon hepsilon hepsilon_half refine ⟨B, hB, ?_⟩ intro Ω κ _ _ _ _ _ μ _ X A n hX hA hn hoverlap let f : Ω → κ × Bool := fun ω => (X ω, A ω) let ν : Measure (κ × Bool) := μ.map f have hf : Measurable f := hX.prodMk hA haveI : IsProbabilityMeasure ν := Measure.isProbabilityMeasure_map hf.aemeasurable have hcell (k : κ) : cellMass ν (fun v : κ × Bool => v.1) k = cellMass μ X k := by unfold cellMass ν change ((μ.map f) {v : κ × Bool | v.1 = k}).toReal = (μ {ω | X ω = k}).toReal rw [Measure.map_apply hf (measurableSet_eq_fun measurable_fst measurable_const)] rfl have harm (a : Bool) (k : κ) : armCellMass ν (fun v : κ × Bool => v.1) (fun v => v.2) a k = armCellMass μ X A a k := by unfold armCellMass ν change ((μ.map f) {v : κ × Bool | v.1 = k ∧ v.2 = a}).toReal = (μ {ω | X ω = k ∧ A ω = a}).toReal rw [Measure.map_apply hf (Set.Finite.measurableSet (Set.toFinite _))] rfl have hoverlap' : ∀ a k, 0 < cellMass ν (fun v : κ × Bool => v.1) k → epsilon * cellMass ν (fun v => v.1) k ≤ armCellMass ν (fun v => v.1) (fun v => v.2) a k := by intro a k hk rw [hcell, harm] exact hoverlap a k (hcell k ▸ hk) let F : (Fin n → Ω) → (Fin n → κ × Bool) := fun z i => f (z i) have hF : Measurable F := measurable_pi_lambda _ (fun i => hf.comp (measurable_pi_apply i)) have hpi : (Measure.pi (fun _ : Fin n => μ)).map F = Measure.pi (fun _ : Fin n => ν) := iid_design_marginal n μ X A hX hA have hkernel : Measurable (inverseUsableGroupTotal (fun v : κ × Bool => v.1) (fun v => v.2) : (Fin n → κ × Bool) → ℝ) := measurable_inverseUsableGroupTotal _ _ measurable_fst measurable_snd have htransport : (∫ z : Fin n → Ω, inverseUsableGroupTotal X A z ∂Measure.pi (fun _ : Fin n => μ)) = (∫ z : Fin n → κ × Bool, inverseUsableGroupTotal (fun v => v.1) (fun v => v.2) z ∂Measure.pi (fun _ : Fin n => ν)) := by rw [← hpi, integral_map hF.aemeasurable hkernel.aestronglyMeasurable] rfl rw [htransport] exact hrate κ ν n hn hoverlap'
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.observed_reciprocal_occupancy_rate · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/ObservedTransport.lean:86 · uses armCellMass , cellMass , inverseUsableGroupTotal
1 supporting declaration (lemmas, instances)
Occupancy 1 core · 3 supporting These estimates concern only the finite observed design law on cell-arm pairs. ★ reciprocal_occupancy_rate

Uniform usable-occupancy controls

These estimates concern only the finite observed design law on cell-arm pairs. The constants are chosen before the cell alphabet, its masses, and sample size. The finite-product transport lemma moves them to any measurable observed law.

theorem reciprocal_occupancy_rate reviewed
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk

For an overlap margin ε strictly between zero and one half, there is a positive constant B, depending only on ε, such that the following holds for every finite set of cells, every probability law on cell-arm pairs, and every positive sample size n: if in each cell of positive mass both arm-cell pairs have mass at least ε times the cell mass, then under n independent draws the expectation of the reciprocal of the usable total (the number of observations in cells containing both arms), with the reciprocal read as zero when the usable total is zero, is at most B·(1/n + card(κ)/n²), where card(κ) is the number of cells.

Formal statement
epsilon :
ℝ
hepsilon :
0 < epsilon
hepsilon_half :
epsilon < 1 / 2
∃ B : ℝ,
0 < B
conclusion 1
κ :
Type
ν :
Measure (κ × Bool)
n :
ℕ
0 < n
(∀ a k, 0 < cellMass ν (fun z : κ × Bool => z.1) k → epsilon * cellMass ν (fun z : κ × Bool => z.1) k ≤ armCellMass ν (fun z => z.1) (fun z => z.2) a k)
(∫ z : Fin n → κ × Bool, inverseUsableGroupTotal (fun v => v.1) (fun v => v.2) z ∂Measure.pi (fun _ : Fin n => ν))
≤ B * (1 / (n : ℝ) + (Fintype.card κ : ℝ) / (n : ℝ) ^ 2)
Proof (Lean source)
theorem reciprocal_occupancy_rate (epsilon : ℝ) (hepsilon : 0 < epsilon) (hepsilon_half : epsilon < 1 / 2) : ∃ B : ℝ, 0 < B ∧ ∀ (κ : Type) [Fintype κ] [DecidableEq κ] [MeasurableSpace κ] [MeasurableSingletonClass κ] (ν : Measure (κ × Bool)) [IsProbabilityMeasure ν] (n : ℕ), 0 < n → (∀ a k, 0 < cellMass ν (fun z : κ × Bool => z.1) k → epsilon * cellMass ν (fun z : κ × Bool => z.1) k ≤ armCellMass ν (fun z => z.1) (fun z => z.2) a k) → (∫ z : Fin n → κ × Bool, inverseUsableGroupTotal (fun v => v.1) (fun v => v.2) z ∂Measure.pi (fun _ : Fin n => ν)) ≤ B * (1 / (n : ℝ) + (Fintype.card κ : ℝ) / (n : ℝ) ^ 2) := by classical obtain ⟨c, hc, hlap⟩ := fixed_design_laplace_rate epsilon hepsilon hepsilon_half obtain ⟨B, hB, hrate⟩ := birthday_reciprocal_rate c hc refine ⟨B, hB, ?_⟩ intro κ _ _ _ _ ν _ n hn hoverlap let P : Measure (Fin n → κ × Bool) := Measure.pi (fun _ : Fin n => ν) let T (z : Fin n → κ × Bool) := usableTotal (fun v : κ × Bool => v.1) (fun v => v.2) z let t : ℝ := c * (n : ℝ) ^ 2 / (2 * max (n : ℝ) (Fintype.card κ : ℝ)) have hnR : 0 < (n : ℝ) := by exact_mod_cast hn have ht : 0 < t := by dsimp [t] positivity have hpoint (z : Fin n → κ × Bool) : inverseUsableGroupTotal (fun v : κ × Bool => v.1) (fun v => v.2) z ≤ t⁻¹ + exp t * exp (-(T z : ℝ)) := by simpa [inverseUsableGroupTotal, T, usableTotal] using guarded_inverse_le_exp t ht (T z) have hmono : (∫ z, inverseUsableGroupTotal (fun v : κ × Bool => v.1) (fun v => v.2) z ∂P) ≤ ∫ z, t⁻¹ + exp t * exp (-(T z : ℝ)) ∂P := by exact integral_mono Integrable.of_finite Integrable.of_finite hpoint have hP : IsProbabilityMeasure P := inferInstance have hint : (∫ z, t⁻¹ + exp t * exp (-(T z : ℝ)) ∂P) = t⁻¹ + exp t * ∫ z, exp (-(T z : ℝ)) ∂P := by rw [integral_add (integrable_const _) Integrable.of_finite] rw [integral_const_mul] simp have hbound : t⁻¹ + exp t * (∫ z, exp (-(T z : ℝ)) ∂P) ≤ t⁻¹ + exp t * (2 * exp (-(c * (n : ℝ) ^ 2 / max (n : ℝ) (Fintype.card κ : ℝ)))) := by have hmul := mul_le_mul_of_nonneg_left (show (∫ z, exp (-(T z : ℝ)) ∂P) ≤ 2 * exp (-(c * (n : ℝ) ^ 2 / max (n : ℝ) (Fintype.card κ : ℝ))) from hlap κ ν n hn hoverlap) (Real.exp_nonneg t) linarith have hscalar : t⁻¹ + exp t * (2 * exp (-(c * (n : ℝ) ^ 2 / max (n : ℝ) (Fintype.card κ : ℝ)))) = 2 * max (n : ℝ) (Fintype.card κ : ℝ) / (c * (n : ℝ) ^ 2) + 2 * exp (-(c * (n : ℝ) ^ 2 / (2 * max (n : ℝ) (Fintype.card κ : ℝ)))) := by have hM : 0 < max (n : ℝ) (Fintype.card κ : ℝ) := lt_of_lt_of_le hnR (le_max_left _ _) have hnum : c * (n : ℝ) ^ 2 ≠ 0 := ne_of_gt (mul_pos hc (sq_pos_of_pos hnR)) have hden : 2 * max (n : ℝ) (Fintype.card κ : ℝ) ≠ 0 := by positivity have hrec : t⁻¹ = 2 * max (n : ℝ) (Fintype.card κ : ℝ) / (c * (n : ℝ) ^ 2) := by dsimp [t] field_simp have harg : -(c * (n : ℝ) ^ 2 / max (n : ℝ) (Fintype.card κ : ℝ)) = -t + -t := by dsimp [t] ring rw [hrec, harg, Real.exp_add] congr 1 calc exp t * (2 * (exp (-t) * exp (-t))) = 2 * (exp t * exp (-t)) * exp (-t) := by ring _ = 2 * exp (-t) := by rw [← Real.exp_add]; simp _ = 2 * exp (-(c * (n : ℝ) ^ 2 / (2 * max (n : ℝ) (Fintype.card κ : ℝ)))) := rfl change (∫ z, inverseUsableGroupTotal (fun v : κ × Bool => v.1) (fun v => v.2) z ∂P) ≤ _ calc _ ≤ ∫ z, t⁻¹ + exp t * exp (-(T z : ℝ)) ∂P := hmono _ = t⁻¹ + exp t * ∫ z, exp (-(T z : ℝ)) ∂P := hint _ ≤ t⁻¹ + exp t * (2 * exp (-(c * (n : ℝ) ^ 2 / max (n : ℝ) (Fintype.card κ : ℝ)))) := hbound _ = 2 * max (n : ℝ) (Fintype.card κ : ℝ) / (c * (n : ℝ) ^ 2) + 2 * exp (-(c * (n : ℝ) ^ 2 / (2 * max (n : ℝ) (Fintype.card κ : ℝ)))) := hscalar _ ≤ B * (1 / (n : ℝ) + (Fintype.card κ : ℝ) / (n : ℝ) ^ 2) := hrate n (Fintype.card κ) hn
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.reciprocal_occupancy_rate · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/Occupancy.lean:193 · uses armCellMass , cellMass , inverseUsableGroupTotal
3 supporting declarations (lemmas, instances)
  • iid_design_marginal theorem — Applying the measured cell and arm labels to every iid observation gives iid draws from the observed cell-arm marginal.
    Ω κ :
    n :
    ℕ
    X :
    Ω → κ
    A :
    Ω → Bool
    hX :
    hA :
    (Measure.pi (fun _ : Fin n => μ)).map (fun z : Fin n → Ω => fun i => (X (z i), A (z i)))
    = Measure.pi (fun _ : Fin n => μ.map (fun ω => (X ω, A ω)))
    Proof (Lean source)
    theorem iid_design_marginal {Ω κ : Type} [MeasurableSpace Ω] [MeasurableSpace κ] (n : ℕ) (μ : Measure Ω) [IsProbabilityMeasure μ] (X : Ω → κ) (A : Ω → Bool) (hX : Measurable X) (hA : Measurable A) : (Measure.pi (fun _ : Fin n => μ)).map (fun z : Fin n → Ω => fun i => (X (z i), A (z i))) = Measure.pi (fun _ : Fin n => μ.map (fun ω => (X ω, A ω))) := by exact map_pi_finCoordinatewise n μ (hX.prodMk hA)
    Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.iid_design_marginal · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/Occupancy.lean:19
  • fixed_design_laplace_rate theorem — The fixed-size Laplace transform of usable occupancy has a birthday-scale bound for every finite measurable cell alphabet, including null cells. The constant depends only on occupied-cell overlap.
    epsilon :
    ℝ
    hepsilon :
    0 < epsilon
    hepsilon_half :
    epsilon < 1 / 2
    ∃ c : ℝ,
    0 < c
    conclusion 1
    κ :
    Type
    ν :
    Measure (κ × Bool)
    n :
    ℕ
    0 < n
    (∀ a k, 0 < cellMass ν (fun z : κ × Bool => z.1) k → epsilon * cellMass ν (fun z : κ × Bool => z.1) k ≤ armCellMass ν (fun z => z.1) (fun z => z.2) a k)
    (∫ z : Fin n → κ × Bool, exp (-(usableTotal (fun v : κ × Bool => v.1) (fun v => v.2) z : ℝ)) ∂Measure.pi (fun _ : Fin n => ν))
    ≤ 2 * exp (-(c * (n : ℝ) ^ 2 / max (n : ℝ) (Fintype.card κ : ℝ)))
    Proof (Lean source)
    theorem fixed_design_laplace_rate (epsilon : ℝ) (hepsilon : 0 < epsilon) (hepsilon_half : epsilon < 1 / 2) : ∃ c : ℝ, 0 < c ∧ ∀ (κ : Type) [Fintype κ] [DecidableEq κ] [MeasurableSpace κ] [MeasurableSingletonClass κ] (ν : Measure (κ × Bool)) [IsProbabilityMeasure ν] (n : ℕ), 0 < n → (∀ a k, 0 < cellMass ν (fun z : κ × Bool => z.1) k → epsilon * cellMass ν (fun z : κ × Bool => z.1) k ≤ armCellMass ν (fun z => z.1) (fun z => z.2) a k) → (∫ z : Fin n → κ × Bool, exp (-(usableTotal (fun v : κ × Bool => v.1) (fun v => v.2) z : ℝ)) ∂Measure.pi (fun _ : Fin n => ν)) ≤ 2 * exp (-(c * (n : ℝ) ^ 2 / max (n : ℝ) (Fintype.card κ : ℝ))) := by classical obtain ⟨c, hc, hrate⟩ := poissonized_design_laplace_rate epsilon hepsilon hepsilon_half refine ⟨c, hc, ?_⟩ intro κ _ _ _ _ ν _ n hn hoverlap let e : κ ≃ Fin (Fintype.card κ) := Fintype.equivFin κ let em : κ ≃ᵐ Fin (Fintype.card κ) := MeasurableEquiv.mk e (measurable_of_countable _) (measurable_of_countable _) let ep : (κ × Bool) ≃ᵐ (Fin (Fintype.card κ) × Bool) := em.prodCongr (MeasurableEquiv.refl Bool) let ν' : Measure (Fin (Fintype.card κ) × Bool) := ν.map ep have : IsProbabilityMeasure ν' := Measure.isProbabilityMeasure_map ep.measurable.aemeasurable have hcell (k : κ) : cellMass ν' (fun v : Fin (Fintype.card κ) × Bool => v.1) (e k) = cellMass ν (fun v : κ × Bool => v.1) k := by unfold cellMass ν' rw [Measure.map_apply ep.measurable (Set.Finite.measurableSet (Set.toFinite _))] congr 1 apply congrArg ν ext v change e v.1 = e k ↔ v.1 = k exact e.injective.eq_iff have harm (a : Bool) (k : κ) : armCellMass ν' (fun v : Fin (Fintype.card κ) × Bool => v.1) (fun v => v.2) a (e k) = armCellMass ν (fun v : κ × Bool => v.1) (fun v => v.2) a k := by unfold armCellMass ν' rw [Measure.map_apply ep.measurable (Set.Finite.measurableSet (Set.toFinite _))] congr 1 apply congrArg ν ext v change e v.1 = e k ∧ v.2 = a ↔ v.1 = k ∧ v.2 = a simp only [e.injective.eq_iff] have hoverlap' : ∀ a k, 0 < cellMass ν' (fun v : Fin (Fintype.card κ) × Bool => v.1) k → epsilon * cellMass ν' (fun v => v.1) k ≤ armCellMass ν' (fun v => v.1) (fun v => v.2) a k := by intro a k hk obtain ⟨j, rfl⟩ := e.surjective k rw [hcell, harm] exact hoverlap a j (hcell j ▸ hk) have hcount (z : Fin n → κ × Bool) (a : Bool) (k : κ) : groupArmCount (fun v : Fin (Fintype.card κ) × Bool => v.1) (fun v => v.2) (fun i => ep (z i)) a (e k) = groupArmCount (fun v : κ × Bool => v.1) (fun v => v.2) z a k := by unfold groupArmCount congr 1 ext i simp only [mem_filter, Finset.mem_univ, true_and] change e (z i).1 = e k ∧ (z i).2 = a ↔ (z i).1 = k ∧ (z i).2 = a simp only [e.injective.eq_iff] have htotal (z : Fin n → κ × Bool) : usableTotal (fun v : Fin (Fintype.card κ) × Bool => v.1) (fun v => v.2) (fun i => ep (z i)) = usableTotal (fun v : κ × Bool => v.1) (fun v => v.2) z := by unfold usableTotal usableGroupTotal rw [← e.sum_comp] apply Finset.sum_congr rfl intro k _ simp only [usableGroup, groupCount, hcount] by_cases h : 0 < groupArmCount (fun v : κ × Bool => v.1) (fun v => v.2) z false k ∧ 0 < groupArmCount (fun v : κ × Bool => v.1) (fun v => v.2) z true k · simp [h] · simp [h] have hpi := Causalean.Stat.map_pi_finCoordinatewise n ν ep.measurable have htransport : (∫ z : Fin n → Fin (Fintype.card κ) × Bool, exp (-(usableTotal (fun v : Fin (Fintype.card κ) × Bool => v.1) (fun v => v.2) z : ℝ)) ∂Measure.pi (fun _ : Fin n => ν')) = (∫ z : Fin n → κ × Bool, exp (-(usableTotal (fun v : κ × Bool => v.1) (fun v => v.2) z : ℝ)) ∂Measure.pi (fun _ : Fin n => ν)) := by rw [← hpi] let es : (Fin n → κ × Bool) ≃ᵐ (Fin n → Fin (Fintype.card κ) × Bool) := MeasurableEquiv.piCongrRight (fun _ => ep) rw [show (fun z : Fin n → κ × Bool => fun i => ep (z i)) = es from rfl] rw [integral_map_equiv es] have hes (z : Fin n → κ × Bool) : es z = fun i => ep (z i) := rfl simp only [hes, htotal] rw [← htransport] exact (fixed_design_laplace_le_poisson ν').trans (mul_le_mul_of_nonneg_left (hrate _ ν' n hn hoverlap') (by norm_num))
    Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.fixed_design_laplace_rate · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/Occupancy.lean:29
  • bad_occupancy_rate theorem — Under occupied-cell overlap, the probability of no matched cell is bounded uniformly by a constant depending only on the overlap margin times 1/n + card(κ)/n², including null cells and the zero-usable case.
    epsilon :
    ℝ
    hepsilon :
    0 < epsilon
    hepsilon_half :
    epsilon < 1 / 2
    ∃ B : ℝ,
    0 < B
    conclusion 1
    κ :
    Type
    ν :
    Measure (κ × Bool)
    n :
    ℕ
    0 < n
    (∀ a k, 0 < cellMass ν (fun z : κ × Bool => z.1) k → epsilon * cellMass ν (fun z : κ × Bool => z.1) k ≤ armCellMass ν (fun z => z.1) (fun z => z.2) a k)
    ((Measure.pi (fun _ : Fin n => ν)) {z | usableTotal (fun v : κ × Bool => v.1) (fun v => v.2) z = 0}).toReal
    ≤ B * (1 / (n : ℝ) + (Fintype.card κ : ℝ) / (n : ℝ) ^ 2)
    Proof (Lean source)
    theorem bad_occupancy_rate (epsilon : ℝ) (hepsilon : 0 < epsilon) (hepsilon_half : epsilon < 1 / 2) : ∃ B : ℝ, 0 < B ∧ ∀ (κ : Type) [Fintype κ] [DecidableEq κ] [MeasurableSpace κ] [MeasurableSingletonClass κ] (ν : Measure (κ × Bool)) [IsProbabilityMeasure ν] (n : ℕ), 0 < n → (∀ a k, 0 < cellMass ν (fun z : κ × Bool => z.1) k → epsilon * cellMass ν (fun z : κ × Bool => z.1) k ≤ armCellMass ν (fun z => z.1) (fun z => z.2) a k) → ((Measure.pi (fun _ : Fin n => ν)) {z | usableTotal (fun v : κ × Bool => v.1) (fun v => v.2) z = 0}).toReal ≤ B * (1 / (n : ℝ) + (Fintype.card κ : ℝ) / (n : ℝ) ^ 2) := by classical obtain ⟨c, hc, hlap⟩ := fixed_design_laplace_rate epsilon hepsilon hepsilon_half obtain ⟨B, hB, hrate⟩ := birthday_laplace_rate c hc refine ⟨B, hB, ?_⟩ intro κ _ _ _ _ ν _ n hn hoverlap let P : Measure (Fin n → κ × Bool) := Measure.pi (fun _ : Fin n => ν) let T (z : Fin n → κ × Bool) := usableTotal (fun v : κ × Bool => v.1) (fun v => v.2) z let E : Set (Fin n → κ × Bool) := {z | T z = 0} have hE : MeasurableSet E := by exact measurableSet_eq_fun (measurable_usableGroupTotal (n := n) (fun v : κ × Bool => v.1) (fun v => v.2) measurable_fst measurable_snd) measurable_const have hmono : (∫ z, E.indicator (1 : (Fin n → κ × Bool) → ℝ) z ∂P) ≤ ∫ z, exp (-(T z : ℝ)) ∂P := by apply integral_mono Integrable.of_finite Integrable.of_finite intro z simpa [E, T, indicator, Set.indicator_apply] using zero_indicator_le_exp (T z) have hprob : P.real E = ∫ z, E.indicator (1 : (Fin n → κ × Bool) → ℝ) z ∂P := (integral_indicator_one hE).symm change P.real E ≤ _ calc P.real E = ∫ z, E.indicator (1 : (Fin n → κ × Bool) → ℝ) z ∂P := hprob _ ≤ ∫ z, exp (-(T z : ℝ)) ∂P := hmono _ ≤ 2 * exp (-(c * (n : ℝ) ^ 2 / max (n : ℝ) (Fintype.card κ : ℝ))) := hlap κ ν n hn hoverlap _ ≤ B * (1 / (n : ℝ) + (Fintype.card κ : ℝ) / (n : ℝ) ^ 2) := hrate n (Fintype.card κ) hn
    Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.bad_occupancy_rate · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/Occupancy.lean:140
Occupancy­Bridge 1 core · 2 supporting This module separates the deterministic prefix monotonicity, independent Poisson occupancy estimate, and half-intensity de-Poissonization needed for uniform fixed-sample collision bounds. ★ fixed_design_laplace_le_poisson

Poissonization bridge for finite observed designs

This module separates the deterministic prefix monotonicity, independent Poisson occupancy estimate, and half-intensity de-Poissonization needed for uniform fixed-sample collision bounds. All laws here concern observed cell and arm labels.

theorem fixed_design_laplace_le_poisson reviewed
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk

Given a finite cell count and sample size and an observed probability law on cell-arm pairs, the expectation of exp(−usable total) under n independent draws is at most twice the expectation of the same quantity for a Poissonized sample, in which the number of independent draws is itself Poisson with mean n/2. The usable total is the number of observations in cells containing both arms; no overlap condition is assumed.

Formal statement
d n :
ℕ
(∫ z : Fin n → Fin d × Bool, exp (-(usableTotal (fun v : Fin d × Bool => v.1) (fun v => v.2) z : ℝ)) ∂Measure.pi (fun _ : Fin n => ν))
≤ 2 * (∫ s : FiniteSample (Fin d × Bool), exp (-(usableTotal (fun v : Fin d × Bool => v.1) (fun v => v.2) s.2 : ℝ)) ∂finitePoissonSampleLaw ν ((n : ℝ≥0) / 2))
Proof (Lean source)
theorem fixed_design_laplace_le_poisson {d n : ℕ} (ν : Measure (Fin d × Bool)) [IsProbabilityMeasure ν] : (∫ z : Fin n → Fin d × Bool, exp (-(usableTotal (fun v : Fin d × Bool => v.1) (fun v => v.2) z : ℝ)) ∂Measure.pi (fun _ : Fin n => ν)) ≤ 2 * (∫ s : FiniteSample (Fin d × Bool), exp (-(usableTotal (fun v : Fin d × Bool => v.1) (fun v => v.2) s.2 : ℝ)) ∂finitePoissonSampleLaw ν ((n : ℝ≥0) / 2)) := by classical let X := Fin d × Bool let lam : ℝ≥0 := (n : ℝ≥0) / 2 let G (m : ℕ) (z : Fin m → X) : ℝ := exp (-(usableTotal (fun v : X => v.1) (fun v => v.2) z : ℝ)) let F (s : FiniteSample X) : ℝ := G s.1 s.2 have hG (m : ℕ) : Measurable (G m) := measurable_of_countable _ have hF : Measurable F := by intro t ht rw [MeasurableSpace.measurableSet_iInf] intro m change MeasurableSet ((fun z : Fin m → X => F ⟨m, z⟩) ⁻¹' t) exact ht.preimage (hG m) have hbounds (m : ℕ) (z : Fin m → X) : 0 ≤ G m z ∧ G m z ≤ 1 := by constructor · exact (Real.exp_pos _).le · apply Real.exp_le_one_iff.mpr exact neg_nonpos.mpr (by positivity) have htail : (1 / 2 : ℝ) ≤ (poissonMeasure lam).real (Iic n) := by have hmarkov := mul_meas_ge_le_integral_of_nonneg (μ := poissonMeasure lam) (f := fun k : ℕ => (k : ℝ)) (ae_of_all _ fun k => Nat.cast_nonneg k) ((poisson_natCast_memLp_two lam).integrable (by norm_num)) ((n : ℝ) + 1) have hset : {k : ℕ | (n : ℝ) + 1 ≤ (k : ℝ)} = (Iic n)ᶜ := by ext k simp only [Set.mem_ofPred_eq, Set.mem_compl_iff, Set.mem_Iic] norm_cast omega rw [hset, measureReal_compl measurableSet_Iic, poisson_natCast_first_moment] at hmarkov simp only [measureReal_def, measure_univ, ENNReal.toReal_one] at hmarkov change ((n : ℝ) + 1) * (1 - (poissonMeasure lam).real (Iic n)) ≤ (lam : ℝ) at hmarkov have hn : 0 ≤ (n : ℝ) := Nat.cast_nonneg n have hp : 0 ≤ (poissonMeasure lam).real (Iic n) := measureReal_nonneg have hlam : (lam : ℝ) = (n : ℝ) / 2 := by simp [lam, NNReal.coe_div] rw [hlam] at hmarkov nlinarith let μ : Measure (ℕ × (ℕ → X)) := poissonIIDStreamLaw ν lam let q (w : ℕ → X) : ℝ := G n (fun i => w i) let a (m : ℕ) : ℝ := if m ≤ n then 1 else 0 have hq : Measurable q := (hG n).comp (by fun_prop) have ha : Measurable a := measurable_of_countable _ have hqint : Integrable q (iidStreamLaw ν) := by apply Integrable.of_bound hq.aestronglyMeasurable 1 filter_upwards with w rw [Real.norm_eq_abs, abs_of_nonneg (hbounds n _).1] exact (hbounds n _).2 have haint : Integrable a (poissonMeasure lam) := by apply Integrable.of_bound ha.aestronglyMeasurable 1 filter_upwards with m simp only [a] split_ifs <;> norm_num have hFint : Integrable (fun z : ℕ × (ℕ → X) => F (streamToFiniteSample z)) μ := by apply Integrable.of_bound (hF.comp measurable_streamToFiniteSample).aestronglyMeasurable 1 filter_upwards with z change ‖G z.1 (fun i : Fin z.1 => z.2 i)‖ ≤ 1 rw [Real.norm_eq_abs, abs_of_nonneg (hbounds z.1 _).1] exact (hbounds z.1 _).2 have hprodint : Integrable (fun z : ℕ × (ℕ → X) => a z.1 * q z.2) μ := by change Integrable (fun z : ℕ × (ℕ → X) => a z.1 * q z.2) ((poissonMeasure lam).prod (iidStreamLaw ν)) exact haint.mul_prod hqint have hcomp : ∀ z : ℕ × (ℕ → X), a z.1 * q z.2 ≤ F (streamToFiniteSample z) := by intro z by_cases hz : z.1 ≤ n · have hm := usableTotal_prefix_mono hz (fun v : X => v.1) (fun v => v.2) (fun i : Fin n => z.2 i) have he : G n (fun i => z.2 i) ≤ G z.1 (fun i => z.2 i) := by apply Real.exp_le_exp.mpr exact neg_le_neg (by exact_mod_cast hm) simpa [a, q, F, G, streamToFiniteSample, hz] using he · have hp := (hbounds z.1 (fun i : Fin z.1 => z.2 i)).1 simpa [a, F, G, streamToFiniteSample, hz] using hp have hmain := integral_mono hprodint hFint hcomp have hfactor : (∫ z : ℕ × (ℕ → X), a z.1 * q z.2 ∂μ) = (poissonMeasure lam).real (Iic n) * ∫ w : ℕ → X, q w ∂iidStreamLaw ν := by change (∫ z : ℕ × (ℕ → X), a z.1 * q z.2 ∂(poissonMeasure lam).prod (iidStreamLaw ν)) = _ rw [integral_prod_mul] congr 1 have haeq : a = (Iic n).indicator (fun _ => (1 : ℝ)) := by funext m simp [a, indicator, Set.mem_Iic] rw [haeq] rw [integral_indicator measurableSet_Iic] simp [measureReal_def] have hprefix : (∫ w : ℕ → X, q w ∂iidStreamLaw ν) = ∫ z : Fin n → X, G n z ∂Measure.pi (fun _ : Fin n => ν) := by rw [← iidStreamLaw_map_finPrefix ν n] exact (integral_map (by fun_prop : Measurable (fun w : ℕ → X => fun i : Fin n => w i)).aemeasurable (hG n).aestronglyMeasurable).symm have hpoisson : (∫ s : FiniteSample X, F s ∂finitePoissonSampleLaw ν lam) = ∫ z : ℕ × (ℕ → X), F (streamToFiniteSample z) ∂μ := by exact integral_map measurable_streamToFiniteSample.aemeasurable hF.aestronglyMeasurable have hfixed_nonneg : 0 ≤ ∫ z : Fin n → X, G n z ∂Measure.pi (fun _ : Fin n => ν) := integral_nonneg (fun z => (hbounds n z).1) have hhalf : (1 / 2 : ℝ) * (∫ z : Fin n → X, G n z ∂Measure.pi (fun _ : Fin n => ν)) ≤ (poissonMeasure lam).real (Iic n) * (∫ z : Fin n → X, G n z ∂Measure.pi (fun _ : Fin n => ν)) := mul_le_mul_of_nonneg_right htail hfixed_nonneg change (∫ z : Fin n → X, G n z ∂Measure.pi (fun _ : Fin n => ν)) ≤ 2 * (∫ s : FiniteSample X, F s ∂finitePoissonSampleLaw ν lam) rw [hpoisson] rw [hfactor, hprefix] at hmain linarith
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.fixed_design_laplace_le_poisson · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/OccupancyBridge.lean:207 · uses FiniteSample , finitePoissonSampleLaw , usableTotal
2 supporting declarations (lemmas, instances)
  • usableTotal_prefix_mono theorem — Adding observations cannot decrease the number of observations lying in cells where both observed arms are present. This includes the case in which a previously unmatched cell becomes matched.
    Ω κ :
    n N :
    ℕ
    hnN :
    n ≤ N
    X :
    Ω → κ
    A :
    Ω → Bool
    z :
    Fin N → Ω
    usableTotal X A (fun i : Fin n => z (castLE hnN i)) ≤ usableTotal X A z
    Proof (Lean source)
    theorem usableTotal_prefix_mono {Ω κ : Type} [Fintype κ] [DecidableEq κ] {n N : ℕ} (hnN : n ≤ N) (X : Ω → κ) (A : Ω → Bool) (z : Fin N → Ω) : usableTotal X A (fun i : Fin n => z (castLE hnN i)) ≤ usableTotal X A z := by classical have hcount (a : Bool) (k : κ) : groupArmCount X A (fun i : Fin n => z (castLE hnN i)) a k ≤ groupArmCount X A z a k := by unfold groupArmCount apply Finset.card_le_card_of_injOn (castLE hnN) · intro i hi simpa using hi · intro i _ j _ hij exact Fin.castLE_injective hnN hij unfold usableTotal usableGroupTotal apply Finset.sum_le_sum intro k _ by_cases hp : usableGroup X A (fun i : Fin n => z (castLE hnN i)) k · have hfull : usableGroup X A z k := by exact ⟨lt_of_lt_of_le hp.1 (hcount false k), lt_of_lt_of_le hp.2 (hcount true k)⟩ simp only [if_pos hp, if_pos hfull, groupCount] have hf := hcount false k have ht := hcount true k omega · simp [hp]
    Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.usableTotal_prefix_mono · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/OccupancyBridge.lean:26
  • poissonized_design_laplace_rate theorem — The half-intensity Poisson sample has an exponentially small Laplace transform of usable occupancy, uniformly over finite observed cell masses and null cells under arm-cell overlap. The positive exponent constant depends only on the overlap margin.
    epsilon :
    ℝ
    hepsilon :
    0 < epsilon
    hepsilon_half :
    epsilon < 1 / 2
    ∃ c : ℝ,
    0 < c
    conclusion 1
    d :
    ℕ
    ν :
    n :
    ℕ
    0 < n
    (∀ a k, 0 < cellMass ν (fun v : Fin d × Bool => v.1) k → epsilon * cellMass ν (fun v : Fin d × Bool => v.1) k ≤ armCellMass ν (fun v => v.1) (fun v => v.2) a k)
    (∫ s : FiniteSample (Fin d × Bool), exp (-(usableTotal (fun v : Fin d × Bool => v.1) (fun v => v.2) s.2 : ℝ)) ∂finitePoissonSampleLaw ν ((n : ℝ≥0) / 2))
    ≤ exp (-(c * (n : ℝ) ^ 2 / max (n : ℝ) (d : ℝ)))
    Proof (Lean source)
    theorem poissonized_design_laplace_rate (epsilon : ℝ) (hepsilon : 0 < epsilon) (hepsilon_half : epsilon < 1 / 2) : ∃ c : ℝ, 0 < c ∧ ∀ (d : ℕ) (ν : Measure (Fin d × Bool)) [IsProbabilityMeasure ν] (n : ℕ), 0 < n → (∀ a k, 0 < cellMass ν (fun v : Fin d × Bool => v.1) k → epsilon * cellMass ν (fun v : Fin d × Bool => v.1) k ≤ armCellMass ν (fun v => v.1) (fun v => v.2) a k) → (∫ s : FiniteSample (Fin d × Bool), exp (-(usableTotal (fun v : Fin d × Bool => v.1) (fun v => v.2) s.2 : ℝ)) ∂finitePoissonSampleLaw ν ((n : ℝ≥0) / 2)) ≤ exp (-(c * (n : ℝ) ^ 2 / max (n : ℝ) (d : ℝ))) := by classical obtain ⟨c₀, hc₀, hrate⟩ := independent_poisson_laplace_rate epsilon hepsilon hepsilon_half refine ⟨c₀ / 4, by positivity, ?_⟩ intro d ν _ n hn hoverlap have hd : 0 < d := by by_contra h have hzero : d = 0 := by omega subst d have hempty : (Set.univ : Set (Fin 0 × Bool)) = ∅ := by ext ⟨k, a⟩ exact elim0 k have hprob := measure_univ (μ := ν) rw [hempty, measure_empty] at hprob exact zero_ne_one hprob let lam : ℝ≥0 := (n : ℝ≥0) / 2 let u : Fin d → ℝ≥0 := fun k => lam * (ν {(k, false)}).toNNReal let v : Fin d → ℝ≥0 := fun k => lam * (ν {(k, true)}).toNNReal let x : Fin d → ℝ := fun k => (u k : ℝ) + v k have hsplit (k : Fin d) : ν {(k, false)} + ν {(k, true)} = ν (groupEvent (fun w : Fin d × Bool => w.1) k) := by rw [← measure_union (by simp) (measurableSet_singleton _)] congr 1 ext ⟨j, a⟩ cases a <;> simp [groupEvent] have hx (k : Fin d) : x k = (lam : ℝ) * cellMass ν (fun w => w.1) k := by simp only [x, u, v, cellMass] rw [← NNReal.coe_add, ← mul_add, ← ENNReal.toNNReal_add (measure_ne_top ν _) (measure_ne_top ν _), hsplit] rfl have hsum : ∑ k, x k = (lam : ℝ) := by let p : FiniteMeasurablePartition (Fin d × Bool) (Fin d) := ⟨Prod.fst, measurable_fst⟩ have hp : ∑ k, cellMass ν (fun w : Fin d × Bool => w.1) k = 1 := by have h := p.sum_cellMass ν apply_fun (fun t : ℝ≥0 => (t : ℝ)) at h norm_cast at h calc _ = ∑ k, (p.cellMass ν k : ℝ) := by apply Finset.sum_congr rfl intro k _ rfl _ = 1 := by exact_mod_cast h simp_rw [hx] rw [← Finset.mul_sum, hp, mul_one] have hu (k : Fin d) : epsilon * x k ≤ u k := by by_cases hk : 0 < cellMass ν (fun w : Fin d × Bool => w.1) k · have hh := hoverlap false k hk rw [hx] have hle : (lam : ℝ) * (epsilon * cellMass ν (fun w => w.1) k) ≤ (lam : ℝ) * armCellMass ν (fun w => w.1) (fun w => w.2) false k := mul_le_mul_of_nonneg_left hh (by positivity) convert hle using 1 · ring · have hevent : armGroupEvent (fun w : Fin d × Bool => w.1) (fun w => w.2) false k = {(k, false)} := by ext ⟨j, a⟩ cases a <;> simp [armGroupEvent] simp [u, armCellMass, hevent, toReal] · have hz : cellMass ν (fun w : Fin d × Bool => w.1) k = 0 := by have : 0 ≤ cellMass ν (fun w : Fin d × Bool => w.1) k := by unfold cellMass positivity exact le_antisymm (le_of_not_gt hk) this simp [hx, hz] have hv (k : Fin d) : epsilon * x k ≤ v k := by by_cases hk : 0 < cellMass ν (fun w : Fin d × Bool => w.1) k · have hh := hoverlap true k hk rw [hx] have hle : (lam : ℝ) * (epsilon * cellMass ν (fun w => w.1) k) ≤ (lam : ℝ) * armCellMass ν (fun w => w.1) (fun w => w.2) true k := mul_le_mul_of_nonneg_left hh (by positivity) convert hle using 1 · ring · have hevent : armGroupEvent (fun w : Fin d × Bool => w.1) (fun w => w.2) true k = {(k, true)} := by ext ⟨j, a⟩ cases a <;> simp [armGroupEvent] simp [v, armCellMass, hevent, toReal] · have hz : cellMass ν (fun w : Fin d × Bool => w.1) k = 0 := by have : 0 ≤ cellMass ν (fun w : Fin d × Bool => w.1) k := by unfold cellMass positivity exact le_antisymm (le_of_not_gt hk) this simp [hx, hz] have hbound := hrate d hd u v x (lam : ℝ) (fun k => rfl) hu hv hsum let H : FiniteSample (Fin d × Bool) → Fin d → ℕ × ℕ := fun s k => (groupArmCount (fun w : Fin d × Bool => w.1) (fun w => w.2) s.2 false k, groupArmCount (fun w : Fin d × Bool => w.1) (fun w => w.2) s.2 true k) have hH : Measurable H := by intro t ht rw [MeasurableSpace.measurableSet_iInf] intro m change MeasurableSet ((fun z : Fin m → Fin d × Bool => H ⟨m, z⟩) ⁻¹' t) exact (Set.to_countable _).measurableSet have hcount (s : FiniteSample (Fin d × Bool)) : (usableTotal (fun w : Fin d × Bool => w.1) (fun w => w.2) s.2 : ℝ) = ∑ k, (usablePoissonPairCount (H s k) : ℝ) := by unfold usableTotal usableGroupTotal usablePoissonPairCount usableGroup groupCount H push_cast rfl have htransport : (∫ s : FiniteSample (Fin d × Bool), exp (-(usableTotal (fun w : Fin d × Bool => w.1) (fun w => w.2) s.2 : ℝ)) ∂finitePoissonSampleLaw ν lam) = ∫ z : Fin d → ℕ × ℕ, exp (-(∑ k, (usablePoissonPairCount (z k) : ℝ))) ∂Measure.pi (fun k => (poissonMeasure (u k)).prod (poissonMeasure (v k))) := by rw [← poisson_arm_cell_count_law ν lam] rw [integral_map hH.aemeasurable (measurable_of_countable _).aestronglyMeasurable] congr 1 funext s rw [hcount] rw [htransport] have hlam : (lam : ℝ) = (n : ℝ) / 2 := by simp [lam, NNReal.coe_div] rw [hlam] at hbound have hnreal : (0 : ℝ) < n := by exact_mod_cast hn have hdreal : (0 : ℝ) ≤ d := by positivity have hmax : 0 < max (n : ℝ) (d : ℝ) := lt_of_lt_of_le hnreal (le_max_left _ _) have hr : c₀ / 4 * (n : ℝ) ^ 2 / max (n : ℝ) (d : ℝ) ≤ c₀ * ((n : ℝ) / 2) ^ 2 / max ((n : ℝ) / 2) (d : ℝ) := by have hmaxle : max ((n : ℝ) / 2) (d : ℝ) ≤ max (n : ℝ) (d : ℝ) := max_le_max_right _ (by linarith) have hmaxhalf : 0 < max ((n : ℝ) / 2) (d : ℝ) := by apply lt_of_lt_of_le (by linarith : (0 : ℝ) < (n : ℝ) / 2) exact le_max_left _ _ apply (div_le_div_iff₀ hmax hmaxhalf).2 nlinarith [mul_nonneg (show 0 ≤ c₀ * (n : ℝ) ^ 2 by positivity) (sub_nonneg.mpr hmaxle)] exact le_trans hbound (Real.exp_le_exp.mpr (neg_le_neg hr))
    Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.poissonized_design_laplace_rate · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/OccupancyBridge.lean:56
Poisson­Aggregate 1 core · 1 supporting The deterministic light and heavy mass split and the resulting product-law Laplace estimate are separated from transport of the finite Poisson sample. ★ independent_poisson_laplace_rate

Aggregating independent Poisson cells

The deterministic light and heavy mass split and the resulting product-law Laplace estimate are separated from transport of the finite Poisson sample.

theorem independent_poisson_laplace_rate reviewed
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk

For an overlap margin ε strictly between zero and one half, there is a positive constant c, depending only on ε, such that the following holds for every positive number d of cells and every table of nonnegative control and treated Poisson intensities whose cell totals are x and whose grand total is T: if in each cell both intensities are at least ε times the cell total, then, for independent Poisson arm counts with those intensities, the expectation of exp(−sum over cells of the usable count) is at most exp(−c·T²/max(T, d)). The usable count of a cell is the sum of its two arm counts when both are positive, and zero otherwise.

Formal statement
epsilon :
ℝ
hepsilon :
0 < epsilon
hepsilon_half :
epsilon < 1 / 2
∃ c : ℝ,
0 < c
conclusion 1
d :
ℕ
hd :
0 < d
u v :
Fin d → ℝ≥0
x :
Fin d → ℝ
total :
ℝ
(∀ k, (u k : ℝ) + v k = x k)
(∀ k, epsilon * x k ≤ u k)
(∀ k, epsilon * x k ≤ v k)
(∑ k, x k = total)
(∫ z : Fin d → ℕ × ℕ, exp (-(∑ k, (usablePoissonPairCount (z k) : ℝ))) ∂Measure.pi (fun k => (poissonMeasure (u k)).prod (poissonMeasure (v k))))
≤ exp (-(c * total ^ 2 / max total (d : ℝ)))
Proof (Lean source)
theorem independent_poisson_laplace_rate (epsilon : ℝ) (hepsilon : 0 < epsilon) (hepsilon_half : epsilon < 1 / 2) : ∃ c : ℝ, 0 < c ∧ ∀ (d : ℕ) (hd : 0 < d) (u v : Fin d → ℝ≥0) (x : Fin d → ℝ) (total : ℝ), (∀ k, (u k : ℝ) + v k = x k) → (∀ k, epsilon * x k ≤ u k) → (∀ k, epsilon * x k ≤ v k) → (∑ k, x k = total) → (∫ z : Fin d → ℕ × ℕ, exp (-(∑ k, (usablePoissonPairCount (z k) : ℝ))) ∂Measure.pi (fun k => (poissonMeasure (u k)).prod (poissonMeasure (v k)))) ≤ exp (-(c * total ^ 2 / max total (d : ℝ))) := by obtain ⟨a, ha, hlight⟩ := poissonCellLaplace_light_rate epsilon hepsilon obtain ⟨b, hb, hheavy⟩ := poissonCellLaplace_heavy_rate epsilon hepsilon hepsilon_half let c : ℝ := min (a / 4) (b / 2) refine ⟨c, lt_min (by positivity) (by positivity), ?_⟩ intro d hd u v x total hx hu hv hsum have hx0 (k : Fin d) : 0 ≤ x k := by rw [← hx k] positivity have htotal : 0 ≤ total := by rw [← hsum] exact Finset.sum_nonneg (fun k _ => hx0 k) have hcost := lightHeavyExponent_ge_birthdayScale hd htotal ha.le hb.le x hx0 hsum have hprod := poisson_cell_product_le_exp_sum u v x a b (fun k hk => hlight (u k) (v k) (x k) (hx k) (hu k) (hv k) hk) (fun k hk => hheavy (u k) (v k) (x k) (hx k) (hu k) (hv k) hk.le) calc (∫ z : Fin d → ℕ × ℕ, exp (-(∑ k, (usablePoissonPairCount (z k) : ℝ))) ∂Measure.pi (fun k => (poissonMeasure (u k)).prod (poissonMeasure (v k)))) = ∏ k, poissonCellLaplace (u k) (v k) := poisson_usable_integral_eq_prod u v _ ≤ exp (-(a * ∑ k ∈ Finset.univ.filter (fun k ↦ x k ≤ 1), x k ^ 2 + b * ∑ k ∈ Finset.univ.filter (fun k ↦ 1 < x k), x k)) := hprod _ ≤ exp (-(c * total ^ 2 / max total (d : ℝ))) := by apply Real.exp_le_exp.mpr linarith [hcost]
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.independent_poisson_laplace_rate · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/PoissonAggregate.lean:104 · uses usablePoissonPairCount
1 supporting declaration (lemmas, instances)
  • lightHeavyExponent_ge_birthdayScale theorem — For nonnegative cell intensities summing to total, the quadratic cost in cells of intensity at most one and linear cost in the other cells dominate the birthday-scale quantity total² / max total d. This includes zero intensity and null cells.
    d :
    ℕ
    hd :
    0 < d
    total a b :
    ℝ
    htotal :
    0 ≤ total
    ha :
    0 ≤ a
    hb :
    0 ≤ b
    x :
    Fin d → ℝ
    hx :
    ∀ k, 0 ≤ x k
    hsum :
    ∑ k, x k = total
    min (a / 4) (b / 2) * total ^ 2 / max total (d : ℝ)
    ≤ a * ∑ k ∈ Finset.univ.filter (fun k ↦ x k ≤ 1), x k ^ 2
    + b * ∑ k ∈ Finset.univ.filter (fun k ↦ 1 < x k), x k
    Proof (Lean source)
    theorem lightHeavyExponent_ge_birthdayScale {d : ℕ} (hd : 0 < d) {total a b : ℝ} (htotal : 0 ≤ total) (ha : 0 ≤ a) (hb : 0 ≤ b) (x : Fin d → ℝ) (hx : ∀ k, 0 ≤ x k) (hsum : ∑ k, x k = total) : min (a / 4) (b / 2) * total ^ 2 / max total (d : ℝ) ≤ a * ∑ k ∈ Finset.univ.filter (fun k ↦ x k ≤ 1), x k ^ 2 + b * ∑ k ∈ Finset.univ.filter (fun k ↦ 1 < x k), x k := by let light : Finset (Fin d) := Finset.univ.filter (fun k ↦ x k ≤ 1) let heavy : Finset (Fin d) := Finset.univ.filter (fun k ↦ 1 < x k) have hpartition : (∑ k ∈ light, x k) + ∑ k ∈ heavy, x k = total := by rw [← hsum] classical rw [← Finset.sum_filter_add_sum_filter_not univ (fun k ↦ x k ≤ 1) x] simp only [light, heavy, not_le] have hmax_pos : 0 < max total (d : ℝ) := lt_of_lt_of_le (by exact_mod_cast hd) (le_max_right _ _) have htotal_rate : total ^ 2 / max total (d : ℝ) ≤ total := by apply (div_le_iff₀ hmax_pos).2 nlinarith [le_max_left total (d : ℝ)] by_cases hheavy : total / 2 ≤ ∑ k ∈ heavy, x k · have hc_le : min (a / 4) (b / 2) ≤ b / 2 := min_le_right _ _ have hleft : min (a / 4) (b / 2) * total ^ 2 / max total (d : ℝ) ≤ b * (total / 2) := by calc min (a / 4) (b / 2) * total ^ 2 / max total (d : ℝ) = min (a / 4) (b / 2) * (total ^ 2 / max total (d : ℝ)) := by ring _ ≤ min (a / 4) (b / 2) * total := mul_le_mul_of_nonneg_left htotal_rate (le_min (by positivity) (by positivity)) _ ≤ (b / 2) * total := mul_le_mul_of_nonneg_right hc_le htotal _ = b * (total / 2) := by ring have hlight_nonneg : 0 ≤ a * ∑ k ∈ light, x k ^ 2 := by positivity have := mul_le_mul_of_nonneg_left hheavy hb change min (a / 4) (b / 2) * total ^ 2 / max total (d : ℝ) ≤ a * ∑ k ∈ light, x k ^ 2 + b * ∑ k ∈ heavy, x k nlinarith · have hlight_mass : total / 2 < ∑ k ∈ light, x k := by linarith have hcauchy : (∑ k ∈ light, x k) ^ 2 ≤ (light.card : ℝ) * ∑ k ∈ light, x k ^ 2 := by simpa using sq_sum_le_card_mul_sum_sq (s := light) (f := x) have hcard : (light.card : ℝ) ≤ d := by have hcardNat : light.card ≤ card (Fin d) := light.card_le_univ rw [Fintype.card_fin] at hcardNat exact_mod_cast hcardNat have hsquares_nonneg : 0 ≤ ∑ k ∈ light, x k ^ 2 := by positivity have hcauchy_d : (∑ k ∈ light, x k) ^ 2 ≤ (d : ℝ) * ∑ k ∈ light, x k ^ 2 := hcauchy.trans (mul_le_mul_of_nonneg_right hcard hsquares_nonneg) have hhalf_sq : (total / 2) ^ 2 ≤ (∑ k ∈ light, x k) ^ 2 := by nlinarith [Finset.sum_nonneg (s := light) (fun k _ ↦ hx k)] have hsquares : total ^ 2 / (4 * d) ≤ ∑ k ∈ light, x k ^ 2 := by have hdreal : (0 : ℝ) < d := by exact_mod_cast hd apply (div_le_iff₀ (by positivity : (0 : ℝ) < 4 * d)).2 nlinarith have hrate_d : total ^ 2 / max total (d : ℝ) ≤ total ^ 2 / d := by exact div_le_div_of_nonneg_left (sq_nonneg total) (by exact_mod_cast hd) (le_max_right _ _) have hc_le : min (a / 4) (b / 2) ≤ a / 4 := min_le_left _ _ have hleft : min (a / 4) (b / 2) * total ^ 2 / max total (d : ℝ) ≤ a * (total ^ 2 / (4 * d)) := by calc min (a / 4) (b / 2) * total ^ 2 / max total (d : ℝ) = min (a / 4) (b / 2) * (total ^ 2 / max total (d : ℝ)) := by ring _ ≤ min (a / 4) (b / 2) * (total ^ 2 / d) := mul_le_mul_of_nonneg_left hrate_d (le_min (by positivity) (by positivity)) _ ≤ (a / 4) * (total ^ 2 / d) := mul_le_mul_of_nonneg_right hc_le (by positivity) _ = a * (total ^ 2 / (4 * d)) := by ring have hheavy_nonneg : 0 ≤ b * ∑ k ∈ heavy, x k := by exact mul_nonneg hb (Finset.sum_nonneg fun k _ ↦ hx k) dsimp [light, heavy] at * nlinarith [mul_le_mul_of_nonneg_left hsquares ha]
    Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.lightHeavyExponent_ge_birthdayScale · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/PoissonAggregate.lean:21
Poisson­Product 1 core · 1 supporting These lemmas separate the independent-coordinate integral identity from the finite product comparison used in the birthday-scale occupancy estimate. ★ poisson_cell_product_le_exp_sum

Product-law Poisson occupancy bounds

These lemmas separate the independent-coordinate integral identity from the finite product comparison used in the birthday-scale occupancy estimate.

theorem poisson_cell_product_le_exp_sum reviewed
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk

Take two vectors of Poisson arm intensities over finitely many cells, a real number x attached to each cell, and two real exponents a and b. If every cell with x at most one has one-cell Laplace factor at most exp(−a·x²) and every cell with x above one has one-cell Laplace factor at most exp(−b·x), then the product of the one-cell Laplace factors over all cells is at most exp(−(a·S₂ + b·S₁)), where S₂ is the sum of x² over the cells with x at most one and S₁ is the sum of x over the cells with x above one.

Formal statement
d :
ℕ
u v :
Fin d → ℝ≥0
x :
Fin d → ℝ
a b :
ℝ
hlight :
∀ k
if
x k ≤ 1
then
poissonCellLaplace (u k) (v k) ≤ exp (-(a * x k ^ 2))
hheavy :
∀ k
if
1 < x k
then
poissonCellLaplace (u k) (v k) ≤ exp (-(b * x k))
(∏ k, poissonCellLaplace (u k) (v k))
≤ exp (-(a * ∑ k ∈ Finset.univ.filter (fun k ↦ x k ≤ 1), x k ^ 2 + b * ∑ k ∈ Finset.univ.filter (fun k ↦ 1 < x k), x k))
Proof (Lean source)
theorem poisson_cell_product_le_exp_sum {d : ℕ} (u v : Fin d → ℝ≥0) (x : Fin d → ℝ) (a b : ℝ) (hlight : ∀ k, x k ≤ 1 → poissonCellLaplace (u k) (v k) ≤ exp (-(a * x k ^ 2))) (hheavy : ∀ k, 1 < x k → poissonCellLaplace (u k) (v k) ≤ exp (-(b * x k))) : (∏ k, poissonCellLaplace (u k) (v k)) ≤ exp (-(a * ∑ k ∈ Finset.univ.filter (fun k ↦ x k ≤ 1), x k ^ 2 + b * ∑ k ∈ Finset.univ.filter (fun k ↦ 1 < x k), x k)) := by -- Compare the nonnegative factors using the ordered-ring form of -- `Finset.prod_le_prod`, then -- combine exponential factors with `Real.exp_sum` and split the index set. classical let rate : Fin d → ℝ := fun k => if x k ≤ 1 then a * x k ^ 2 else b * x k have hnonneg (k : Fin d) : 0 ≤ poissonCellLaplace (u k) (v k) := by unfold poissonCellLaplace exact integral_nonneg (fun _ => (Real.exp_pos _).le) have hcell (k : Fin d) : poissonCellLaplace (u k) (v k) ≤ exp (-(rate k)) := by by_cases hk : x k ≤ 1 · simpa [rate, hk] using hlight k hk · have hk' : 1 < x k := lt_of_not_ge hk simpa [rate, hk] using hheavy k hk' calc (∏ k, poissonCellLaplace (u k) (v k)) ≤ ∏ k, exp (-(rate k)) := by exact Finset.prod_le_prod (fun k _ => hnonneg k) (fun k _ => hcell k) _ = exp (-(∑ k, rate k)) := by rw [← Real.exp_sum, Finset.sum_neg_distrib] _ = exp (-(a * ∑ k ∈ Finset.univ.filter (fun k ↦ x k ≤ 1), x k ^ 2 + b * ∑ k ∈ Finset.univ.filter (fun k ↦ 1 < x k), x k)) := by congr 1 simp [rate, Finset.sum_ite, Finset.mul_sum, not_le]
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.poisson_cell_product_le_exp_sum · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/PoissonProduct.lean:44 · uses poissonCellLaplace
1 supporting declaration (lemmas, instances)
Poisson­Transport 1 core · 0 supporting The count-law identity transports an observed finite Poisson sample to its independent Poisson arm-cell histogram, including cells of zero mass. ★ poisson_arm_cell_count_law

Poisson sample to independent arm-cell counts

The count-law identity transports an observed finite Poisson sample to its independent Poisson arm-cell histogram, including cells of zero mass.

theorem poisson_arm_cell_count_law reviewed
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk

Given a finite cell count, an observed probability law, and a nonnegative Poisson mean λ, draw a Poisson(λ) number of independent observations from the law. Then the table of control and treated counts in each cell has independent entries across cells and arms, the count of each arm-cell pair being Poisson with mean λ times that pair's probability; a pair of zero probability has the degenerate Poisson law with mean zero.

Formal statement
d :
ℕ
lam :
ℝ≥0
(finitePoissonSampleLaw ν lam).map (fun s : FiniteSample (Fin d × Bool) => fun k : Fin d => (groupArmCount (fun v : Fin d × Bool => v.1) (fun v => v.2) s.2 false k, groupArmCount (fun v : Fin d × Bool => v.1) (fun v => v.2) s.2 true k))
= Measure.pi (fun k : Fin d => (poissonMeasure (lam * (ν {(k, false)}).toNNReal)).prod (poissonMeasure (lam * (ν {(k, true)}).toNNReal)))
Proof (Lean source)
theorem poisson_arm_cell_count_law {d : ℕ} (ν : Measure (Fin d × Bool)) [IsProbabilityMeasure ν] (lam : ℝ≥0) : (finitePoissonSampleLaw ν lam).map (fun s : FiniteSample (Fin d × Bool) => fun k : Fin d => (groupArmCount (fun v : Fin d × Bool => v.1) (fun v => v.2) s.2 false k, groupArmCount (fun v : Fin d × Bool => v.1) (fun v => v.2) s.2 true k)) = Measure.pi (fun k : Fin d => (poissonMeasure (lam * (ν {(k, false)}).toNNReal)).prod (poissonMeasure (lam * (ν {(k, true)}).toNNReal))) := by classical let μ : Fin d × Bool → Measure ℕ := fun p => poissonMeasure (lam * (ν {p}).toNNReal) let regroup : (Fin d × Bool → ℕ) → Fin d → ℕ × ℕ := fun h k => (h (k, false), h (k, true)) have hregroup : Measurable regroup := by apply measurable_pi_lambda intro k exact (measurable_pi_apply (k, false)).prodMk (measurable_pi_apply (k, true)) have hhist : (fun s : FiniteSample (Fin d × Bool) => fun k : Fin d => (groupArmCount (fun v : Fin d × Bool => v.1) (fun v => v.2) s.2 false k, groupArmCount (fun v : Fin d × Bool => v.1) (fun v => v.2) s.2 true k)) = regroup ∘ (fun s : FiniteSample (Fin d × Bool) => finiteSampleHistogram s.points) := by funext s k rcases s with ⟨n, z⟩ have hcount (a : Bool) : groupArmCount (fun v : Fin d × Bool => v.1) (fun v => v.2) z a k = finiteSampleHistogram z (k, a) := by rw [finiteSampleHistogram, Fintype.card_subtype] unfold groupArmCount congr 1 ext i simp only [mem_filter, Finset.mem_univ, true_and] cases h : z i with | mk x b => simp exact Prod.ext (hcount false) (hcount true) have hhistMeas : Measurable (fun s : FiniteSample (Fin d × Bool) => finiteSampleHistogram s.points) := by apply measurable_to_countable' intro c rw [MeasurableSpace.measurableSet_iInf] intro n change MeasurableSet ((Sigma.mk n) ⁻¹' {s : FiniteSample (Fin d × Bool) | finiteSampleHistogram s.points = c}) exact (Set.to_countable _).measurableSet rw [hhist, ← Measure.map_map hregroup hhistMeas] rw [finitePoissonSampleLaw_map_histogram] change Measure.map regroup (Measure.pi μ) = _ have hcurry : Measure.map (MeasurableEquiv.curry (Fin d) Bool ℕ) (Measure.pi μ) = Measure.pi (fun k : Fin d => Measure.pi (fun a : Bool => μ (k, a))) := by simpa only [Measure.infinitePi_eq_pi] using (Measure.infinitePi_map_curry (fun k : Fin d => fun a : Bool => μ (k, a))) have hpair (k : Fin d) : Measure.map (fun f : Bool → ℕ => (f false, f true)) (Measure.pi (fun a : Bool => μ (k, a))) = (μ (k, false)).prod (μ (k, true)) := by let e : Bool ≃ Fin 2 := finTwoEquiv.symm let m : Fin 2 → Measure ℕ := fun i => μ (k, finTwoEquiv i) have hreindex : Measure.map (MeasurableEquiv.piCongrLeft (fun _ : Fin 2 => ℕ) e) (Measure.pi (fun a : Bool => μ (k, a))) = Measure.pi m := by simpa [m, e] using Measure.pi_map_piCongrLeft e m have htwo := (measurePreserving_piFinTwo m).map_eq calc _ = Measure.map (MeasurableEquiv.piFinTwo (fun _ : Fin 2 => ℕ)) (Measure.map (MeasurableEquiv.piCongrLeft (fun _ : Fin 2 => ℕ) e) (Measure.pi (fun a : Bool => μ (k, a)))) := by rw [Measure.map_map] · congr 1 · exact (MeasurableEquiv.piFinTwo _).measurable · exact (MeasurableEquiv.piCongrLeft _ e).measurable _ = (μ (k, false)).prod (μ (k, true)) := by rw [hreindex, htwo] simp [m, finTwoEquiv] have hmap : Measure.map regroup (Measure.pi μ) = Measure.pi (fun k : Fin d => (μ (k, false)).prod (μ (k, true))) := by let pair : (Fin d → Bool → ℕ) → Fin d → ℕ × ℕ := fun f k => (f k false, f k true) have hpairMeas : Measurable pair := by fun_prop calc _ = Measure.map pair (Measure.map (MeasurableEquiv.curry (Fin d) Bool ℕ) (Measure.pi μ)) := by rw [Measure.map_map hpairMeas (MeasurableEquiv.curry _ _ _).measurable] rfl _ = Measure.map pair (Measure.pi (fun k : Fin d => Measure.pi (fun a : Bool => μ (k, a)))) := by rw [hcurry] _ = Measure.pi (fun k : Fin d => Measure.map (fun f : Bool → ℕ => (f false, f true)) (Measure.pi (fun a : Bool => μ (k, a)))) := by simpa [pair] using (Measure.pi_map_pi (μ := fun k : Fin d => Measure.pi (fun a : Bool => μ (k, a))) (f := fun _ : Fin d => fun f : Bool → ℕ => (f false, f true)) (fun _ => by fun_prop)) _ = _ := by simp_rw [hpair] exact hmap
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.poisson_arm_cell_count_law · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/PoissonTransport.lean:22 · uses FiniteSample , finitePoissonSampleLaw , groupArmCount
Prefix 1 core · 1 supporting A deterministic prefix of a larger iid sample has the finite product law used by the observed collision-risk theorem. ★ integral_prefix_collision_error_sq

Deterministic iid pilot prefixes

A deterministic prefix of a larger iid sample has the finite product law used by the observed collision-risk theorem. The squared-risk identity records the transport needed by a paper-local pilot estimator.

theorem integral_prefix_collision_error_sq reviewed
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk

Given an observed probability law and finite cell setting, measurable cell, arm, and outcome maps with centers, and sample sizes n ≤ N, the expected squared difference between the collision estimator and the population contrast is the same whether the estimator is computed from the first n observations of N independent draws or from n independent draws.

Formal statement
X :
Ω → κ
A :
Ω → Bool
Y :
Ω → ℝ
center :
Bool → κ → ℝ
hX :
hA :
hY :
n N :
ℕ
hnN :
n ≤ N
(∫ z : Fin N → Ω, (collisionEstimator X A Y (fun i : Fin n => z (castLE hnN i)) - populationContrast μ X center) ^ 2 ∂Measure.pi (fun _ : Fin N => μ))
= ∫ z : Fin n → Ω, (collisionEstimator X A Y z - populationContrast μ X center) ^ 2 ∂Measure.pi (fun _ : Fin n => μ)
Proof (Lean source)
theorem integral_prefix_collision_error_sq {Ω κ : Type} [MeasurableSpace Ω] [Fintype κ] [DecidableEq κ] [MeasurableSpace κ] [MeasurableSingletonClass κ] (μ : Measure Ω) [IsProbabilityMeasure μ] (X : Ω → κ) (A : Ω → Bool) (Y : Ω → ℝ) (center : Bool → κ → ℝ) (hX : Measurable X) (hA : Measurable A) (hY : Measurable Y) {n N : ℕ} (hnN : n ≤ N) : (∫ z : Fin N → Ω, (collisionEstimator X A Y (fun i : Fin n => z (castLE hnN i)) - populationContrast μ X center) ^ 2 ∂Measure.pi (fun _ : Fin N => μ)) = ∫ z : Fin n → Ω, (collisionEstimator X A Y z - populationContrast μ X center) ^ 2 ∂Measure.pi (fun _ : Fin n => μ) := by have hprefix : Measurable (fun z : Fin N → Ω => fun i : Fin n => z (castLE hnN i)) := by fun_prop have herror : Measurable (fun z : Fin n → Ω => (collisionEstimator X A Y z - populationContrast μ X center) ^ 2) := ((measurable_collisionEstimator X A Y hX hA hY).sub measurable_const).pow_const 2 calc _ = ∫ z : Fin n → Ω, (collisionEstimator X A Y z - populationContrast μ X center) ^ 2 ∂(Measure.pi (fun _ : Fin N => μ)).map (fun z : Fin N → Ω => fun i : Fin n => z (castLE hnN i)) := by exact (integral_map hprefix.aemeasurable herror.aestronglyMeasurable).symm _ = _ := by rw [iid_prefix_map μ hnN]
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.integral_prefix_collision_error_sq · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/Prefix.lean:36 · uses collisionEstimator , populationContrast
1 supporting declaration (lemmas, instances)
Risk 1 core · 2 supporting This module combines a design-only usable-occupancy estimate with centered real-mark variance and approximate homogeneity. ★ observed_collision_mse_le

Observed-law collision mean-square risk

This module combines a design-only usable-occupancy estimate with centered real-mark variance and approximate homogeneity. Its estimator and every hypothesis are functions of the observed law alone.

theorem observed_collision_mse_le reviewed
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk

For an overlap margin ε strictly between zero and one half, there is a positive constant C, depending only on ε, such that the following holds for every probability law with a label into a finite set of cells, a Boolean arm label, a real outcome, supplied arm-and-cell centres, an envelope M, a heterogeneity level ρ, and every positive sample size n: if the observed-law assumptions hold with these ε, M and ρ, then under n independent draws the expected squared difference between the cell-count-weighted collision estimator and the population contrast is at most C·M²·(1/n + ρ² + card(κ)/n²), where card(κ) is the number of cells. The observed-law assumptions are occupied-cell overlap at margin ε, centres bounded by M, arm-cell residuals that are centred with second moment at most M², and occupied-cell contrasts within M·ρ of the population contrast.

Formal statement
epsilon :
ℝ
hepsilon :
0 < epsilon
hepsilon_half :
epsilon < 1 / 2
∃ C_epsilon : ℝ,
0 < C_epsilon
conclusion 1
Ω κ :
Type
μ :
X :
Ω → κ
A :
Ω → Bool
Y :
Ω → ℝ
center :
Bool → κ → ℝ
M rho :
ℝ
n :
ℕ
0 < n
ObservedAssumptions μ X A Y center epsilon M rho
(∫ z : Fin n → Ω, (collisionEstimator X A Y z - populationContrast μ X center) ^ 2 ∂Measure.pi (fun _ : Fin n => μ))
≤ C_epsilon * M ^ 2 * (1 / (n : ℝ) + rho ^ 2 + (Fintype.card κ : ℝ) / (n : ℝ) ^ 2)
Proof (Lean source)
theorem observed_collision_mse_le (epsilon : ℝ) (hepsilon : 0 < epsilon) (hepsilon_half : epsilon < 1 / 2) : ∃ C_epsilon : ℝ, 0 < C_epsilon ∧ ∀ (Ω κ : Type) [MeasurableSpace Ω] [Fintype κ] [DecidableEq κ] [MeasurableSpace κ] [MeasurableSingletonClass κ] (μ : Measure Ω) [IsProbabilityMeasure μ] (X : Ω → κ) (A : Ω → Bool) (Y : Ω → ℝ) (center : Bool → κ → ℝ) (M rho : ℝ) (n : ℕ), 0 < n → ObservedAssumptions μ X A Y center epsilon M rho → (∫ z : Fin n → Ω, (collisionEstimator X A Y z - populationContrast μ X center) ^ 2 ∂Measure.pi (fun _ : Fin n => μ)) ≤ C_epsilon * M ^ 2 * (1 / (n : ℝ) + rho ^ 2 + (Fintype.card κ : ℝ) / (n : ℝ) ^ 2) := by -- Apply observed_bad_occupancy_rate and -- observed_reciprocal_occupancy_rate. Combine integral_collision_noise_sq_le and -- integral_designCenter_bias_sq_le with (u+v)^2 ≤ 2u²+2v² and the L2 -- integrability helpers (`collision_sub_target_memLp`, -- `designCenter_sub_target_memLp`, and `occupancyWeightedResidual_memLp_two`). -- If Bbad and Brec are the two occupancy constants and -- K = 16 / (epsilon^2 * (1-epsilon)), choose -- C_epsilon = 2*K*Brec + 8*Bbad + 2. The inequalities -- 0 < epsilon < 1/2 give K > 0. Set R = 1/n + card(κ)/n^2; -- then 2*K*Brec*R + 2*rho^2 + 8*Bbad*R ≤ -- C_epsilon * (R + rho^2), since R and rho^2 are nonnegative. classical obtain ⟨Bbad, hBbad, hbad⟩ := observed_bad_occupancy_rate epsilon hepsilon hepsilon_half obtain ⟨Brec, hBrec, hrec⟩ := observed_reciprocal_occupancy_rate epsilon hepsilon hepsilon_half let K : ℝ := 16 / (epsilon ^ 2 * (1 - epsilon)) have hK : 0 < K := by dsimp [K] apply div_pos (by norm_num) exact mul_pos (sq_pos_of_pos hepsilon) (by linarith) let C_epsilon : ℝ := 2 * K * Brec + 8 * Bbad + 2 have hC : 0 < C_epsilon := by dsimp [C_epsilon] positivity refine ⟨C_epsilon, hC, ?_⟩ intro Ω κ _ _ _ _ _ μ _ X A Y center M rho n hn h let ν : Measure (Fin n → Ω) := Measure.pi (fun _ : Fin n => μ) let R : ℝ := 1 / (n : ℝ) + (Fintype.card κ : ℝ) / (n : ℝ) ^ 2 have hR : 0 ≤ R := by dsimp [R] positivity have hM2 : 0 ≤ M ^ 2 := sq_nonneg M have hoverlap : ∀ a k, 0 < cellMass μ X k → epsilon * cellMass μ X k ≤ armCellMass μ X A a k := by intro a k hk exact h.overlap a k hk have hbad' : (ν {z | usableTotal X A z = 0}).toReal ≤ Bbad * R := by exact hbad Ω κ μ X A n h.X_measurable h.A_measurable hn hoverlap have hrec' : (∫ z : Fin n → Ω, inverseUsableGroupTotal X A z ∂ν) ≤ Brec * R := by exact hrec Ω κ μ X A n h.X_measurable h.A_measurable hn hoverlap have hnoiseLp : MemLp (fun z : Fin n → Ω => collisionEstimator X A Y z - designCenter X A center z) 2 ν := by convert (collision_sub_target_memLp (n := n) μ X A Y center epsilon M rho h).sub (designCenter_sub_target_memLp (n := n) μ X A Y center epsilon M rho h) using 1 funext z dsimp ring have hnoiseInt : Integrable (fun z : Fin n → Ω => (collisionEstimator X A Y z - designCenter X A center z) ^ 2) ν := hnoiseLp.integrable_sq have hbiasInt : Integrable (fun z : Fin n → Ω => (designCenter X A center z - populationContrast μ X center) ^ 2) ν := (designCenter_sub_target_memLp (n := n) μ X A Y center epsilon M rho h).integrable_sq have htargetInt : Integrable (fun z : Fin n → Ω => (collisionEstimator X A Y z - populationContrast μ X center) ^ 2) ν := (collision_sub_target_memLp (n := n) μ X A Y center epsilon M rho h).integrable_sq have hsplit : (∫ z : Fin n → Ω, (collisionEstimator X A Y z - populationContrast μ X center) ^ 2 ∂ν) ≤ 2 * (∫ z : Fin n → Ω, (collisionEstimator X A Y z - designCenter X A center z) ^ 2 ∂ν) + 2 * (∫ z : Fin n → Ω, (designCenter X A center z - populationContrast μ X center) ^ 2 ∂ν) := by have hpoint : ∀ z : Fin n → Ω, (collisionEstimator X A Y z - populationContrast μ X center) ^ 2 ≤ 2 * (collisionEstimator X A Y z - designCenter X A center z) ^ 2 + 2 * (designCenter X A center z - populationContrast μ X center) ^ 2 := by intro z calc _ = ((collisionEstimator X A Y z - designCenter X A center z) + (designCenter X A center z - populationContrast μ X center)) ^ 2 := by ring _ ≤ 2 * ((collisionEstimator X A Y z - designCenter X A center z) ^ 2 + (designCenter X A center z - populationContrast μ X center) ^ 2) := add_sq_le _ = _ := by ring have hright : Integrable (fun z : Fin n → Ω => 2 * (collisionEstimator X A Y z - designCenter X A center z) ^ 2 + 2 * (designCenter X A center z - populationContrast μ X center) ^ 2) ν := (hnoiseInt.const_mul 2).add (hbiasInt.const_mul 2) have hmono := integral_mono htargetInt hright hpoint rw [integral_add (hnoiseInt.const_mul 2) (hbiasInt.const_mul 2), integral_const_mul, integral_const_mul] at hmono exact hmono have hnoise := integral_collision_noise_sq_le (n := n) μ X A Y center epsilon M rho h have hbias := integral_designCenter_bias_sq_le (n := n) μ X A Y center epsilon M rho h have hbound : (∫ z : Fin n → Ω, (collisionEstimator X A Y z - populationContrast μ X center) ^ 2 ∂ν) ≤ M ^ 2 * (2 * K * Brec * R + 2 * rho ^ 2 + 8 * Bbad * R) := by calc _ ≤ 2 * (∫ z : Fin n → Ω, (collisionEstimator X A Y z - designCenter X A center z) ^ 2 ∂ν) + 2 * (∫ z : Fin n → Ω, (designCenter X A center z - populationContrast μ X center) ^ 2 ∂ν) := hsplit _ ≤ 2 * (K * M ^ 2 * (∫ z : Fin n → Ω, inverseUsableGroupTotal X A z ∂ν)) + 2 * (M ^ 2 * (rho ^ 2 + 4 * (ν {z | usableTotal X A z = 0}).toReal)) := by gcongr _ ≤ 2 * (K * M ^ 2 * (Brec * R)) + 2 * (M ^ 2 * (rho ^ 2 + 4 * (Bbad * R))) := by gcongr _ = M ^ 2 * (2 * K * Brec * R + 2 * rho ^ 2 + 8 * Bbad * R) := by ring have hscalar : 2 * K * Brec * R + 2 * rho ^ 2 + 8 * Bbad * R ≤ C_epsilon * (1 / (n : ℝ) + rho ^ 2 + (Fintype.card κ : ℝ) / (n : ℝ) ^ 2) := by have hcoef : 0 ≤ 2 * K * Brec + 8 * Bbad := by positivity dsimp [C_epsilon, R] at * nlinarith [mul_nonneg hcoef (sq_nonneg rho)] calc _ ≤ M ^ 2 * (2 * K * Brec * R + 2 * rho ^ 2 + 8 * Bbad * R) := hbound _ ≤ M ^ 2 * (C_epsilon * (1 / (n : ℝ) + rho ^ 2 + (Fintype.card κ : ℝ) / (n : ℝ) ^ 2)) := mul_le_mul_of_nonneg_left hscalar hM2 _ = _ := by ring
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.observed_collision_mse_le · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/Risk.lean:98 · uses ObservedAssumptions , collisionEstimator , populationContrast
2 supporting declarations (lemmas, instances)
Risk­Algebra 1 core · 7 supporting The identities and elementary bounds here separate outcome noise from the matched-cell design center. ★ collision_sub_target_memLp

Real-mark collision-risk algebra

The identities and elementary bounds here separate outcome noise from the matched-cell design center. They use only an observed law and include the zero-usable fallback and population-null cells.

theorem collision_sub_target_memLp reviewed
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk

Given a sample size, observed probability law, finite cell setting, observed maps, centers, and envelope parameters and the observed-law assumptions, the collision error has a finite second moment.

Formal statement
Ω :
Type
shared
κ :
Type
shared
n :
ℕ
X :
Ω → κ
A :
Ω → Bool
Y :
Ω → ℝ
center :
Bool → κ → ℝ
epsilon M rho :
ℝ
h :
ObservedAssumptions μ X A Y center epsilon M rho
MemLp (fun z : Fin n → Ω => collisionEstimator X A Y z - populationContrast μ X center) 2 (Measure.pi (fun _ : Fin n => μ))
Proof (Lean source)
theorem collision_sub_target_memLp {n : ℕ} (μ : Measure Ω) [IsProbabilityMeasure μ] (X : Ω → κ) (A : Ω → Bool) (Y : Ω → ℝ) (center : Bool → κ → ℝ) (epsilon M rho : ℝ) (h : ObservedAssumptions μ X A Y center epsilon M rho) : MemLp (fun z : Fin n → Ω => collisionEstimator X A Y z - populationContrast μ X center) 2 (Measure.pi (fun _ : Fin n => μ)) := by -- Rewrite estimator - designCenter with the preceding identity; use -- occupancyWeightedResidual_memLp_two and add design L2. have hres := occupancyWeightedResidual_memLp_two (n := n) μ X A Y center h.X_measurable h.A_measurable h.Y_measurable h.residual_L2 have hdesign := designCenter_sub_target_memLp (n := n) μ X A Y center epsilon M rho h convert hres.add hdesign using 1 funext z change collisionEstimator X A Y z - populationContrast μ X center = occupancyWeightedResidual μ X A Y center z + (designCenter X A center z - populationContrast μ X center) rw [← collision_sub_designCenter_eq_residual μ X A Y center z] ring
Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.collision_sub_target_memLp · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/RiskAlgebra.lean:323 · uses ObservedAssumptions , collisionEstimator , populationContrast
7 supporting declarations (lemmas, instances)
  • center_envelope_nonneg theorem — The observed arm-center envelope itself forces the real scale to be nonnegative under a probability law, since some measurable cell is inhabited.
    Ω :
    Type
    shared
    κ :
    Type
    shared
    X :
    Ω → κ
    A :
    Ω → Bool
    Y :
    Ω → ℝ
    center :
    Bool → κ → ℝ
    epsilon M rho :
    ℝ
    h :
    ObservedAssumptions μ X A Y center epsilon M rho
    0 ≤ M
    Proof (Lean source)
    theorem center_envelope_nonneg (μ : Measure Ω) [IsProbabilityMeasure μ] (X : Ω → κ) (A : Ω → Bool) (Y : Ω → ℝ) (center : Bool → κ → ℝ) (epsilon M rho : ℝ) (h : ObservedAssumptions μ X A Y center epsilon M rho) : 0 ≤ M := by -- A probability law makes Ω, hence κ via X, nonempty. Then use -- 0 ≤ |center a k| ≤ M. obtain ⟨ω⟩ := nonempty_of_isProbabilityMeasure μ exact le_trans (abs_nonneg _) (h.center_envelope true (X ω))
    Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.center_envelope_nonneg · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/RiskAlgebra.lean:23
  • populationContrast_abs_le theorem — The observed population contrast has magnitude at most twice the arm-center envelope under a probability law.
    Ω :
    Type
    shared
    κ :
    Type
    shared
    X :
    Ω → κ
    A :
    Ω → Bool
    Y :
    Ω → ℝ
    center :
    Bool → κ → ℝ
    epsilon M rho :
    ℝ
    h :
    ObservedAssumptions μ X A Y center epsilon M rho
    |populationContrast μ X center| ≤ 2 * M
    Proof (Lean source)
    theorem populationContrast_abs_le (μ : Measure Ω) [IsProbabilityMeasure μ] (X : Ω → κ) (A : Ω → Bool) (Y : Ω → ℝ) (center : Bool → κ → ℝ) (epsilon M rho : ℝ) (h : ObservedAssumptions μ X A Y center epsilon M rho) : |populationContrast μ X center| ≤ 2 * M := by -- Sum the cell masses to one; each contrast has absolute value at most 2M. classical have hmass : (∑ k : κ, cellMass μ X k) = 1 := by have hsum := sum_measureReal_preimage_singleton (μ := μ) (s := (Finset.univ : Finset κ)) (f := X) (hf := by intro k hk; exact h.X_measurable (measurableSet_singleton k)) (h := by intro k hk exact ne_of_lt <| lt_of_le_of_lt (measure_mono (Set.subset_univ _)) (by simp [IsProbabilityMeasure.measure_univ])) simpa [cellMass, groupEvent, Measure.real, preimage] using hsum have hM : 0 ≤ M := center_envelope_nonneg μ X A Y center epsilon M rho h have hbound (k : κ) : |cellMass μ X k * (center true k - center false k)| ≤ cellMass μ X k * (2 * M) := by have hcell : 0 ≤ cellMass μ X k := ENNReal.toReal_nonneg have htrue := h.center_envelope true k have hfalse := h.center_envelope false k rw [abs_mul, abs_of_nonneg hcell] apply mul_le_mul_of_nonneg_left _ hcell rw [abs_le] constructor <;> rcases abs_le.mp htrue with ⟨htl, htu⟩ <;> rcases abs_le.mp hfalse with ⟨hfl, hfu⟩ <;> linarith calc |populationContrast μ X center| = |∑ k : κ, cellMass μ X k * (center true k - center false k)| := rfl _ ≤ ∑ k : κ, |cellMass μ X k * (center true k - center false k)| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ k : κ, cellMass μ X k * (2 * M) := Finset.sum_le_sum (by intro k hk; exact hbound k) _ = 2 * M := by rw [← Finset.sum_mul, hmass, one_mul]
    Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.populationContrast_abs_le · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/RiskAlgebra.lean:35
  • usable_supported_ae theorem — Almost every iid sample places observations only in cells of positive observed population mass; hence every empirically matched cell is supported. The finite-cell hypothesis is essential: an atomless cell law gives zero mass to every realized singleton. Prove the claim by taking the finite union of null cell events, then the finite union over sample coordinates.
    Ω :
    Type
    shared
    κ :
    Type
    shared
    X :
    Ω → κ
    A :
    Ω → Bool
    n :
    ℕ
    ∀ᵐ z ∂Measure.pi (fun _ : Fin n => μ), ∀ k, matchedCell X A z k → 0 < cellMass μ X k
    Proof (Lean source)
    theorem usable_supported_ae (μ : Measure Ω) [IsProbabilityMeasure μ] (X : Ω → κ) (A : Ω → Bool) (n : ℕ) : ∀ᵐ z ∂Measure.pi (fun _ : Fin n => μ), ∀ k, matchedCell X A z k → 0 < cellMass μ X k := by classical have hcell (k : κ) (hk : cellMass μ X k = 0) : ∀ᵐ ω ∂μ, X ω ≠ k := by have hfinite : μ (groupEvent X k) ≠ ⊤ := by exact ne_of_lt (lt_of_le_of_lt (measure_mono (Set.subset_univ _)) (by simp [IsProbabilityMeasure.measure_univ])) have hnull : μ (groupEvent X k) = 0 := (measureReal_eq_zero_iff (s := groupEvent X k)).mp (by simpa [cellMass, Measure.real] using hk) exact ae_iff.mpr (by simpa [groupEvent] using hnull) have hall : ∀ᵐ ω ∂μ, ∀ k : κ, X ω = k → 0 < cellMass μ X k := by rw [Filter.eventually_all] intro k by_cases hk : cellMass μ X k = 0 · exact (hcell k hk).mono (by intro ω hω heq; exact False.elim (hω heq)) · filter_upwards [] with ω intro _ exact lt_of_le_of_ne ENNReal.toReal_nonneg (Ne.symm hk) have hcoords : ∀ᵐ z ∂Measure.pi (fun _ : Fin n => μ), ∀ i : Fin n, ∀ k : κ, X (z i) = k → 0 < cellMass μ X k := (Filter.eventually_all.2 fun i => (Measure.tendsto_eval_ae_ae (μ := fun _ : Fin n => μ) (i := i)).eventually hall) filter_upwards [hcoords] with z hz k hk obtain ⟨i, hi⟩ : ∃ i : Fin n, X (z i) = k := by have hcount : 0 < groupArmCount X A z false k := hk.1 obtain ⟨i, hi⟩ := Finset.card_pos.mp hcount exact ⟨i, (Finset.mem_filter.mp hi).2.1⟩ exact hz i k hi
    Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.usable_supported_ae · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/RiskAlgebra.lean:73
  • collision_sub_designCenter_eq_residual theorem — The collision estimator minus its design center is exactly the occupancy-weighted difference of guarded arm-cell residual means, even when the usable total is zero.
    Ω :
    Type
    shared
    κ :
    Type
    shared
    n :
    ℕ
    μ :
    X :
    Ω → κ
    A :
    Ω → Bool
    Y :
    Ω → ℝ
    center :
    Bool → κ → ℝ
    z :
    Fin n → Ω
    collisionEstimator X A Y z - designCenter X A center z
    = occupancyWeightedResidual μ X A Y center z
    Proof (Lean source)
    theorem collision_sub_designCenter_eq_residual {n : ℕ} (μ : Measure Ω) (X : Ω → κ) (A : Ω → Bool) (Y : Ω → ℝ) (center : Bool → κ → ℝ) (z : Fin n → Ω) : collisionEstimator X A Y z - designCenter X A center z = occupancyWeightedResidual μ X A Y center z := by classical have hsum (a : Bool) (k : κ) : armSum X A Y z a k = armResidualSum X A Y center z a k + (groupArmCount X A z a k : ℝ) * center a k := by simp only [armSum, armResidualSum, supportedArmGroupResidual, groupArmCount] rw [Finset.card_eq_sum_ones] push_cast rw [Finset.sum_mul] simp_rw [Finset.sum_filter] rw [← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro i hi by_cases h : X (z i) = k ∧ A (z i) = a <;> simp [armGroupEvent, armGroupResidual, h] have hmean (a : Bool) (k : κ) (hc : 0 < groupArmCount X A z a k) : armMean X A Y z a k = armResidualMean X A Y center z a k + center a k := by have hne : (groupArmCount X A z a k : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt hc) unfold armMean armResidualMean rw [if_pos hc, if_pos hc] change (groupArmCount X A z a k : ℝ)⁻¹ * armSum X A Y z a k = (groupArmCount X A z a k : ℝ)⁻¹ * armResidualSum X A Y center z a k + center a k rw [hsum] field_simp by_cases ht : 0 < usableTotal X A z · unfold collisionEstimator designCenter occupancyWeightedResidual simp only [ht, ↓reduceIte, div_eq_inv_mul] rw [← mul_sub] congr 1 rw [← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro k hk by_cases hu : matchedCell X A z k · simp only [hu, ↓reduceIte] rw [hmean true k hu.2, hmean false k hu.1] ring · simp [hu] · unfold collisionEstimator designCenter occupancyWeightedResidual simp [ht]
    Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.collision_sub_designCenter_eq_residual · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/RiskAlgebra.lean:112
  • designCenter_bias_sq_le theorem — Approximate homogeneity bounds squared design bias on supported samples; if no cell is usable, the zero fallback incurs at most four envelope squares.
    Ω :
    Type
    shared
    κ :
    Type
    shared
    n :
    ℕ
    X :
    Ω → κ
    A :
    Ω → Bool
    Y :
    Ω → ℝ
    center :
    Bool → κ → ℝ
    epsilon M rho :
    ℝ
    h :
    ObservedAssumptions μ X A Y center epsilon M rho
    z :
    Fin n → Ω
    hsupport :
    ∀ k
    if
    matchedCell X A z k
    then
    0 < cellMass μ X k
    (designCenter X A center z - populationContrast μ X center) ^ 2
    ≤ M ^ 2 * (rho ^ 2 + if usableTotal X A z = 0 then 4 else 0)
    Proof (Lean source)
    theorem designCenter_bias_sq_le {n : ℕ} (μ : Measure Ω) [IsProbabilityMeasure μ] (X : Ω → κ) (A : Ω → Bool) (Y : Ω → ℝ) (center : Bool → κ → ℝ) (epsilon M rho : ℝ) (h : ObservedAssumptions μ X A Y center epsilon M rho) (z : Fin n → Ω) (hsupport : ∀ k, matchedCell X A z k → 0 < cellMass μ X k) : (designCenter X A center z - populationContrast μ X center) ^ 2 ≤ M ^ 2 * (rho ^ 2 + if usableTotal X A z = 0 then 4 else 0) := by -- Positive total: use a nonnegative weighted average of deviations. -- Zero total: designCenter=0 and populationContrast_abs_le gives 4M². classical let p := populationContrast μ X center let B := M * rho let w : κ → ℝ := fun k => if matchedCell X A z k then (groupCount X A z k : ℝ) else 0 let d : κ → ℝ := fun k => center true k - center false k - p have htotal : (∑ k : κ, w k) = (usableTotal X A z : ℝ) := by dsimp [w] exact_mod_cast (show (∑ k : κ, if matchedCell X A z k then groupCount X A z k else 0) = usableTotal X A z from rfl) by_cases ht : 0 < usableTotal X A z · have htR : (0 : ℝ) < (usableTotal X A z : ℝ) := by exact_mod_cast ht have hnum : (∑ k : κ, w k * d k) = (∑ k : κ, if matchedCell X A z k then (groupCount X A z k : ℝ) * (center true k - center false k) else 0) - (usableTotal X A z : ℝ) * p := by rw [← htotal, Finset.sum_mul, ← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro k hk by_cases hu : matchedCell X A z k <;> simp [w, d, hu]; ring have hcenter : designCenter X A center z - p = (∑ k : κ, w k * d k) / (usableTotal X A z : ℝ) := by rw [hnum] unfold designCenter simp only [ht, ↓reduceIte] field_simp have hterm (k : κ) : |w k * d k| ≤ w k * B := by by_cases hu : matchedCell X A z k · have hc := h.homogeneity k (hsupport k hu) dsimp [w, d, B] simp only [hu, ↓reduceIte, abs_mul] rw [abs_of_nonneg (show 0 ≤ (groupCount X A z k : ℝ) by positivity)] simpa [p] using mul_le_mul_of_nonneg_left hc (show 0 ≤ (groupCount X A z k : ℝ) by positivity) · simp [w, hu] have hbound : |∑ k : κ, w k * d k| ≤ (usableTotal X A z : ℝ) * B := by calc |∑ k : κ, w k * d k| ≤ ∑ k : κ, |w k * d k| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ k : κ, w k * B := Finset.sum_le_sum (by intro k hk; exact hterm k) _ = (usableTotal X A z : ℝ) * B := by rw [← Finset.sum_mul, htotal] have habs : |designCenter X A center z - p| ≤ B := by rw [hcenter, abs_div, abs_of_pos htR] exact (div_le_iff₀ htR).2 (by simpa [mul_comm] using hbound) have hB : 0 ≤ B := le_trans (abs_nonneg _) habs have hsq := (sq_le_sq₀ (abs_nonneg _) hB).2 habs rw [sq_abs] at hsq simpa [p, B, (Nat.ne_of_gt ht), mul_pow] using hsq · have ht0 : usableTotal X A z = 0 := by omega have hp := populationContrast_abs_le μ X A Y center epsilon M rho h have hM : 0 ≤ M := center_envelope_nonneg μ X A Y center epsilon M rho h have hsq := (sq_le_sq₀ (abs_nonneg _) (by positivity : 0 ≤ 2 * M)).2 hp rw [sq_abs] at hsq have hdesign : designCenter X A center z = 0 := by simp [designCenter, ht0] rw [hdesign, ht0] simp only [ite_true, zero_sub, neg_sq] nlinarith [mul_nonneg (sq_nonneg M) (sq_nonneg rho)]
    Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.designCenter_bias_sq_le · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/RiskAlgebra.lean:164
  • measurable_collisionEstimator theorem — Measurable cell, arm, and outcome maps make the guarded collision estimator measurable on every finite iid sample space.
    Ω :
    Type
    shared
    κ :
    Type
    shared
    n :
    ℕ
    X :
    Ω → κ
    A :
    Ω → Bool
    Y :
    Ω → ℝ
    hX :
    hA :
    hY :
    Proof (Lean source)
    @[fun_prop] theorem measurable_collisionEstimator {n : ℕ} (X : Ω → κ) (A : Ω → Bool) (Y : Ω → ℝ) (hX : Measurable X) (hA : Measurable A) (hY : Measurable Y) : Measurable (collisionEstimator (n := n) X A Y) := by classical have heq : collisionEstimator (n := n) X A Y = occupancyWeightedResidual (n := n) (0 : Measure Ω) X A Y (fun _ _ => 0) := by funext z unfold collisionEstimator occupancyWeightedResidual split_ifs <;> simp only [armMean, div_eq_inv_mul] rw [heq] exact measurable_occupancyWeightedResidual (0 : Measure Ω) X A Y (fun _ _ => 0) hX hA hY
    Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.measurable_collisionEstimator · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/RiskAlgebra.lean:235
  • designCenter_sub_target_memLp theorem — The centered design statistic has a finite second moment under bounded arm-cell centers and an observed probability law.
    Ω :
    Type
    shared
    κ :
    Type
    shared
    n :
    ℕ
    X :
    Ω → κ
    A :
    Ω → Bool
    Y :
    Ω → ℝ
    center :
    Bool → κ → ℝ
    epsilon M rho :
    ℝ
    h :
    ObservedAssumptions μ X A Y center epsilon M rho
    MemLp (fun z : Fin n → Ω => designCenter X A center z - populationContrast μ X center) 2 (Measure.pi (fun _ : Fin n => μ))
    Proof (Lean source)
    theorem designCenter_sub_target_memLp {n : ℕ} (μ : Measure Ω) [IsProbabilityMeasure μ] (X : Ω → κ) (A : Ω → Bool) (Y : Ω → ℝ) (center : Bool → κ → ℝ) (epsilon M rho : ℝ) (h : ObservedAssumptions μ X A Y center epsilon M rho) : MemLp (fun z : Fin n → Ω => designCenter X A center z - populationContrast μ X center) 2 (Measure.pi (fun _ : Fin n => μ)) := by -- The design center is a convex average of contrasts bounded by 2M, -- or zero. Combine with populationContrast_abs_le and MemLp.of_bound. classical have hM : 0 ≤ M := center_envelope_nonneg μ X A Y center epsilon M rho h have hmeas : Measurable (designCenter (n := n) X A center) := by unfold designCenter have ht := measurable_usableGroupTotal (n := n) X A h.X_measurable h.A_measurable apply Measurable.ite (measurableSet_lt measurable_const ht) · apply Measurable.div · apply Finset.measurable_sum intro k hk apply Measurable.ite (measurableSet_usableGroup X A h.X_measurable h.A_measurable k) · exact ((Measurable.of_discrete : Measurable fun m : ℕ => (m : ℝ)).comp (measurable_groupCount X A h.X_measurable h.A_measurable k)).mul measurable_const · exact measurable_const · exact (Measurable.of_discrete : Measurable fun m : ℕ => (m : ℝ)).comp ht · exact measurable_const have hbound (z : Fin n → Ω) : |designCenter X A center z| ≤ 2 * M := by by_cases ht : 0 < usableTotal X A z · have htR : (0 : ℝ) < usableTotal X A z := by exact_mod_cast ht have hterm (k : κ) : |(if matchedCell X A z k then (groupCount X A z k : ℝ) * (center true k - center false k) else 0)| ≤ (if matchedCell X A z k then (groupCount X A z k : ℝ) else 0) * (2 * M) := by by_cases hk : matchedCell X A z k · simp only [hk, ↓reduceIte, abs_mul] rw [abs_of_nonneg (by positivity : 0 ≤ (groupCount X A z k : ℝ))] have hc : |center true k - center false k| ≤ 2 * M := by rw [abs_le] constructor <;> rcases abs_le.mp (h.center_envelope true k) with ⟨htl, htu⟩ <;> rcases abs_le.mp (h.center_envelope false k) with ⟨hfl, hfu⟩ <;> linarith exact mul_le_mul_of_nonneg_left hc (by positivity) · simp [hk] have hsum : |∑ k : κ, if matchedCell X A z k then (groupCount X A z k : ℝ) * (center true k - center false k) else 0| ≤ (usableTotal X A z : ℝ) * (2 * M) := by calc _ ≤ ∑ k : κ, |if matchedCell X A z k then (groupCount X A z k : ℝ) * (center true k - center false k) else 0| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ k : κ, (if matchedCell X A z k then (groupCount X A z k : ℝ) else 0) * (2 * M) := Finset.sum_le_sum (by intro k hk; exact hterm k) _ = (usableTotal X A z : ℝ) * (2 * M) := by rw [← Finset.sum_mul] congr 1 exact_mod_cast (show (∑ k : κ, if matchedCell X A z k then groupCount X A z k else 0) = usableTotal X A z from rfl) unfold designCenter simp only [ht, ↓reduceIte, abs_div, abs_of_pos htR] exact (div_le_iff₀ htR).2 (by simpa [mul_comm] using hsum) · have ht0 : usableTotal X A z = 0 := by omega simp [designCenter, ht0, hM] have hp := populationContrast_abs_le μ X A Y center epsilon M rho h apply MemLp.of_bound (hmeas.sub measurable_const).aestronglyMeasurable (4 * M) filter_upwards [] with z rw [Real.norm_eq_abs] exact (abs_sub _ _).trans (by linarith [hbound z])
    Causalean.Stat.Sample.OccupancyWeightedMean.ObservedRisk.designCenter_sub_target_memLp · Causalean/Stat/Sample/OccupancyWeightedMean/ObservedRisk/RiskAlgebra.lean:251