Stat.Quantile.Conditional­Marked­Subsample­Dkw

Boolean-marked subsample empirical-CDF concentration: exact mark-word conditioning, selected-coordinate iid laws, finite conditional aggregation, and DKW-style tail lifting.

Basic 12 core · 7 supporting This module defines exact mark words, their selected coordinates, and the empirical CDF obtained after retaining one Boolean arm. ★ selectedCDFBadEvent_inter_wordEvent

Boolean-marked finite samples

This module defines exact mark words, their selected coordinates, and the empirical CDF obtained after retaining one Boolean arm. The definitions are deterministic and form the reindexing layer for conditional probability arguments in the companion modules.

def selectedIndices reviewed
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw

For a Boolean word and a requested mark, the selected positions are the finite set of coordinates carrying that mark, as given by filtering all coordinates.

Definition (Lean source)
n :
w :
Fin n → Bool
a :
selectedIndices w a :
by classical exact Finset.univ.filter fun i => w i = a
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw.selectedIndices · Causalean/Stat/Quantile/ConditionalMarkedSubsampleDkw/Basic.lean:18
def selectedWordCount reviewed
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw

For a Boolean word and a requested mark, the selected count is the number of its selected positions, given by their cardinality.

Definition (Lean source)
n :
w :
Fin n → Bool
a :
selectedWordCount w a :
(selectedIndices w a).card
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw.selectedWordCount · Causalean/Stat/Quantile/ConditionalMarkedSubsampleDkw/Basic.lean:24
def selectedIndex reviewed
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw

For a Boolean word and a requested mark, the selected-coordinate embedding enumerates the selected positions in their original order, using the ordered finite-set enumeration.

Definition (Lean source)
n :
w :
Fin n → Bool
a :
selectedIndex w a :
(selectedIndices w a).orderEmbOfFin rfl
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw.selectedIndex · Causalean/Stat/Quantile/ConditionalMarkedSubsampleDkw/Basic.lean:29 · uses selectedWordCount
def wordEvent reviewed
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw

For a marked sample and a Boolean word, the exact-word event is the set of outcomes whose complete mark vector equals that word.

Definition (Lean source)
Ω :
Type*
n :
Z :
Fin n → Ω → Bool × ℝ
w :
Fin n → Bool
wordEvent Z w :
Set Ω
{ω | ∀ i, (Z i ω).1 = w i}
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw.wordEvent · Causalean/Stat/Quantile/ConditionalMarkedSubsampleDkw/Basic.lean:67
def selectedCount reviewed
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw

For a marked sample, a requested mark, and a sample outcome, the selected count is the number of observed coordinates carrying that mark.

Definition (Lean source)
Ω :
Type*
n :
Z :
Fin n → Ω → Bool × ℝ
a :
ω :
Ω
selectedCount Z a ω :
by classical exact (Finset.univ.filter fun i => (Z i ω).1 = a).card
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw.selectedCount · Causalean/Stat/Quantile/ConditionalMarkedSubsampleDkw/Basic.lean:105
def selectedOutcomes reviewed
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw

For a marked sample, a Boolean word, and a requested mark, the selected outcome vector takes the outcome component at each reindexed selected coordinate.

Definition (Lean source)
Ω :
Type*
n :
Z :
Fin n → Ω → Bool × ℝ
w :
Fin n → Bool
a :
selectedOutcomes Z w a :
Ω → Fin (selectedWordCount w a) → ℝ
fun ω j => (Z (selectedIndex w a j) ω).2
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw.selectedOutcomes · Causalean/Stat/Quantile/ConditionalMarkedSubsampleDkw/Basic.lean:126 · uses selectedWordCount
def empiricalCDFVec reviewed
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw

For a finite real vector and a threshold, the vector empirical CDF is the normalized sum of lower-ray indicators. For the empty vector the normalizing inverse is zero by convention, so the value is zero.

Definition (Lean source)
m :
x :
Fin m → ℝ
y :
empiricalCDFVec x y :
(m : ℝ)⁻¹ * ∑ i, cdfStat y (x i)
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw.empiricalCDFVec · Causalean/Stat/Quantile/ConditionalMarkedSubsampleDkw/Basic.lean:133
def selectedEmpiricalCDF reviewed
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw

For a marked sample, a requested mark, a sample outcome, and a threshold, the selected empirical CDF is the lower-ray count in the selected arm divided by its observed size. When the selected arm is empty the inverse size is zero by convention and the value is zero; the bad event below requires a nonempty arm.

Definition (Lean source)
Ω :
Type*
n :
Z :
Fin n → Ω → Bool × ℝ
a :
ω :
Ω
y :
selectedEmpiricalCDF Z a ω y :
by classical exact (selectedCount Z a ω : ℝ)⁻¹ * ∑ i ∈ Finset.univ.filter (fun i => (Z i ω).1 = a), cdfStat y (Z i ω).2
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw.selectedEmpiricalCDF · Causalean/Stat/Quantile/ConditionalMarkedSubsampleDkw/Basic.lean:139
def uniformCDFDeviation reviewed
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw

For a measure on the real line and a finite real vector, the uniform empirical-CDF deviation is the supremum over thresholds of the absolute empirical-minus-population CDF difference. No probability assumption is made here; for a probability law, as assumed by the measurability and tail results, the differences are bounded and this is the usual uniform deviation, while an unbounded family has real supremum zero by convention.

Definition (Lean source)
m :
ρ :
x :
Fin m → ℝ
uniformCDFDeviation ρ x :
sSup (Set.range fun y : ℝ => |empiricalCDFVec x y - cdf ρ y|)
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw.uniformCDFDeviation · Causalean/Stat/Quantile/ConditionalMarkedSubsampleDkw/Basic.lean:166
def fixedCDFBadSet reviewed
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw

For a measure on the real line (a population probability law in the results using it) and a deviation radius, the fixed-size bad set is the set of vectors whose uniform empirical-CDF deviation exceeds that radius.

Definition (Lean source)
m :
ρ :
radius :
fixedCDFBadSet ρ radius :
Set (Fin m → ℝ)
{x | uniformCDFDeviation ρ x > radius}
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw.fixedCDFBadSet · Causalean/Stat/Quantile/ConditionalMarkedSubsampleDkw/Basic.lean:174
def selectedCDFBadEvent reviewed
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw

For a marked sample, a requested mark, a measure on the real line (a population probability law in the results using it), and a count-indexed radius, the selected-sample bad event is the event that the selected arm is nonempty and its uniform deviation exceeds the radius at its observed size.

Definition (Lean source)
Ω :
Type*
n :
Z :
Fin n → Ω → Bool × ℝ
a :
ρ :
radius :
ℕ → ℝ
selectedCDFBadEvent Z a ρ radius :
Set Ω
{ω | selectedCount Z a ω > 0 ∧ sSup (Set.range fun y : ℝ => |selectedEmpiricalCDF Z a ω y - cdf ρ y|) > radius (selectedCount Z a ω)}
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw.selectedCDFBadEvent · Causalean/Stat/Quantile/ConditionalMarkedSubsampleDkw/Basic.lean:180
lemma selectedCDFBadEvent_inter_wordEvent reviewed
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw

Given a marked sample, a requested mark, a population law, a count-indexed radius, a Boolean word, and a positive selected count for that word, intersecting the selected bad event with its exact-word event equals the reindexed fixed-size bad event intersected with that word event.

Formal statement
Ω :
Type*
n :
Z :
Fin n → Ω → Bool × ℝ
a :
ρ :
radius :
ℕ → ℝ
w :
Fin n → Bool
hw :
selectedCDFBadEvent Z a ρ radius ∩ wordEvent Z w
= (selectedOutcomes Z w a) ⁻¹' fixedCDFBadSet ρ (radius (selectedWordCount w a)) ∩ wordEvent Z w
Proof (Lean source)
lemma selectedCDFBadEvent_inter_wordEvent {Ω : Type*} {n : ℕ} (Z : Fin n → Ω → Bool × ℝ) (a : Bool) (ρ : Measure ℝ) (radius : ℕ → ℝ) (w : Fin n → Bool) (hw : 0 < selectedWordCount w a) : selectedCDFBadEvent Z a ρ radius ∩ wordEvent Z w = (selectedOutcomes Z w a) ⁻¹' fixedCDFBadSet ρ (radius (selectedWordCount w a)) ∩ wordEvent Z w := by -- Extensionality reduces this to the count identity and pointwise empirical-CDF reindexing. ext ω constructor · rintro ⟨⟨_, hbad⟩, hω⟩ refine ⟨?_, hω⟩ simpa [fixedCDFBadSet, uniformCDFDeviation, selectedCount_eq_on_wordEvent Z a w hω, empiricalCDFVec_selectedOutcomes_eq Z a w hω] using hbad · rintro ⟨hbad, hω⟩ refine ⟨⟨?_, ?_⟩, hω⟩ · simpa [selectedCount_eq_on_wordEvent Z a w hω] using hw · simpa [fixedCDFBadSet, uniformCDFDeviation, selectedCount_eq_on_wordEvent Z a w hω, empiricalCDFVec_selectedOutcomes_eq Z a w hω] using hbad
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw.selectedCDFBadEvent_inter_wordEvent · Causalean/Stat/Quantile/ConditionalMarkedSubsampleDkw/Basic.lean:189 · uses fixedCDFBadSet , selectedCDFBadEvent , selectedOutcomes , selectedWordCount , wordEvent
7 supporting declarations (lemmas, instances)
Conditional­Law 3 core · 6 supporting This module conditions a finite i.i.d. ★ selectedOutcomes_conditionalLaw

Conditional law of a Boolean-marked subsample

This module conditions a finite i.i.d. family of marked real observations on its complete Boolean word. It proves that the coordinates selected by a fixed mark, reindexed in their original order, have the expected finite product law.

structure MarkedIID reviewed
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw

A finite marked iid experiment packages the marked observation family, its coordinatewise measurability, mutual independence, and the common marginal law.

Definition (Lean source)
Ω :
n :
μ :
ν :
Measure (Bool × ℝ)
Z :
Fin n → Ω → Bool × ℝ
measurable :
∀ i, Measurable (Z i)
indep :
iIndepFun Z μ
law :
∀ i, μ.map (Z i) = ν
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw.MarkedIID · Causalean/Stat/Quantile/ConditionalMarkedSubsampleDkw/ConditionalLaw.lean:18
structure BooleanMarkFactorization reviewed
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw

A Boolean mark factorization packages a positive requested-mark mass and the identity expressing each marked outcome-set mass as that mass times the outcome law.

Definition (Lean source)
ν :
Measure (Bool × ℝ)
a :
e :
ℝ≥0∞
ρ :
positive :
e ≠ 0
joint :
∀ B : Set
then
ν {z | z.1 = a ∧ z.2 ∈ B} = e * ρ B
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw.BooleanMarkFactorization · Causalean/Stat/Quantile/ConditionalMarkedSubsampleDkw/ConditionalLaw.lean:27
theorem selectedOutcomes_conditionalLaw reviewed
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw.MarkedIID

Given a finite marked iid experiment, a requested mark, its mass, a selected-outcome law, a Boolean mark factorization, a Boolean word, and positive probability for that word, the reindexed selected outcome vector conditioned on the word has the finite iid product law with marginal ρ.

Formal statement
Ω :
n :
μ :
ν :
Measure (Bool × ℝ)
S :
MarkedIID Ω n μ ν
a :
e :
ℝ≥0∞
hfac :
w :
Fin n → Bool
hw :
μ (wordEvent S.Z w) ≠ 0
Measure.map (selectedOutcomes S.Z w a) μ[|wordEvent S.Z w]
= Measure.pi (fun _ : Fin (selectedWordCount w a) => ρ)
Proof (Lean source)
theorem MarkedIID.selectedOutcomes_conditionalLaw {Ω : Type*} [MeasurableSpace Ω] {n : ℕ} {μ : Measure Ω} {ν : Measure (Bool × ℝ)} [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] (S : MarkedIID Ω n μ ν) (a : Bool) (e : ℝ≥0∞) (ρ : Measure ℝ) [IsProbabilityMeasure ρ] (hfac : BooleanMarkFactorization ν a e ρ) (w : Fin n → Bool) (hw : μ (wordEvent S.Z w) ≠ 0) : Measure.map (selectedOutcomes S.Z w a) μ[|wordEvent S.Z w] = Measure.pi (fun _ : Fin (selectedWordCount w a) => ρ) := by -- Use `iIndepFun.map_fun_eq_pi_map` and rewrite every marginal with the preceding lemma. calc Measure.map (selectedOutcomes S.Z w a) μ[|wordEvent S.Z w] = Measure.pi (fun j => Measure.map (fun ω => selectedOutcomes S.Z w a ω j) μ[|wordEvent S.Z w]) := by exact iIndepFun.map_fun_eq_pi_map (fun j => (S.measurable (selectedIndex w a j)).snd.aemeasurable) (S.selectedOutcomes_iIndep_cond_word a w hw) _ = Measure.pi (fun _ : Fin (selectedWordCount w a) => ρ) := by congr 1 funext j exact S.selectedOutcome_map_cond_word_eq a e ρ hfac w hw j
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw.MarkedIID.selectedOutcomes_conditionalLaw · Causalean/Stat/Quantile/ConditionalMarkedSubsampleDkw/ConditionalLaw.lean:222 · uses BooleanMarkFactorization , MarkedIID , selectedOutcomes , selectedWordCount , wordEvent
6 supporting declarations (lemmas, instances)
  • measure_wordEvent_eq_prod lemma — Given a finite marked iid experiment and a Boolean word, the probability of its exact-word event equals the product of its coordinatewise mark probabilities.
    Ω :
    n :
    μ :
    ν :
    Measure (Bool × ℝ)
    S :
    MarkedIID Ω n μ ν
    w :
    Fin n → Bool
    μ (wordEvent S.Z w) = ∏ i, ν {z | z.1 = w i}
    Proof (Lean source)
    lemma MarkedIID.measure_wordEvent_eq_prod {Ω : Type*} [MeasurableSpace Ω] {n : ℕ} {μ : Measure Ω} {ν : Measure (Bool × ℝ)} (S : MarkedIID Ω n μ ν) (w : Fin n → Bool) : μ (wordEvent S.Z w) = ∏ i, ν {z | z.1 = w i} := by -- Apply the finite-intersection characterization of `iIndepFun`, then each marginal map law. rw [show wordEvent S.Z w = ⋂ i, S.Z i ⁻¹' {z | z.1 = w i} by ext ω simp [wordEvent]] rw [S.indep.meas_iInter] · apply Finset.prod_congr rfl intro i _ calc μ (S.Z i ⁻¹' {z | z.1 = w i}) = μ.map (S.Z i) {z | z.1 = w i} := (Measure.map_apply (S.measurable i) ((measurableSet_singleton (w i)).preimage measurable_fst)).symm _ = ν {z | z.1 = w i} := by rw [S.law i] · intro i exact ⟨{z | z.1 = w i}, (measurableSet_singleton (w i)).preimage measurable_fst, rfl⟩
    Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw.MarkedIID.measure_wordEvent_eq_prod · Causalean/Stat/Quantile/ConditionalMarkedSubsampleDkw/ConditionalLaw.lean:35
  • map_snd_cond_mark_eq lemma — Given a finite marked iid experiment, a requested mark, its mass, a probability law for selected outcomes, a Boolean mark factorization, and a coordinate, conditioning that coordinate's outcome on its requested mark gives the selected-outcome law.
    Ω :
    n :
    μ :
    ν :
    Measure (Bool × ℝ)
    S :
    MarkedIID Ω n μ ν
    a :
    e :
    ℝ≥0∞
    hfac :
    i :
    Fin n
    Measure.map (fun ω => (S.Z i ω).2) μ[|{ω | (S.Z i ω).1 = a}] = ρ
    Proof (Lean source)
    lemma MarkedIID.map_snd_cond_mark_eq {Ω : Type*} [MeasurableSpace Ω] {n : ℕ} {μ : Measure Ω} {ν : Measure (Bool × ℝ)} [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] (S : MarkedIID Ω n μ ν) (a : Bool) (e : ℝ≥0∞) (ρ : Measure ℝ) [IsProbabilityMeasure ρ] (hfac : BooleanMarkFactorization ν a e ρ) (i : Fin n) : Measure.map (fun ω => (S.Z i ω).2) μ[|{ω | (S.Z i ω).1 = a}] = ρ := by -- Use `Measure.ext`; `cond_apply` turns each measurable test set into the factorization ratio. have hmark_meas : MeasurableSet {ω | (S.Z i ω).1 = a} := (measurableSet_singleton a).preimage (S.measurable i).fst have hνmark : ν {z | z.1 = a} = e := by simpa using hfac.joint Set.univ MeasurableSet.univ have hμmark : μ {ω | (S.Z i ω).1 = a} = e := by calc μ {ω | (S.Z i ω).1 = a} = μ.map (S.Z i) {z | z.1 = a} := (Measure.map_apply (S.measurable i) ((measurableSet_singleton a).preimage measurable_fst)).symm _ = ν {z | z.1 = a} := by rw [S.law i] _ = e := hνmark have he_top : e ≠ ∞ := by rw [← hνmark] exact measure_ne_top ν _ ext B hB rw [Measure.map_apply (S.measurable i).snd hB, cond_apply hmark_meas, hμmark] have hjoint : μ ({ω | (S.Z i ω).1 = a} ∩ (fun ω => (S.Z i ω).2) ⁻¹' B) = e * ρ B := by calc μ ({ω | (S.Z i ω).1 = a} ∩ (fun ω => (S.Z i ω).2) ⁻¹' B) = μ (S.Z i ⁻¹' {z | z.1 = a ∧ z.2 ∈ B}) := by congr 1 _ = μ.map (S.Z i) {z | z.1 = a ∧ z.2 ∈ B} := (Measure.map_apply (S.measurable i) (((measurableSet_singleton a).preimage measurable_fst).inter (hB.preimage measurable_snd))).symm _ = ν {z | z.1 = a ∧ z.2 ∈ B} := by rw [S.law i] _ = e * ρ B := hfac.joint B hB rw [hjoint, ← mul_assoc, ENNReal.inv_mul_cancel hfac.positive he_top, one_mul]
    Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw.MarkedIID.map_snd_cond_mark_eq · Causalean/Stat/Quantile/ConditionalMarkedSubsampleDkw/ConditionalLaw.lean:57
  • outcomes_iIndep_cond_word lemma — Given a finite marked iid experiment, a Boolean word, and positive probability for its exact-word event, all outcome coordinates remain mutually independent after conditioning on that event.
    Ω :
    n :
    μ :
    ν :
    Measure (Bool × ℝ)
    S :
    MarkedIID Ω n μ ν
    w :
    Fin n → Bool
    hw :
    μ (wordEvent S.Z w) ≠ 0
    iIndepFun (fun i ω => (S.Z i ω).2) μ[|wordEvent S.Z w]
    Proof (Lean source)
    lemma MarkedIID.outcomes_iIndep_cond_word {Ω : Type*} [MeasurableSpace Ω] {n : ℕ} {μ : Measure Ω} {ν : Measure (Bool × ℝ)} [IsProbabilityMeasure μ] (S : MarkedIID Ω n μ ν) (w : Fin n → Bool) (hw : μ (wordEvent S.Z w) ≠ 0) : iIndepFun (fun i ω => (S.Z i ω).2) μ[|wordEvent S.Z w] := by -- Swap each pair, invoke `iIndepFun.cond`, and derive nonzero coordinate mark events from `hw`. have hprod : ∏ i, ν {z | z.1 = w i} ≠ 0 := by rw [← S.measure_wordEvent_eq_prod w] exact hw have hνmark (i : Fin n) : ν {z | z.1 = w i} ≠ 0 := (Finset.prod_ne_zero_iff.mp hprod) i (Finset.mem_univ i) have hμmark (i : Fin n) : μ ((fun ω => (S.Z i ω).1) ⁻¹' {w i}) ≠ 0 := by calc μ ((fun ω => (S.Z i ω).1) ⁻¹' {w i}) = μ.map (S.Z i) {z | z.1 = w i} := (Measure.map_apply (S.measurable i) ((measurableSet_singleton (w i)).preimage measurable_fst)).symm _ = ν {z | z.1 = w i} := by rw [S.law i] _ ≠ 0 := hνmark i have hindep : iIndepFun (fun i ω => ((S.Z i ω).2, (S.Z i ω).1)) μ := by simpa [Function.comp_def] using S.indep.comp (fun (_ : Fin n) => fun z : Bool × ℝ => (z.2, z.1)) (fun _ => measurable_snd.prodMk measurable_fst) have hcond := iIndepFun.cond (X := fun i ω => (S.Z i ω).2) (Y := fun i ω => (S.Z i ω).1) (t := fun i => {w i}) (fun i => (S.measurable i).fst) hindep hμmark (fun i => measurableSet_singleton (w i)) have hevent : (⋂ i, (fun ω => (S.Z i ω).1) ⁻¹' {w i}) = wordEvent S.Z w := by ext ω simp [wordEvent] rw [hevent] at hcond exact hcond
    Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw.MarkedIID.outcomes_iIndep_cond_word · Causalean/Stat/Quantile/ConditionalMarkedSubsampleDkw/ConditionalLaw.lean:98
  • selectedOutcome_map_cond_word_eq lemma — Given a finite marked iid experiment, a requested mark, its mass, a selected-outcome law, a Boolean mark factorization, a Boolean word, positive probability for that word, and a selected-coordinate index, that reindexed selected outcome has law ρ after conditioning on the complete word.
    Ω :
    n :
    μ :
    ν :
    Measure (Bool × ℝ)
    S :
    MarkedIID Ω n μ ν
    a :
    e :
    ℝ≥0∞
    hfac :
    w :
    Fin n → Bool
    hw :
    μ (wordEvent S.Z w) ≠ 0
    Measure.map (fun ω => selectedOutcomes S.Z w a ω j) μ[|wordEvent S.Z w] = ρ
    Proof (Lean source)
    lemma MarkedIID.selectedOutcome_map_cond_word_eq {Ω : Type*} [MeasurableSpace Ω] {n : ℕ} {μ : Measure Ω} {ν : Measure (Bool × ℝ)} [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] (S : MarkedIID Ω n μ ν) (a : Bool) (e : ℝ≥0∞) (ρ : Measure ℝ) [IsProbabilityMeasure ρ] (hfac : BooleanMarkFactorization ν a e ρ) (w : Fin n → Bool) (hw : μ (wordEvent S.Z w) ≠ 0) (j : Fin (selectedWordCount w a)) : Measure.map (fun ω => selectedOutcomes S.Z w a ω j) μ[|wordEvent S.Z w] = ρ := by -- `cond_iInter` shows that conditioning on the other marks does not change this marginal. let k : Fin n := selectedIndex w a j have hk : w k = a := selectedIndex_mark w a j have hprod : ∏ i, ν {z | z.1 = w i} ≠ 0 := by rw [← S.measure_wordEvent_eq_prod w] exact hw have hνmark (i : Fin n) : ν {z | z.1 = w i} ≠ 0 := (Finset.prod_ne_zero_iff.mp hprod) i (Finset.mem_univ i) have hμmark (i : Fin n) : μ ((fun ω => (S.Z i ω).1) ⁻¹' {w i}) ≠ 0 := by calc μ ((fun ω => (S.Z i ω).1) ⁻¹' {w i}) = μ.map (S.Z i) {z | z.1 = w i} := (Measure.map_apply (S.measurable i) ((measurableSet_singleton (w i)).preimage measurable_fst)).symm _ = ν {z | z.1 = w i} := by rw [S.law i] _ ≠ 0 := hνmark i have hindep : iIndepFun (fun i ω => ((S.Z i ω).2, (S.Z i ω).1)) μ := by simpa [Function.comp_def] using S.indep.comp (fun (_ : Fin n) => fun z : Bool × ℝ => (z.2, z.1)) (fun _ => measurable_snd.prodMk measurable_fst) have hevent : (⋂ i, (fun ω => (S.Z i ω).1) ⁻¹' {w i}) = wordEvent S.Z w := by ext ω simp [wordEvent] ext B hB change (Measure.map (fun ω => (S.Z k ω).2) μ[|wordEvent S.Z w]) B = ρ B rw [Measure.map_apply ((S.measurable k).snd) hB] change μ[(fun ω => (S.Z k ω).2) ⁻¹' B | wordEvent S.Z w] = ρ B rw [← hevent] have hcond := cond_iInter (X := fun i ω => (S.Z i ω).2) (Y := fun i ω => (S.Z i ω).1) (f := fun i => (fun ω => (S.Z i ω).2) ⁻¹' B) (t := fun i => {w i}) (s := {k}) (fun i => (S.measurable i).fst) hindep (fun i _ => ⟨B, hB, rfl⟩) (fun i _ => hμmark i) (fun i => measurableSet_singleton (w i)) have hsingle : μ[(fun ω => (S.Z k ω).2) ⁻¹' B | ⋂ i, (fun ω => (S.Z i ω).1) ⁻¹' {w i}] = μ[(fun ω => (S.Z k ω).2) ⁻¹' B | (fun ω => (S.Z k ω).1) ⁻¹' {w k}] := by simpa using hcond rw [hsingle] have hmarg := congrArg (fun m : Measure ℝ => m B) (S.map_snd_cond_mark_eq a e ρ hfac k) rw [Measure.map_apply (S.measurable k).snd hB] at hmarg rw [hk] have hmarkset : (fun ω => (S.Z k ω).1) ⁻¹' {a} = {ω | (S.Z k ω).1 = a} := by ext ω simp rw [hmarkset] exact hmarg
    Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw.MarkedIID.selectedOutcome_map_cond_word_eq · Causalean/Stat/Quantile/ConditionalMarkedSubsampleDkw/ConditionalLaw.lean:135
  • selectedOutcomes_iIndep_cond_word lemma — Given a finite marked iid experiment, a requested mark, a Boolean word, and positive probability for its exact-word event, the reindexed selected outcomes remain mutually independent after conditioning on that event.
    Ω :
    n :
    μ :
    ν :
    Measure (Bool × ℝ)
    S :
    MarkedIID Ω n μ ν
    a :
    w :
    Fin n → Bool
    hw :
    μ (wordEvent S.Z w) ≠ 0
    iIndepFun (fun j ω => selectedOutcomes S.Z w a ω j) μ[|wordEvent S.Z w]
    Proof (Lean source)
    lemma MarkedIID.selectedOutcomes_iIndep_cond_word {Ω : Type*} [MeasurableSpace Ω] {n : ℕ} {μ : Measure Ω} {ν : Measure (Bool × ℝ)} [IsProbabilityMeasure μ] (S : MarkedIID Ω n μ ν) (a : Bool) (w : Fin n → Bool) (hw : μ (wordEvent S.Z w) ≠ 0) : iIndepFun (fun j ω => selectedOutcomes S.Z w a ω j) μ[|wordEvent S.Z w] := by -- Precompose `outcomes_iIndep_cond_word` with the injective selected-coordinate embedding. simpa [selectedOutcomes] using iIndepFun.precomp (selectedIndex w a).injective (S.outcomes_iIndep_cond_word w hw)
    Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw.MarkedIID.selectedOutcomes_iIndep_cond_word · Causalean/Stat/Quantile/ConditionalMarkedSubsampleDkw/ConditionalLaw.lean:199
  • measurable_selectedOutcomes lemma — Given a finite marked iid experiment, a requested mark, and a Boolean word, the map from a sample outcome to its reindexed selected outcome vector is measurable.
    Ω :
    n :
    μ :
    ν :
    Measure (Bool × ℝ)
    S :
    MarkedIID Ω n μ ν
    a :
    w :
    Fin n → Bool
    Proof (Lean source)
    lemma measurable_selectedOutcomes {Ω : Type*} [MeasurableSpace Ω] {n : ℕ} {μ : Measure Ω} {ν : Measure (Bool × ℝ)} (S : MarkedIID Ω n μ ν) (a : Bool) (w : Fin n → Bool) : Measurable (selectedOutcomes S.Z w a) := by -- Apply `measurable_pi_lambda`; each coordinate is a projection of `S.measurable`. exact measurable_pi_lambda _ fun j => (S.measurable (selectedIndex w a j)).snd
    Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw.measurable_selectedOutcomes · Causalean/Stat/Quantile/ConditionalMarkedSubsampleDkw/ConditionalLaw.lean:213
Measurability 1 core · 2 supporting This module supplies the separability step needed to treat the supremum over all real thresholds as an ordinary measurable random variable. ★ measurableSet_fixedCDFBadSet

Measurability of finite empirical-CDF deviations

This module supplies the separability step needed to treat the supremum over all real thresholds as an ordinary measurable random variable. In particular, callers of the tail-lifting theorem do not need to assume an extra measurability side condition beyond the fixed-size probability bound.

lemma measurableSet_fixedCDFBadSet reviewed
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw

For a probability law and a deviation radius, the fixed-size uniform empirical-CDF bad set is measurable.

Formal statement
m :
radius :
MeasurableSet (fixedCDFBadSet (m := m) ρ radius)
Proof (Lean source)
lemma measurableSet_fixedCDFBadSet {m : ℕ} (ρ : Measure ℝ) [IsProbabilityMeasure ρ] (radius : ℝ) : MeasurableSet (fixedCDFBadSet (m := m) ρ radius) := by -- This is the measurable preimage of the open upper ray `(radius, ∞)`. change MeasurableSet ((uniformCDFDeviation (m := m) ρ) ⁻¹' Ioi radius) exact measurableSet_Ioi.preimage (measurable_uniformCDFDeviation ρ)
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw.measurableSet_fixedCDFBadSet · Causalean/Stat/Quantile/ConditionalMarkedSubsampleDkw/Measurability.lean:128 · uses fixedCDFBadSet
2 supporting declarations (lemmas, instances)
Tail­Lift 2 core · 2 supporting This module lifts any fixed-size i.i.d. ★ conditionalMarkedSubsample_empiricalCDF_tail

Empirical-CDF tail bounds after Boolean selection

This module lifts any fixed-size i.i.d. empirical-CDF tail bound through independent Boolean marking and the resulting random sample size. It also packages the count-dependent radius used with the sharp two-sided DKW--Massart bound.

theorem conditionalMarkedSubsample_empiricalCDF_tail reviewed
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw

Given a finite marked iid experiment, a requested mark, its mass, a selected-outcome law, a Boolean mark factorization, a count-indexed radius, a probability bound, and the corresponding fixed-size iid empirical-CDF bound at every positive sample size, the probability that the selected arm is nonempty and its uniform empirical-CDF deviation exceeds its count-indexed radius is at most β.

Formal statement
Ω :
n :
μ :
ν :
Measure (Bool × ℝ)
S :
MarkedIID Ω n μ ν
a :
e :
ℝ≥0∞
hfac :
radius :
ℕ → ℝ
β :
ℝ≥0∞
hfixed :
∀ m : ℕ
if
0 < m
then
(Measure.pi (fun _ : Fin m => ρ)) (fixedCDFBadSet ρ (radius m)) ≤ β
μ (selectedCDFBadEvent S.Z a ρ radius) ≤ β
Proof (Lean source)
theorem conditionalMarkedSubsample_empiricalCDF_tail {Ω : Type*} [MeasurableSpace Ω] {n : ℕ} {μ : Measure Ω} {ν : Measure (Bool × ℝ)} [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] (S : MarkedIID Ω n μ ν) (a : Bool) (e : ℝ≥0∞) (ρ : Measure ℝ) [IsProbabilityMeasure ρ] (hfac : BooleanMarkFactorization ν a e ρ) (radius : ℕ → ℝ) (β : ℝ≥0∞) (hfixed : ∀ m : ℕ, 0 < m → (Measure.pi (fun _ : Fin m => ρ)) (fixedCDFBadSet ρ (radius m)) ≤ β) : μ (selectedCDFBadEvent S.Z a ρ radius) ≤ β := by -- Apply finite aggregation to exact words; positive-count cells use the conditional product law. -- Rewrite the cell intersection with `selectedCDFBadEvent_inter_wordEvent`, turn its pullback -- probability into a mapped conditional measure via `Measure.map_apply`, and then rewrite that -- map with `selectedOutcomes_conditionalLaw`. Zero-count cells again have empty intersection. apply measure_le_of_cond_le_on_finite_partition μ (fun w : Fin n → Bool => wordEvent S.Z w) (fun w => measurableSet_wordEvent S.Z S.measurable w) (fun w v hwv => disjoint_wordEvent S.Z hwv) (iUnion_wordEvent S.Z) (selectedCDFBadEvent S.Z a ρ radius) (measurableSet_selectedCDFBadEvent S a ρ radius) β intro w hwprob by_cases hw : 0 < selectedWordCount w a · rw [cond_apply (measurableSet_wordEvent S.Z S.measurable w), inter_comm (wordEvent S.Z w), selectedCDFBadEvent_inter_wordEvent S.Z a ρ radius w hw] calc (μ (wordEvent S.Z w))⁻¹ * μ ((selectedOutcomes S.Z w a) ⁻¹' fixedCDFBadSet ρ (radius (selectedWordCount w a)) ∩ wordEvent S.Z w) = (Measure.map (selectedOutcomes S.Z w a) μ[|wordEvent S.Z w]) (fixedCDFBadSet ρ (radius (selectedWordCount w a))) := by rw [Measure.map_apply (measurable_selectedOutcomes S a w) (measurableSet_fixedCDFBadSet ρ _), cond_apply (measurableSet_wordEvent S.Z S.measurable w), inter_comm] _ = (Measure.pi (fun _ : Fin (selectedWordCount w a) => ρ)) (fixedCDFBadSet ρ (radius (selectedWordCount w a))) := by rw [S.selectedOutcomes_conditionalLaw a e ρ hfac w hwprob] _ ≤ β := hfixed (selectedWordCount w a) hw · rw [cond_apply (measurableSet_wordEvent S.Z S.measurable w)] have hinter : wordEvent S.Z w ∩ selectedCDFBadEvent S.Z a ρ radius = ∅ := by ext ω constructor · rintro ⟨hword, hbad⟩ exact (hw (by simpa [selectedCount_eq_on_wordEvent S.Z a w hword] using hbad.1)).elim · simp simp [hinter]
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw.conditionalMarkedSubsample_empiricalCDF_tail · Causalean/Stat/Quantile/ConditionalMarkedSubsampleDkw/TailLift.lean:58 · uses BooleanMarkFactorization , MarkedIID , fixedCDFBadSet , selectedCDFBadEvent
def dkwRadius reviewed
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw

For a confidence parameter and a selected count, the DKW confidence radius is the square root of log(4/α) divided by twice that count. It is a DKW radius for a confidence parameter that is positive and at most one and a positive count, as assumed by the tail theorems; outside that domain the logarithm, division and square-root conventions give values without that meaning (for example zero at count zero).

Definition (Lean source)
α :
m :
dkwRadius α m :
sqrt (log (4 / α) / (2 * (m : ℝ)))
Causalean.Stat.Quantile.ConditionalMarkedSubsampleDkw.dkwRadius · Causalean/Stat/Quantile/ConditionalMarkedSubsampleDkw/TailLift.lean:107
2 supporting declarations (lemmas, instances)