Mathlib.Probability.Poisson.Finite­Partition.Capped­Prefix

This subtopic identifies a fixed finite iid sample, uniformly permuted and independently marked by fair Boolean variables, with the nonoverflow part of a finite marked-Poisson prefix experiment.

Uniform 2 core · 4 supporting An iid sample remains iid after a coordinate permutation. ★ map_permuted_marked_pi

Uniform permutation and Boolean mark laws

An iid sample remains iid after a coordinate permutation. Independent fair Boolean marks pair with that sample to give the paired iid product law. The finite mark and permutation normalizations are explicit.

def fairBoolLaw reviewed
Causalean.Mathlib.Probability.Poisson.FinitePartition.CappedPrefix

The fair Boolean law assigns probability one half to each Boolean value.

Definition (Lean source)
fairBoolLaw :
(1 / 2 : ENNReal) • (Measure.dirac false + Measure.dirac true)
Causalean.Mathlib.Probability.Poisson.FinitePartition.CappedPrefix.fairBoolLaw · Causalean/Mathlib/Probability/Poisson/FinitePartition/CappedPrefix/Uniform.lean:21
theorem map_permuted_marked_pi reviewed
Causalean.Mathlib.Probability.Poisson.FinitePartition.CappedPrefix

For an iid probability law, a sample size, and a coordinate permutation, independently fair marked permuted observations have the paired iid product law.

Formal statement
X :
n :
ℕ
perm :
Perm (Fin n)
Measure.map (fun z : (Fin n → X) × (Fin n → Bool) => fun i => (z.1 (perm i), z.2 i)) ((Measure.pi (fun _ : Fin n => μ)).prod (Measure.pi (fun _ : Fin n => fairBoolLaw)))
= Measure.pi (fun _ : Fin n => μ.prod fairBoolLaw)
Proof (Lean source)
theorem map_permuted_marked_pi {X : Type*} [MeasurableSpace X] (μ : Measure X) [IsProbabilityMeasure μ] (n : ℕ) (perm : Perm (Fin n)) : Measure.map (fun z : (Fin n → X) × (Fin n → Bool) => fun i => (z.1 (perm i), z.2 i)) ((Measure.pi (fun _ : Fin n => μ)).prod (Measure.pi (fun _ : Fin n => fairBoolLaw))) = Measure.pi (fun _ : Fin n => μ.prod fairBoolLaw) := by /- Combine `map_perm_pi` with `Measure.pi_prod`/the measurable Pi-product equivalence. -/ let f : (Fin n → X) → (Fin n → X) := fun x i => x (perm i) let e := MeasurableEquiv.arrowProdEquivProdArrow X Bool (Fin n) have hf : Measurable f := by unfold f fun_prop have hpair : Measure.map e.symm ((Measure.pi (fun _ : Fin n => μ)).prod (Measure.pi (fun _ : Fin n => fairBoolLaw))) = Measure.pi (fun _ : Fin n => μ.prod fairBoolLaw) := (measurePreserving_arrowProdEquivProdArrow X Bool (Fin n) (fun _ => μ) (fun _ => fairBoolLaw)).symm.map_eq calc Measure.map (fun z : (Fin n → X) × (Fin n → Bool) => fun i => (z.1 (perm i), z.2 i)) ((Measure.pi (fun _ : Fin n => μ)).prod (Measure.pi (fun _ : Fin n => fairBoolLaw))) = Measure.map e.symm (Measure.map (map f id) ((Measure.pi (fun _ : Fin n => μ)).prod (Measure.pi (fun _ : Fin n => fairBoolLaw)))) := by rw [Measure.map_map e.symm.measurable (hf.prodMap measurable_id)] rfl _ = Measure.map e.symm ((Measure.pi (fun _ : Fin n => μ)).prod (Measure.pi (fun _ : Fin n => fairBoolLaw))) := by rw [← Measure.map_prod_map _ _ hf measurable_id] rw [show Measure.map f (Measure.pi (fun _ : Fin n => μ)) = Measure.pi (fun _ : Fin n => μ) from map_perm_pi μ n perm] simp _ = _ := hpair
Causalean.Mathlib.Probability.Poisson.FinitePartition.CappedPrefix.map_permuted_marked_pi · Causalean/Mathlib/Probability/Poisson/FinitePartition/CappedPrefix/Uniform.lean:49 · uses fairBoolLaw
4 supporting declarations (lemmas, instances)
Basic 1 core · 2 supporting Finite Poisson count mixtures from a fixed iid sample agree with the nonoverflow restriction of the marked Poisson finite-prefix law. ★ capped_marked_prefix_integral

Capped marked Poisson prefix identities

Finite Poisson count mixtures from a fixed iid sample agree with the nonoverflow restriction of the marked Poisson finite-prefix law.

theorem capped_marked_prefix_integral reviewed
Causalean.Mathlib.Probability.Poisson.FinitePartition.CappedPrefix

For a probability observation law, a Poisson mean, a sample size, a real statistic of finite fair-marked samples, and its integrability under the Poisson finite-sample law of fair-marked observations, the expectation over an iid sample of size n of the mixture that draws a prefix length M ≤ n with its Poisson probability, a uniformly random ordering of the sample, and uniformly random Boolean marks, and evaluates the statistic at the length-M prefix of the reordered marked sample, equals the expectation of the statistic under the Poisson finite-sample law restricted to samples of at most n points. The Poisson weights of lengths above n are dropped on both sides, so neither side is renormalized.

Formal statement
X :
lam :
ℝ≥0
n :
ℕ
g :
FiniteSample (X × Bool) → ℝ
(∫ x : Fin n → X, ∑ M : Fin (n + 1), ∑ perm : Perm (Fin n), ∑ marks : Fin n → Bool, ((poissonMeasure lam {M.val}).toReal / ((card (Perm (Fin n)) : ℝ) * (card (Fin n → Bool) : ℝ))) * g (prefixOfLE (fun i => (x (perm i), marks i)) M.val (le_of_lt_succ M.isLt)) ∂Measure.pi (fun _ : Fin n => μ))
= ∫ z : FiniteSample (X × Bool), if z.count ≤ n then g z else 0 ∂finitePoissonSampleLaw (μ.prod fairBoolLaw) lam
Proof (Lean source)
theorem capped_marked_prefix_integral {X : Type*} [MeasurableSpace X] (μ : Measure X) [IsProbabilityMeasure μ] (lam : ℝ≥0) (n : ℕ) (g : FiniteSample (X × Bool) → ℝ) (hg : Integrable g (finitePoissonSampleLaw (μ.prod fairBoolLaw) lam)) : (∫ x : Fin n → X, ∑ M : Fin (n + 1), ∑ perm : Perm (Fin n), ∑ marks : Fin n → Bool, ((poissonMeasure lam {M.val}).toReal / ((card (Perm (Fin n)) : ℝ) * (card (Fin n → Bool) : ℝ))) * g (prefixOfLE (fun i => (x (perm i), marks i)) M.val (le_of_lt_succ M.isLt)) ∂Measure.pi (fun _ : Fin n => μ)) = ∫ z : FiniteSample (X × Bool), if z.count ≤ n then g z else 0 ∂finitePoissonSampleLaw (μ.prod fairBoolLaw) lam := by /- For each admissible `M`, use `perm_mark_prefix_average_integral` to remove the finite permutation and mark sums. Pull the Poisson mass outside the integral and apply `poisson_prefix_mixture_integral` with `ν = μ.prod fairBoolLaw`. Derive each fixed-count integrability premise by restricting `hg` to the count fibre via `finitePoissonSampleLaw_restrict_count_eq`; zero Poisson mass fibres may be discarded directly. -/ classical let ν : Measure (Fin n → X) := Measure.pi (fun _ : Fin n => μ) let ρ : Measure (Fin n → Bool) := Measure.pi (fun _ : Fin n => fairBoolLaw) let c : ℝ := (card (Perm (Fin n)) : ℝ) let d : ℝ := (card (Fin n → Bool) : ℝ) have hmark (marks : Fin n → Bool) : ρ.real {marks} = 1 / d := by change (Measure.pi (fun _ : Fin n => fairBoolLaw)).real {marks} = _ rw [fairMarkPi_eq_uniform_sum] simp [Measure.real, Measure.smul_apply, Finset.sum_apply, d] have hfixed (M : Fin (n + 1)) (hmass : poissonMeasure lam {M.val} ≠ 0) : Integrable (fun y : Fin n → X × Bool => g (prefixOfLE y M.val (le_of_lt_succ M.isLt))) (Measure.pi (fun _ : Fin n => μ.prod fairBoolLaw)) := integrable_prefix_of_nonzero_poisson_count (μ.prod fairBoolLaw) lam n M.val (le_of_lt_succ M.isLt) g hg hmass have havg (M : Fin (n + 1)) (hmass : poissonMeasure lam {M.val} ≠ 0) : Integrable (fun x : Fin n → X => ∑ perm : Perm (Fin n), ∑ marks : Fin n → Bool, (1 / (c * d)) * g (prefixOfLE (fun i => (x (perm i), marks i)) M.val (le_of_lt_succ M.isLt))) ν := by apply integrable_finsetSum intro perm _ have hmap : Measurable (fun z : (Fin n → X) × (Fin n → Bool) => fun i => (z.1 (perm i), z.2 i)) := by fun_prop have hprod : Integrable (fun z : (Fin n → X) × (Fin n → Bool) => g (prefixOfLE (fun i => (z.1 (perm i), z.2 i)) M.val (le_of_lt_succ M.isLt))) (ν.prod ρ) := by change Integrable ((fun y : Fin n → X × Bool => g (prefixOfLE y M.val (le_of_lt_succ M.isLt))) ∘ (fun z : (Fin n → X) × (Fin n → Bool) => fun i => (z.1 (perm i), z.2 i))) (ν.prod ρ) exact (integrable_map_measure (by rw [map_permuted_marked_pi μ n perm] exact (hfixed M hmass).aestronglyMeasurable) hmap.aemeasurable).mp (by rw [map_permuted_marked_pi μ n perm] exact hfixed M hmass) have hslice (x : Fin n → X) : (∫ marks : Fin n → Bool, g (prefixOfLE (fun i => (x (perm i), marks i)) M.val (le_of_lt_succ M.isLt)) ∂ρ) = ∑ marks : Fin n → Bool, (1 / d) * g (prefixOfLE (fun i => (x (perm i), marks i)) M.val (le_of_lt_succ M.isLt)) := by rw [integral_fintype (Integrable.of_finite)] simp_rw [hmark, smul_eq_mul] have hsection : Integrable (fun x : Fin n → X => ∑ marks : Fin n → Bool, (1 / d) * g (prefixOfLE (fun i => (x (perm i), marks i)) M.val (le_of_lt_succ M.isLt))) ν := by convert hprod.integral_prod_left using 1 funext x exact (hslice x).symm have heq : (fun x : Fin n → X => ∑ marks : Fin n → Bool, (1 / (c * d)) * g (prefixOfLE (fun i => (x (perm i), marks i)) M.val (le_of_lt_succ M.isLt))) = (fun x : Fin n → X => (1 / c) * ∑ marks : Fin n → Bool, (1 / d) * g (prefixOfLE (fun i => (x (perm i), marks i)) M.val (le_of_lt_succ M.isLt))) := by funext x rw [Finset.mul_sum] apply Finset.sum_congr rfl intro marks _ ring rw [heq] exact hsection.const_mul _ have hterm (M : Fin (n + 1)) : Integrable (fun x : Fin n → X => ∑ perm : Perm (Fin n), ∑ marks : Fin n → Bool, ((poissonMeasure lam {M.val}).toReal / (c * d)) * g (prefixOfLE (fun i => (x (perm i), marks i)) M.val (le_of_lt_succ M.isLt))) ν := by by_cases hmass : poissonMeasure lam {M.val} = 0 · simp [hmass] · convert (havg M hmass).const_mul (poissonMeasure lam {M.val}).toReal using 1 funext x simp_rw [Finset.mul_sum] apply Finset.sum_congr rfl intro perm _ apply Finset.sum_congr rfl intro marks _ ring calc _ = ∑ M : Fin (n + 1), ∫ x : Fin n → X, ∑ perm : Perm (Fin n), ∑ marks : Fin n → Bool, ((poissonMeasure lam {M.val}).toReal / (c * d)) * g (prefixOfLE (fun i => (x (perm i), marks i)) M.val (le_of_lt_succ M.isLt)) ∂ν := by exact integral_finsetSum univ (fun M _ => hterm M) _ = ∑ M : Fin (n + 1), (poissonMeasure lam {M.val}).toReal * ∫ y : Fin n → X × Bool, g (prefixOfLE y M.val (le_of_lt_succ M.isLt)) ∂Measure.pi (fun _ : Fin n => μ.prod fairBoolLaw) := by apply Finset.sum_congr rfl intro M _ by_cases hmass : poissonMeasure lam {M.val} = 0 · simp [hmass] · have hav := perm_mark_prefix_average_integral μ n M.val (le_of_lt_succ M.isLt) g (hfixed M hmass) rw [← hav, ← integral_const_mul] congr 1 funext x rw [Finset.mul_sum] apply Finset.sum_congr rfl intro perm _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro marks _ dsimp [c, d] ring _ = _ := poisson_prefix_mixture_integral (μ.prod fairBoolLaw) lam n g hg
2 supporting declarations (lemmas, instances)
Count­Fibre 1 core · 3 supporting These lemmas isolate the fixed-count step in capped-prefix mixtures. ★ poisson_prefix_count_fibre_integral

Integrability and integration on a Poisson count fibre

These lemmas isolate the fixed-count step in capped-prefix mixtures. A positive Poisson count mass transports integrability to the corresponding finite iid prefix. The weighted identity also covers zero-mass fibres.

theorem poisson_prefix_count_fibre_integral reviewed
Causalean.Mathlib.Probability.Poisson.FinitePartition.CappedPrefix

For an iid observation law, a Poisson mean, a sample size, a count that fits in the sample, and an integrable finite-sample statistic, the count-fibre integral equals the Poisson atom times the iid prefix integral, including a zero-mass atom.

Formal statement
Y :
lam :
ℝ≥0
n m :
ℕ
h :
m ≤ n
g :
FiniteSample Y → ℝ
∫ z : FiniteSample Y in FiniteSample.count ⁻¹' ({m} : Set ℕ), g z ∂finitePoissonSampleLaw ν lam
= (poissonMeasure lam {m}).toReal * ∫ y : Fin n → Y, g (prefixOfLE y m h) ∂Measure.pi (fun _ : Fin n => ν)
Proof (Lean source)
theorem poisson_prefix_count_fibre_integral {Y : Type*} [MeasurableSpace Y] (ν : Measure Y) [IsProbabilityMeasure ν] (lam : ℝ≥0) (n m : ℕ) (h : m ≤ n) (g : FiniteSample Y → ℝ) (hg : Integrable g (finitePoissonSampleLaw ν lam)) : ∫ z : FiniteSample Y in FiniteSample.count ⁻¹' ({m} : Set ℕ), g z ∂finitePoissonSampleLaw ν lam = (poissonMeasure lam {m}).toReal * ∫ y : Fin n → Y, g (prefixOfLE y m h) ∂Measure.pi (fun _ : Fin n => ν) := by /- If the Poisson atom is zero, both sides vanish. Otherwise apply `poisson_prefix_count_fibre_integral_of_nonzero`. -/ by_cases hmass : poissonMeasure lam {m} = 0 · rw [poisson_prefix_count_fibre_integral_of_zero ν lam m g hmass, hmass] simp · exact poisson_prefix_count_fibre_integral_of_nonzero ν lam n m h g hg hmass
Causalean.Mathlib.Probability.Poisson.FinitePartition.CappedPrefix.poisson_prefix_count_fibre_integral · Causalean/Mathlib/Probability/Poisson/FinitePartition/CappedPrefix/CountFibre.lean:209 · uses FiniteSample , count , finitePoissonSampleLaw , prefixOfLE
3 supporting declarations (lemmas, instances)
  • integrable_prefix_of_nonzero_poisson_count theorem — For an iid observation law, a Poisson mean, a sample size, a count that fits in the sample, an integrable finite-sample statistic, and positive mass at that count, the statistic of the fixed-count iid prefix is integrable.
    Y :
    lam :
    ℝ≥0
    n m :
    ℕ
    h :
    m ≤ n
    g :
    FiniteSample Y → ℝ
    hmass :
    poissonMeasure lam {m} ≠ 0
    Integrable (fun y : Fin n → Y => g (prefixOfLE y m h)) (Measure.pi (fun _ : Fin n => ν))
    Proof (Lean source)
    theorem integrable_prefix_of_nonzero_poisson_count {Y : Type*} [MeasurableSpace Y] (ν : Measure Y) [IsProbabilityMeasure ν] (lam : ℝ≥0) (n m : ℕ) (h : m ≤ n) (g : FiniteSample Y → ℝ) (hg : Integrable g (finitePoissonSampleLaw ν lam)) (hmass : poissonMeasure lam {m} ≠ 0) : Integrable (fun y : Fin n → Y => g (prefixOfLE y m h)) (Measure.pi (fun _ : Fin n => ν)) := by /- Restrict `hg` to the count-m fibre, rewrite with `finitePoissonSampleLaw_restrict_count_eq`, cancel the nonzero finite Poisson scalar using `integrable_smul_measure`, then transport the map-integrability across `fixedSizeEmbed` and `map_prefixCoordinates_pi`. -/ classical have hfixed : Integrable g (Measure.map (fixedSizeEmbed m) (Measure.pi (fun _ : Fin m => ν))) := by have hr := hg.restrict (s := FiniteSample.count ⁻¹' ({m} : Set ℕ)) rw [finitePoissonSampleLaw_restrict_count_eq ν lam m] at hr exact (integrable_smul_measure hmass (measure_ne_top _ _)).mp hr have hsmall : Integrable (g ∘ fixedSizeEmbed m) (Measure.pi (fun _ : Fin m => ν)) := (integrable_map_measure hfixed.aestronglyMeasurable (measurable_fixedSizeEmbed m).aemeasurable).mp hfixed let f : (Fin n → Y) → (Fin m → Y) := fun x i => x ⟨i, lt_of_lt_of_le i.isLt h⟩ have hf : Measurable f := by dsimp [f] fun_prop have hmap : Measure.map f (Measure.pi (fun _ : Fin n => ν)) = Measure.pi (fun _ : Fin m => ν) := by symm refine Measure.pi_eq (μ := fun _ : Fin m => ν) (fun s hs => ?_) rw [Measure.map_apply hf (.univ_pi hs)] have hpre : f ⁻¹' (Set.univ.pi s) = Set.univ.pi (fun j : Fin n => if hj : j.val < m then s ⟨j.val, hj⟩ else univ) := by ext x simp only [Set.mem_preimage, Set.mem_pi, Set.mem_univ, true_implies] constructor · intro hx j split · exact hx ⟨j.val, ‹j.val < m›⟩ · trivial · intro hx i simpa [f] using hx ⟨i.val, lt_of_lt_of_le i.isLt h⟩ rw [hpre, Measure.pi_pi] let t : Finset (Fin n) := Finset.univ.filter fun j => j.val < m have ht (j : t) : j.val.val < m := by simpa only [t, mem_filter, Finset.mem_univ, true_and] using j.property let e : Fin m ≃ t := { toFun := fun i => ⟨⟨i.val, lt_of_lt_of_le i.isLt h⟩, by simp [t, i.isLt]⟩ invFun := fun j => ⟨j.val.val, ht j⟩ left_inv := fun i => by rfl right_inv := fun j => by ext; rfl } calc (∏ j : Fin n, ν (if hj : j.val < m then s ⟨j.val, hj⟩ else univ)) = ∏ j : Fin n, if hj : j.val < m then ν (s ⟨j.val, hj⟩) else 1 := by apply Fintype.prod_congr intro j split <;> simp _ = ∏ j : t, ν (s ⟨j.val.val, ht j⟩) := by rw [Finset.prod_dite] simp only [Finset.prod_const_one, mul_one] apply Fintype.prod_congr intro j congr 2 _ = ∏ i : Fin m, ν (s i) := by symm apply Fintype.prod_equiv e intro i rfl have hlarge : Integrable ((g ∘ fixedSizeEmbed m) ∘ f) (Measure.pi (fun _ : Fin n => ν)) := by apply (integrable_map_measure (by rw [hmap]; exact hsmall.aestronglyMeasurable) hf.aemeasurable).mp rwa [hmap] simpa [Function.comp_def, f, prefixOfLE, fixedSizeEmbed] using hlarge
    Causalean.Mathlib.Probability.Poisson.FinitePartition.CappedPrefix.integrable_prefix_of_nonzero_poisson_count · Causalean/Mathlib/Probability/Poisson/FinitePartition/CappedPrefix/CountFibre.lean:21
  • poisson_prefix_count_fibre_integral_of_zero theorem — For an iid observation law, a Poisson mean, a count, a finite-sample statistic, and zero mass at that count, integrating the statistic over that count fibre gives zero.
    Y :
    lam :
    ℝ≥0
    m :
    ℕ
    g :
    FiniteSample Y → ℝ
    hmass :
    poissonMeasure lam {m} = 0
    ∫ z : FiniteSample Y in FiniteSample.count ⁻¹' ({m} : Set ℕ), g z ∂finitePoissonSampleLaw ν lam
    = 0
    Proof (Lean source)
    theorem poisson_prefix_count_fibre_integral_of_zero {Y : Type*} [MeasurableSpace Y] (ν : Measure Y) [IsProbabilityMeasure ν] (lam : ℝ≥0) (m : ℕ) (g : FiniteSample Y → ℝ) (hmass : poissonMeasure lam {m} = 0) : ∫ z : FiniteSample Y in FiniteSample.count ⁻¹' ({m} : Set ℕ), g z ∂finitePoissonSampleLaw ν lam = 0 := by /- The count restriction is a zero scalar multiple of its iid fibre law. -/ rw [finitePoissonSampleLaw_restrict_count_eq ν lam m, hmass] simp
    Causalean.Mathlib.Probability.Poisson.FinitePartition.CappedPrefix.poisson_prefix_count_fibre_integral_of_zero · Causalean/Mathlib/Probability/Poisson/FinitePartition/CappedPrefix/CountFibre.lean:102
  • poisson_prefix_count_fibre_integral_of_nonzero theorem — For an iid observation law, a Poisson mean, a sample size, a count that fits in the sample, an integrable finite-sample statistic, and positive mass at that count, the restricted integral is that mass times the iid fixed-prefix integral.
    Y :
    lam :
    ℝ≥0
    n m :
    ℕ
    h :
    m ≤ n
    g :
    FiniteSample Y → ℝ
    hmass :
    poissonMeasure lam {m} ≠ 0
    ∫ z : FiniteSample Y in FiniteSample.count ⁻¹' ({m} : Set ℕ), g z ∂finitePoissonSampleLaw ν lam
    = (poissonMeasure lam {m}).toReal * ∫ y : Fin n → Y, g (prefixOfLE y m h) ∂Measure.pi (fun _ : Fin n => ν)
    Proof (Lean source)
    theorem poisson_prefix_count_fibre_integral_of_nonzero {Y : Type*} [MeasurableSpace Y] (ν : Measure Y) [IsProbabilityMeasure ν] (lam : ℝ≥0) (n m : ℕ) (h : m ≤ n) (g : FiniteSample Y → ℝ) (hg : Integrable g (finitePoissonSampleLaw ν lam)) (hmass : poissonMeasure lam {m} ≠ 0) : ∫ z : FiniteSample Y in FiniteSample.count ⁻¹' ({m} : Set ℕ), g z ∂finitePoissonSampleLaw ν lam = (poissonMeasure lam {m}).toReal * ∫ y : Fin n → Y, g (prefixOfLE y m h) ∂Measure.pi (fun _ : Fin n => ν) := by /- Rewrite the count restriction as a scalar times `map fixedSizeEmbed`. `integrable_prefix_of_nonzero_poisson_count` supplies fixed-prefix integrability. Transport the integral through `fixedSizeEmbed`, then show the first `m` coordinates of the `Fin n` iid law have the `Fin m` iid law. The latter calculation already appears as `hmap` in that theorem's proof. -/ classical have hfixed : Integrable g (Measure.map (fixedSizeEmbed m) (Measure.pi (fun _ : Fin m => ν))) := by have hr := hg.restrict (s := FiniteSample.count ⁻¹' ({m} : Set ℕ)) rw [finitePoissonSampleLaw_restrict_count_eq ν lam m] at hr exact (integrable_smul_measure hmass (measure_ne_top _ _)).mp hr have hsmall : Integrable (g ∘ fixedSizeEmbed m) (Measure.pi (fun _ : Fin m => ν)) := (integrable_map_measure hfixed.aestronglyMeasurable (measurable_fixedSizeEmbed m).aemeasurable).mp hfixed let f : (Fin n → Y) → (Fin m → Y) := fun x i => x ⟨i, lt_of_lt_of_le i.isLt h⟩ have hf : Measurable f := by dsimp [f] fun_prop have hmap : Measure.map f (Measure.pi (fun _ : Fin n => ν)) = Measure.pi (fun _ : Fin m => ν) := by symm refine Measure.pi_eq (μ := fun _ : Fin m => ν) (fun s hs => ?_) rw [Measure.map_apply hf (.univ_pi hs)] have hpre : f ⁻¹' (Set.univ.pi s) = Set.univ.pi (fun j : Fin n => if hj : j.val < m then s ⟨j.val, hj⟩ else univ) := by ext x simp only [Set.mem_preimage, Set.mem_pi, Set.mem_univ, true_implies] constructor · intro hx j split · exact hx ⟨j.val, ‹j.val < m›⟩ · trivial · intro hx i simpa [f] using hx ⟨i.val, lt_of_lt_of_le i.isLt h⟩ rw [hpre, Measure.pi_pi] let t : Finset (Fin n) := Finset.univ.filter fun j => j.val < m have ht (j : t) : j.val.val < m := by simpa only [t, mem_filter, Finset.mem_univ, true_and] using j.property let e : Fin m ≃ t := { toFun := fun i => ⟨⟨i.val, lt_of_lt_of_le i.isLt h⟩, by simp [t, i.isLt]⟩ invFun := fun j => ⟨j.val.val, ht j⟩ left_inv := fun i => by rfl right_inv := fun j => by ext; rfl } calc (∏ j : Fin n, ν (if hj : j.val < m then s ⟨j.val, hj⟩ else univ)) = ∏ j : Fin n, if hj : j.val < m then ν (s ⟨j.val, hj⟩) else 1 := by apply Fintype.prod_congr intro j split <;> simp _ = ∏ j : t, ν (s ⟨j.val.val, ht j⟩) := by rw [Finset.prod_dite] simp only [Finset.prod_const_one, mul_one] apply Fintype.prod_congr intro j congr 2 _ = ∏ i : Fin m, ν (s i) := by symm apply Fintype.prod_equiv e intro i rfl have htransport : ∫ z : FiniteSample Y, g z ∂Measure.map (fixedSizeEmbed m) (Measure.pi (fun _ : Fin m => ν)) = ∫ y : Fin n → Y, g (prefixOfLE y m h) ∂Measure.pi (fun _ : Fin n => ν) := by rw [integral_map (measurable_fixedSizeEmbed m).aemeasurable hfixed.aestronglyMeasurable] have hcoordinate := integral_map (μ := Measure.pi (fun _ : Fin n => ν)) hf.aemeasurable (by rw [hmap]; exact hsmall.aestronglyMeasurable) (f := g ∘ fixedSizeEmbed m) rw [hmap] at hcoordinate simpa [Function.comp_def, f, prefixOfLE, fixedSizeEmbed] using hcoordinate rw [finitePoissonSampleLaw_restrict_count_eq ν lam m, integral_smul_measure, smul_eq_mul, htransport]
    Causalean.Mathlib.Probability.Poisson.FinitePartition.CappedPrefix.poisson_prefix_count_fibre_integral_of_nonzero · Causalean/Mathlib/Probability/Poisson/FinitePartition/CappedPrefix/CountFibre.lean:116
Count­Partition 1 core · 0 supporting The integral over finite samples whose count is at most a fixed cap splits into the integrals over its finitely many exact-count fibres. ★ poisson_nonoverflow_integral_eq_sum_count_fibres

Finite count partition of a Poisson prefix integral

The integral over finite samples whose count is at most a fixed cap splits into the integrals over its finitely many exact-count fibres.

theorem poisson_nonoverflow_integral_eq_sum_count_fibres reviewed
Causalean.Mathlib.Probability.Poisson.FinitePartition.CappedPrefix

For an iid observation law, a Poisson mean, a count cap, and an integrable statistic, the expectation with zero value above the cap is the sum of exact-count fibre integrals.

Formal statement
Y :
lam :
ℝ≥0
n :
ℕ
g :
FiniteSample Y → ℝ
(∫ z : FiniteSample Y, if z.count ≤ n then g z else 0 ∂finitePoissonSampleLaw ν lam)
= ∑ M : Fin (n + 1), ∫ z : FiniteSample Y in FiniteSample.count ⁻¹' ({M.val} : Set ℕ), g z ∂finitePoissonSampleLaw ν lam
Proof (Lean source)
theorem poisson_nonoverflow_integral_eq_sum_count_fibres {Y : Type*} [MeasurableSpace Y] (ν : Measure Y) [IsProbabilityMeasure ν] (lam : ℝ≥0) (n : ℕ) (g : FiniteSample Y → ℝ) (hg : Integrable g (finitePoissonSampleLaw ν lam)) : (∫ z : FiniteSample Y, if z.count ≤ n then g z else 0 ∂finitePoissonSampleLaw ν lam) = ∑ M : Fin (n + 1), ∫ z : FiniteSample Y in FiniteSample.count ⁻¹' ({M.val} : Set ℕ), g z ∂finitePoissonSampleLaw ν lam := by /- Rewrite the conditional integrand as the indicator of the measurable count-preimage of `Set.Iic n`; use `integral_indicator`. Identify that set with the union over `Fin (n + 1)` of the singleton count fibres. Apply Mathlib's `integral_iUnion_fintype` to these measurable, disjoint fibres; `hg.integrableOn` supplies each fibre's integrability. -/ let s : Fin (n + 1) → Set (FiniteSample Y) := fun M => FiniteSample.count ⁻¹' ({M.val} : Set ℕ) have hcap : MeasurableSet (FiniteSample.count ⁻¹' Set.Iic n : Set (FiniteSample Y)) := measurable_finiteSample_count measurableSet_Iic have hunion : (FiniteSample.count ⁻¹' Set.Iic n : Set (FiniteSample Y)) = ⋃ M : Fin (n + 1), s M := by ext z simp only [Set.mem_preimage, Set.mem_Iic, Set.mem_iUnion, Set.mem_singleton_iff, s] constructor · intro hz exact ⟨⟨z.count, Nat.lt_succ_of_le hz⟩, rfl⟩ · rintro ⟨M, hM⟩ rw [hM] exact Nat.le_of_lt_succ M.isLt have hs : ∀ M, MeasurableSet (s M) := by intro M exact measurable_finiteSample_count (measurableSet_singleton M.val) have hdisj : Pairwise (onFun Disjoint s) := by intro a b hab change Disjoint (s a) (s b) rw [Set.disjoint_left] intro z hza hzb simp only [s, Set.mem_preimage, Set.mem_singleton_iff] at hza hzb apply hab apply Fin.ext exact hza.symm.trans hzb have hfi : ∀ M, IntegrableOn g (s M) (finitePoissonSampleLaw ν lam) := by intro M exact hg.integrableOn calc (∫ z : FiniteSample Y, if z.count ≤ n then g z else 0 ∂finitePoissonSampleLaw ν lam) = ∫ z : FiniteSample Y, (FiniteSample.count ⁻¹' Set.Iic n : Set (FiniteSample Y)).indicator g z ∂finitePoissonSampleLaw ν lam := by congr 1 funext z simp [indicator, Set.mem_Iic] _ = ∫ z : FiniteSample Y in FiniteSample.count ⁻¹' Set.Iic n, g z ∂finitePoissonSampleLaw ν lam := integral_indicator hcap _ = ∫ z : FiniteSample Y in ⋃ M : Fin (n + 1), s M, g z ∂finitePoissonSampleLaw ν lam := by rw [hunion] _ = ∑ M : Fin (n + 1), ∫ z : FiniteSample Y in FiniteSample.count ⁻¹' ({M.val} : Set ℕ), g z ∂finitePoissonSampleLaw ν lam := integral_iUnion_fintype hs hdisj hfi
Causalean.Mathlib.Probability.Poisson.FinitePartition.CappedPrefix.poisson_nonoverflow_integral_eq_sum_count_fibres · Causalean/Mathlib/Probability/Poisson/FinitePartition/CappedPrefix/CountPartition.lean:20 · uses FiniteSample , count , finitePoissonSampleLaw