Mathlib.Probability.Poisson.Pair­Second­Moment

Exact second-moment tools for bilinear sums over two independent finite Poisson samples, including fixed-count coincidence formulas and count-mixture identities.

Basic 2 core · 0 supporting The bilinear statistic is defined for arbitrary finite samples. ★ pairSum_sq_le_count_mul_sum_sq

A finite bilinear sum and its pointwise square bound

The bilinear statistic is defined for arbitrary finite samples. Its square is bounded by the number of index pairs times the sum of squared kernel values.

def pairSum reviewed
Causalean.Mathlib.Probability.Poisson.PairSecondMoment

Given a real kernel and two finite samples, the bilinear pair sum is given by adding the kernel over every ordered left-right pair.

Definition (Lean source)
X :
Type u_1
shared
Y :
Type u_2
shared
K :
X → Y → ℝ
s :
t :
pairSum K s t :
ℝ
∑ i : Fin s.1, ∑ j : Fin t.1, K (s.2 i) (t.2 j)
Causalean.Mathlib.Probability.Poisson.PairSecondMoment.pairSum · Causalean/Mathlib/Probability/Poisson/PairSecondMoment/Basic.lean:21 · uses FiniteSample
theorem pairSum_sq_le_count_mul_sum_sq reviewed
Causalean.Mathlib.Probability.Poisson.PairSecondMoment

Given a real kernel and two finite samples, the squared bilinear sum is bounded by its ordered-pair count times the sum of squared kernel values.

Formal statement
X :
Type u_1
shared
Y :
Type u_2
shared
K :
X → Y → ℝ
s :
t :
pairSum K s t ^ 2
≤ (s.1 : ℝ) * (t.1 : ℝ) * (∑ i : Fin s.1, ∑ j : Fin t.1, K (s.2 i) (t.2 j) ^ 2)
Proof (Lean source)
theorem pairSum_sq_le_count_mul_sum_sq (K : X → Y → ℝ) (s : FiniteSample X) (t : FiniteSample Y) : pairSum K s t ^ 2 ≤ (s.1 : ℝ) * (t.1 : ℝ) * (∑ i : Fin s.1, ∑ j : Fin t.1, K (s.2 i) (t.2 j) ^ 2) := by -- Apply `sq_sum_le_card_mul_sum_sq` to the product of the two index -- finsets. Rewrite the product sum with `Finset.sum_product'`, and its -- cardinality with `Finset.card_product` and `Fintype.card_fin`. have h := sq_sum_le_card_mul_sum_sq (s := univ) (f := fun p : Fin s.1 × Fin t.1 => K (s.2 p.1) (t.2 p.2)) rw [← Finset.univ_product_univ, Finset.sum_product] at h rw [Finset.sum_product] at h simpa [pairSum, Finset.card_product, Fintype.card_fin, mul_assoc] using h
Causalean.Mathlib.Probability.Poisson.PairSecondMoment.pairSum_sq_le_count_mul_sum_sq · Causalean/Mathlib/Probability/Poisson/PairSecondMoment/Basic.lean:28 · uses FiniteSample , pairSum
Algebra 1 core · 1 supporting This file isolates the finite combinatorial expansion behind second moments of bilinear statistics of two independent Poisson streams. ★ integral_bilinearSum_sq_eq_coincidence

Coincidence expansion for bilinear finite sums

This file isolates the finite combinatorial expansion behind second moments of bilinear statistics of two independent Poisson streams. The four terms correspond to coincidence in both stream indices, only the second index, only the first index, and neither index.

theorem integral_bilinearSum_sq_eq_coincidence reviewed
Causalean.Mathlib.Probability.Poisson.PairSecondMoment

Given a measure, a finite array of real summands, and integrable products of every two summands, the integral of its squared bilinear sum is the four-class coincidence expansion.

Formal statement
μ :
K :
ι → κ → Ω → ℝ
hK :
∀ i j k l, Integrable (fun ω => K i j ω * K k l ω) μ
∫ ω, (∑ i, ∑ j, K i j ω) ^ 2 ∂μ
= (∑ i, ∑ j, ∫ ω, K i j ω * K i j ω ∂μ)
+ (∑ i, ∑ j, ∑ l ∈ (Finset.univ.erase j), ∫ ω, K i j ω * K i l ω ∂μ)
+ (∑ i, ∑ j, ∑ k ∈ (Finset.univ.erase i), ∫ ω, K i j ω * K k j ω ∂μ)
+ (∑ i, ∑ j, ∑ k ∈ (Finset.univ.erase i), ∑ l ∈ (Finset.univ.erase j), ∫ ω, K i j ω * K k l ω ∂μ)
Proof (Lean source)
theorem integral_bilinearSum_sq_eq_coincidence {Ω ι κ : Type*} [MeasurableSpace Ω] [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] (μ : Measure Ω) (K : ι → κ → Ω → ℝ) (hK : ∀ i j k l, Integrable (fun ω => K i j ω * K k l ω) μ) : ∫ ω, (∑ i, ∑ j, K i j ω) ^ 2 ∂μ = (∑ i, ∑ j, ∫ ω, K i j ω * K i j ω ∂μ) + (∑ i, ∑ j, ∑ l ∈ (Finset.univ.erase j), ∫ ω, K i j ω * K i l ω ∂μ) + (∑ i, ∑ j, ∑ k ∈ (Finset.univ.erase i), ∫ ω, K i j ω * K k j ω ∂μ) + (∑ i, ∑ j, ∑ k ∈ (Finset.univ.erase i), ∑ l ∈ (Finset.univ.erase j), ∫ ω, K i j ω * K k l ω ∂μ) := by rw [integral_congr_ae (Filter.Eventually.of_forall fun ω => bilinearSum_sq_eq_coincidence (fun i j => K i j ω))] let A := fun ω => ∑ i, ∑ j, K i j ω * K i j ω let B := fun ω => ∑ i, ∑ j, ∑ l ∈ (Finset.univ.erase j), K i j ω * K i l ω let C := fun ω => ∑ i, ∑ j, ∑ k ∈ (Finset.univ.erase i), K i j ω * K k j ω let D := fun ω => ∑ i, ∑ j, ∑ k ∈ (Finset.univ.erase i), ∑ l ∈ (Finset.univ.erase j), K i j ω * K k l ω have hA : Integrable A μ := by dsimp only [A] apply integrable_finsetSum intro i _ apply integrable_finsetSum intro j _ exact hK i j i j have hB : Integrable B μ := by dsimp only [B] apply integrable_finsetSum intro i _ apply integrable_finsetSum intro j _ apply integrable_finsetSum intro l _ exact hK i j i l have hC : Integrable C μ := by dsimp only [C] apply integrable_finsetSum intro i _ apply integrable_finsetSum intro j _ apply integrable_finsetSum intro k _ exact hK i j k j have hD : Integrable D μ := by dsimp only [D] apply integrable_finsetSum intro i _ apply integrable_finsetSum intro j _ apply integrable_finsetSum intro k _ apply integrable_finsetSum intro l _ exact hK i j k l change ∫ ω, ((A ω + B ω) + C ω) + D ω ∂μ = _ have hAB := integral_add hA hB have hABC := integral_add (hA.add hB) hC have hABCD := integral_add ((hA.add hB).add hC) hD have hAB' : (∫ ω, (A + B) ω ∂μ) = (∫ ω, A ω ∂μ) + (∫ ω, B ω ∂μ) := by simpa only [Pi.add_apply] using hAB have hABC' : (∫ ω, (A + B + C) ω ∂μ) = (∫ ω, (A + B) ω ∂μ) + (∫ ω, C ω ∂μ) := by simpa only [Pi.add_apply] using hABC have eA : (∫ ω, A ω ∂μ) = ∑ i, ∑ j, ∫ ω, K i j ω * K i j ω ∂μ := by dsimp only [A] rw [integral_finsetSum univ (fun i _ => integrable_finsetSum univ (fun j _ => hK i j i j))] apply Finset.sum_congr rfl intro i _ rw [integral_finsetSum univ (fun j _ => hK i j i j)] have eB : (∫ ω, B ω ∂μ) = ∑ i, ∑ j, ∑ l ∈ (Finset.univ.erase j), ∫ ω, K i j ω * K i l ω ∂μ := by dsimp only [B] rw [integral_finsetSum univ (fun i _ => integrable_finsetSum univ (fun j _ => integrable_finsetSum (Finset.univ.erase j) (fun l _ => hK i j i l)))] apply Finset.sum_congr rfl intro i _ rw [integral_finsetSum univ (fun j _ => integrable_finsetSum (Finset.univ.erase j) (fun l _ => hK i j i l))] apply Finset.sum_congr rfl intro j _ rw [integral_finsetSum (Finset.univ.erase j) (fun l _ => hK i j i l)] have eC : (∫ ω, C ω ∂μ) = ∑ i, ∑ j, ∑ k ∈ (Finset.univ.erase i), ∫ ω, K i j ω * K k j ω ∂μ := by dsimp only [C] rw [integral_finsetSum univ (fun i _ => integrable_finsetSum univ (fun j _ => integrable_finsetSum (Finset.univ.erase i) (fun k _ => hK i j k j)))] apply Finset.sum_congr rfl intro i _ rw [integral_finsetSum univ (fun j _ => integrable_finsetSum (Finset.univ.erase i) (fun k _ => hK i j k j))] apply Finset.sum_congr rfl intro j _ rw [integral_finsetSum (Finset.univ.erase i) (fun k _ => hK i j k j)] have eD : (∫ ω, D ω ∂μ) = ∑ i, ∑ j, ∑ k ∈ (Finset.univ.erase i), ∑ l ∈ (Finset.univ.erase j), ∫ ω, K i j ω * K k l ω ∂μ := by dsimp only [D] rw [integral_finsetSum univ (fun i _ => integrable_finsetSum univ (fun j _ => integrable_finsetSum (Finset.univ.erase i) (fun k _ => integrable_finsetSum (Finset.univ.erase j) (fun l _ => hK i j k l))))] apply Finset.sum_congr rfl intro i _ rw [integral_finsetSum univ (fun j _ => integrable_finsetSum (Finset.univ.erase i) (fun k _ => integrable_finsetSum (Finset.univ.erase j) (fun l _ => hK i j k l)))] apply Finset.sum_congr rfl intro j _ rw [integral_finsetSum (Finset.univ.erase i) (fun k _ => integrable_finsetSum (Finset.univ.erase j) (fun l _ => hK i j k l))] apply Finset.sum_congr rfl intro k _ rw [integral_finsetSum (Finset.univ.erase j) (fun l _ => hK i j k l)] calc _ = (∫ ω, (A + B + C) ω ∂μ) + (∫ ω, D ω ∂μ) := by simpa only [Pi.add_apply] using hABCD _ = ((∫ ω, (A + B) ω ∂μ) + (∫ ω, C ω ∂μ)) + (∫ ω, D ω ∂μ) := by rw [hABC'] _ = (((∫ ω, A ω ∂μ) + (∫ ω, B ω ∂μ)) + (∫ ω, C ω ∂μ)) + (∫ ω, D ω ∂μ) := by rw [hAB'] _ = _ := by rw [eA, eB, eC, eD]
Causalean.Mathlib.Probability.Poisson.PairSecondMoment.integral_bilinearSum_sq_eq_coincidence · Causalean/Mathlib/Probability/Poisson/PairSecondMoment/Algebra.lean:47
1 supporting declaration (lemmas, instances)
  • bilinearSum_sq_eq_coincidence theorem — Given a finite real array, its squared bilinear sum is the sum of its four index-coincidence classes.
    ι κ :
    K :
    ι → κ → ℝ
    (∑ i, ∑ j, K i j) ^ 2
    = (∑ i, ∑ j, K i j * K i j)
    + (∑ i, ∑ j, ∑ l ∈ (Finset.univ.erase j), K i j * K i l)
    + (∑ i, ∑ j, ∑ k ∈ (Finset.univ.erase i), K i j * K k j)
    + (∑ i, ∑ j, ∑ k ∈ (Finset.univ.erase i), ∑ l ∈ (Finset.univ.erase j), K i j * K k l)
    Proof (Lean source)
    theorem bilinearSum_sq_eq_coincidence {ι κ : Type*} [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] (K : ι → κ → ℝ) : (∑ i, ∑ j, K i j) ^ 2 = (∑ i, ∑ j, K i j * K i j) + (∑ i, ∑ j, ∑ l ∈ (Finset.univ.erase j), K i j * K i l) + (∑ i, ∑ j, ∑ k ∈ (Finset.univ.erase i), K i j * K k j) + (∑ i, ∑ j, ∑ k ∈ (Finset.univ.erase i), ∑ l ∈ (Finset.univ.erase j), K i j * K k l) := by classical rw [pow_two, Finset.sum_mul] simp_rw [Finset.sum_mul, Finset.mul_sum] simp only [← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ rw [← Finset.add_sum_erase univ (fun k => ∑ l, K i j * K k l) (Finset.mem_univ i)] rw [← Finset.add_sum_erase univ (fun l => K i j * K i l) (Finset.mem_univ j)] simp_rw [← Finset.add_sum_erase univ (fun l => K i j * K _ l) (Finset.mem_univ j)] rw [Finset.sum_add_distrib] ring
    Causalean.Mathlib.Probability.Poisson.PairSecondMoment.bilinearSum_sq_eq_coincidence · Causalean/Mathlib/Probability/Poisson/PairSecondMoment/Algebra.lean:19
Coordinates 1 core · 4 supporting The four coincidence patterns in a bilinear square have different coordinate laws. ★ integral_fixedCount_both_distinct

Coordinate integrals for two independent iid arrays

The four coincidence patterns in a bilinear square have different coordinate laws. These lemmas keep the left and right observations independent, and use two fresh coordinates within a stream whenever its indices differ.

theorem integral_fixedCount_both_distinct reviewed
Causalean.Mathlib.Probability.Poisson.PairSecondMoment

Given two probability laws, a measurable real kernel, an integrable kernel square, two fixed array lengths, and distinct selected positions in each array, the product of the two kernel evaluations has the four-independent-coordinate integral.

Formal statement
X :
Type u_1
shared
Y :
Type u_2
shared
K :
X → Y → ℝ
m n :
ℕ
hK :
hK2 :
Integrable (fun p : X × Y => K p.1 p.2 ^ 2) (P.prod Q)
i k :
Fin m
j l :
Fin n
hik :
i ≠ k
hjl :
j ≠ l
(∫ p : (Fin m → X) × (Fin n → Y), K (p.1 i) (p.2 j) * K (p.1 k) (p.2 l) ∂((Measure.pi fun _ : Fin m => P).prod (Measure.pi fun _ : Fin n => Q)))
= ∫ x, ∫ x', ∫ y, ∫ y', K x y * K x' y' ∂Q ∂Q ∂P ∂P
Proof (Lean source)
theorem integral_fixedCount_both_distinct (P : Measure X) [IsProbabilityMeasure P] (Q : Measure Y) [IsProbabilityMeasure Q] (K : X → Y → ℝ) (m n : ℕ) (hK : Measurable (uncurry K)) (hK2 : Integrable (fun p : X × Y => K p.1 p.2 ^ 2) (P.prod Q)) (i k : Fin m) (j l : Fin n) (hik : i ≠ k) (hjl : j ≠ l) : (∫ p : (Fin m → X) × (Fin n → Y), K (p.1 i) (p.2 j) * K (p.1 k) (p.2 l) ∂((Measure.pi fun _ : Fin m => P).prod (Measure.pi fun _ : Fin n => Q))) = ∫ x, ∫ x', ∫ y, ∫ y', K x y * K x' y' ∂Q ∂Q ∂P ∂P := by let μ := (Measure.pi fun _ : Fin m => P).prod (Measure.pi fun _ : Fin n => Q) let φ : ((Fin m → X) × (Fin n → Y)) → (X × X) × (Y × Y) := fun p => ((p.1 i, p.1 k), (p.2 j, p.2 l)) let F : (X × X) × (Y × Y) → ℝ := fun z => K z.1.1 z.2.1 * K z.1.2 z.2.2 have hφ : MeasurePreserving φ μ ((P.prod P).prod (Q.prod Q)) := by convert (measurePreserving_fixedCount_two P m i k hik).prod (measurePreserving_fixedCount_two Q n j l hjl) using 1 rfl have hFmeas : Measurable F := by have h₁ : Measurable (fun z : (X × X) × (Y × Y) => (z.1.1, z.2.1)) := by fun_prop have h₂ : Measurable (fun z : (X × X) × (Y × Y) => (z.1.2, z.2.2)) := by fun_prop exact (hK.comp h₁).mul (hK.comp h₂) have hI := integrable_fixedCount_kernelProduct P Q K m n hK hK2 i k j l have hF : Integrable F ((P.prod P).prod (Q.prod Q)) := by apply (hφ.integrable_comp hFmeas.aestronglyMeasurable).mp exact hI have houter : (∫ p, F (φ p) ∂μ) = ∫ z, F z ∂((P.prod P).prod (Q.prod Q)) := by have e := integral_map (μ := μ) (φ := φ) hφ.measurable.aemeasurable (f := F) hFmeas.aestronglyMeasurable rw [hφ.map_eq] at e exact e.symm have hinner : ∀ᵐ p : X × X ∂(P.prod P), (∫ q : Y × Y, F (p, q) ∂(Q.prod Q)) = ∫ y, ∫ y', K p.1 y * K p.2 y' ∂Q ∂Q := by filter_upwards [hF.prod_right_ae] with p hp exact integral_prod _ hp have hG : Integrable (fun p : X × X => ∫ y, ∫ y', K p.1 y * K p.2 y' ∂Q ∂Q) (P.prod P) := hF.integral_prod_left.congr hinner change (∫ p, F (φ p) ∂μ) = _ calc (∫ p, F (φ p) ∂μ) = ∫ p : X × X, ∫ q : Y × Y, F (p, q) ∂(Q.prod Q) ∂(P.prod P) := by rw [houter, integral_prod _ hF] _ = ∫ p : X × X, ∫ y, ∫ y', K p.1 y * K p.2 y' ∂Q ∂Q ∂(P.prod P) := integral_congr_ae hinner _ = _ := integral_prod _ hG
Causalean.Mathlib.Probability.Poisson.PairSecondMoment.integral_fixedCount_both_distinct · Causalean/Mathlib/Probability/Poisson/PairSecondMoment/Coordinates.lean:204
4 supporting declarations (lemmas, instances)
  • integrable_fixedCount_kernelProduct theorem — Given two probability laws, a real kernel, two fixed array lengths, a measurable kernel, an integrable kernel square, and two selected positions in each array, the product of the two kernel evaluations is integrable.
    X :
    Type u_1
    shared
    Y :
    Type u_2
    shared
    K :
    X → Y → ℝ
    m n :
    ℕ
    hK :
    hK2 :
    Integrable (fun p : X × Y => K p.1 p.2 ^ 2) (P.prod Q)
    i k :
    Fin m
    j l :
    Fin n
    Integrable (fun p : (Fin m → X) × (Fin n → Y) => K (p.1 i) (p.2 j) * K (p.1 k) (p.2 l)) ((Measure.pi fun _ : Fin m => P).prod (Measure.pi fun _ : Fin n => Q))
    Proof (Lean source)
    theorem integrable_fixedCount_kernelProduct (P : Measure X) [IsProbabilityMeasure P] (Q : Measure Y) [IsProbabilityMeasure Q] (K : X → Y → ℝ) (m n : ℕ) (hK : Measurable (uncurry K)) (hK2 : Integrable (fun p : X × Y => K p.1 p.2 ^ 2) (P.prod Q)) (i k : Fin m) (j l : Fin n) : Integrable (fun p : (Fin m → X) × (Fin n → Y) => K (p.1 i) (p.2 j) * K (p.1 k) (p.2 l)) ((Measure.pi fun _ : Fin m => P).prod (Measure.pi fun _ : Fin n => Q)) := by let μ := (Measure.pi fun _ : Fin m => P).prod (Measure.pi fun _ : Fin n => Q) let f := fun p : (Fin m → X) × (Fin n → Y) => K (p.1 i) (p.2 j) let g := fun p : (Fin m → X) × (Fin n → Y) => K (p.1 k) (p.2 l) have hfmeas : Measurable f := by change Measurable ((uncurry K) ∘ fun p : (Fin m → X) × (Fin n → Y) => (p.1 i, p.2 j)) exact hK.comp (((measurable_pi_apply i).comp measurable_fst).prodMk ((measurable_pi_apply j).comp measurable_snd)) have hgmeas : Measurable g := by change Measurable ((uncurry K) ∘ fun p : (Fin m → X) × (Fin n → Y) => (p.1 k, p.2 l)) exact hK.comp (((measurable_pi_apply k).comp measurable_fst).prodMk ((measurable_pi_apply l).comp measurable_snd)) have hfsq : Integrable (fun p => f p ^ 2) μ := by simpa only [f, Function.comp_def] using (measurePreserving_fixedCount_pair P Q m n i j).integrable_comp_of_integrable hK2 have hgsq : Integrable (fun p => g p ^ 2) μ := by simpa only [g, Function.comp_def] using (measurePreserving_fixedCount_pair P Q m n k l).integrable_comp_of_integrable hK2 have hf : MemLp f 2 μ := (memLp_two_iff_integrable_sq hfmeas.aestronglyMeasurable).2 hfsq have hg : MemLp g 2 μ := (memLp_two_iff_integrable_sq hgmeas.aestronglyMeasurable).2 hgsq change Integrable (f * g) μ exact hf.integrable_mul hg
    Causalean.Mathlib.Probability.Poisson.PairSecondMoment.integrable_fixedCount_kernelProduct · Causalean/Mathlib/Probability/Poisson/PairSecondMoment/Coordinates.lean:53
  • integral_fixedCount_both_equal theorem — Given two probability laws, a measurable real kernel, an integrable kernel square, two fixed array lengths, and one selected position in each array, coincident evaluations integrate as one independent point-pair kernel square.
    X :
    Type u_1
    shared
    Y :
    Type u_2
    shared
    K :
    X → Y → ℝ
    m n :
    ℕ
    hK :
    hK2 :
    Integrable (fun p : X × Y => K p.1 p.2 ^ 2) (P.prod Q)
    i :
    Fin m
    j :
    Fin n
    (∫ p : (Fin m → X) × (Fin n → Y), K (p.1 i) (p.2 j) * K (p.1 i) (p.2 j) ∂((Measure.pi fun _ : Fin m => P).prod (Measure.pi fun _ : Fin n => Q)))
    = ∫ x, ∫ y, K x y * K x y ∂Q ∂P
    Proof (Lean source)
    theorem integral_fixedCount_both_equal (P : Measure X) [IsProbabilityMeasure P] (Q : Measure Y) [IsProbabilityMeasure Q] (K : X → Y → ℝ) (m n : ℕ) (hK : Measurable (uncurry K)) (hK2 : Integrable (fun p : X × Y => K p.1 p.2 ^ 2) (P.prod Q)) (i : Fin m) (j : Fin n) : (∫ p : (Fin m → X) × (Fin n → Y), K (p.1 i) (p.2 j) * K (p.1 i) (p.2 j) ∂((Measure.pi fun _ : Fin m => P).prod (Measure.pi fun _ : Fin n => Q))) = ∫ x, ∫ y, K x y * K x y ∂Q ∂P := by let φ : ((Fin m → X) × (Fin n → Y)) → X × Y := fun p => (p.1 i, p.2 j) have hφ := measurePreserving_fixedCount_pair P Q m n i j have hprod : Integrable (fun z : X × Y => K z.1 z.2 * K z.1 z.2) (P.prod Q) := by simpa only [← pow_two] using hK2 calc _ = ∫ z : X × Y, K z.1 z.2 * K z.1 z.2 ∂(P.prod Q) := by have e := integral_map (μ := (Measure.pi fun _ : Fin m => P).prod (Measure.pi fun _ : Fin n => Q)) (φ := φ) hφ.measurable.aemeasurable (f := fun z : X × Y => K z.1 z.2 * K z.1 z.2) (hK.mul hK).aestronglyMeasurable rw [hφ.map_eq] at e exact e.symm _ = _ := integral_prod _ hprod
    Causalean.Mathlib.Probability.Poisson.PairSecondMoment.integral_fixedCount_both_equal · Causalean/Mathlib/Probability/Poisson/PairSecondMoment/Coordinates.lean:92
  • integral_fixedCount_shared_left theorem — Given two probability laws, a measurable real kernel, an integrable kernel square, two fixed array lengths, one left position and distinct right positions, the product integrates with a shared left coordinate and independent right coordinates.
    X :
    Type u_1
    shared
    Y :
    Type u_2
    shared
    K :
    X → Y → ℝ
    m n :
    ℕ
    hK :
    hK2 :
    Integrable (fun p : X × Y => K p.1 p.2 ^ 2) (P.prod Q)
    i :
    Fin m
    j l :
    Fin n
    hjl :
    j ≠ l
    (∫ p : (Fin m → X) × (Fin n → Y), K (p.1 i) (p.2 j) * K (p.1 i) (p.2 l) ∂((Measure.pi fun _ : Fin m => P).prod (Measure.pi fun _ : Fin n => Q)))
    = ∫ x, ∫ y, ∫ y', K x y * K x y' ∂Q ∂Q ∂P
    Proof (Lean source)
    theorem integral_fixedCount_shared_left (P : Measure X) [IsProbabilityMeasure P] (Q : Measure Y) [IsProbabilityMeasure Q] (K : X → Y → ℝ) (m n : ℕ) (hK : Measurable (uncurry K)) (hK2 : Integrable (fun p : X × Y => K p.1 p.2 ^ 2) (P.prod Q)) (i : Fin m) (j l : Fin n) (hjl : j ≠ l) : (∫ p : (Fin m → X) × (Fin n → Y), K (p.1 i) (p.2 j) * K (p.1 i) (p.2 l) ∂((Measure.pi fun _ : Fin m => P).prod (Measure.pi fun _ : Fin n => Q))) = ∫ x, ∫ y, ∫ y', K x y * K x y' ∂Q ∂Q ∂P := by let μ := (Measure.pi fun _ : Fin m => P).prod (Measure.pi fun _ : Fin n => Q) let φ : ((Fin m → X) × (Fin n → Y)) → X × (Y × Y) := fun p => (p.1 i, (p.2 j, p.2 l)) let F : X × (Y × Y) → ℝ := fun z => K z.1 z.2.1 * K z.1 z.2.2 have hφ : MeasurePreserving φ μ (P.prod (Q.prod Q)) := by convert (measurePreserving_eval (fun _ : Fin m => P) i).prod (measurePreserving_fixedCount_two Q n j l hjl) using 1 rfl have hFmeas : Measurable F := by have h₁ : Measurable (fun z : X × (Y × Y) => (z.1, z.2.1)) := by fun_prop have h₂ : Measurable (fun z : X × (Y × Y) => (z.1, z.2.2)) := by fun_prop exact (hK.comp h₁).mul (hK.comp h₂) have hI := integrable_fixedCount_kernelProduct P Q K m n hK hK2 i i j l have hF : Integrable F (P.prod (Q.prod Q)) := by apply (hφ.integrable_comp hFmeas.aestronglyMeasurable).mp exact hI have houter : (∫ p, F (φ p) ∂μ) = ∫ z, F z ∂(P.prod (Q.prod Q)) := by have e := integral_map (μ := μ) (φ := φ) hφ.measurable.aemeasurable (f := F) hFmeas.aestronglyMeasurable rw [hφ.map_eq] at e exact e.symm change (∫ p, F (φ p) ∂μ) = _ rw [houter, integral_prod _ hF] apply integral_congr_ae filter_upwards [hF.prod_right_ae] with x hx exact integral_prod _ hx
    Causalean.Mathlib.Probability.Poisson.PairSecondMoment.integral_fixedCount_shared_left · Causalean/Mathlib/Probability/Poisson/PairSecondMoment/Coordinates.lean:122
  • integral_fixedCount_shared_right theorem — Given two probability laws, a measurable real kernel, an integrable kernel square, two fixed array lengths, distinct left positions and one right position, the product integrates with independent left coordinates and a shared right coordinate.
    X :
    Type u_1
    shared
    Y :
    Type u_2
    shared
    K :
    X → Y → ℝ
    m n :
    ℕ
    hK :
    hK2 :
    Integrable (fun p : X × Y => K p.1 p.2 ^ 2) (P.prod Q)
    i k :
    Fin m
    j :
    Fin n
    hik :
    i ≠ k
    (∫ p : (Fin m → X) × (Fin n → Y), K (p.1 i) (p.2 j) * K (p.1 k) (p.2 j) ∂((Measure.pi fun _ : Fin m => P).prod (Measure.pi fun _ : Fin n => Q)))
    = ∫ x, ∫ x', ∫ y, K x y * K x' y ∂Q ∂P ∂P
    Proof (Lean source)
    theorem integral_fixedCount_shared_right (P : Measure X) [IsProbabilityMeasure P] (Q : Measure Y) [IsProbabilityMeasure Q] (K : X → Y → ℝ) (m n : ℕ) (hK : Measurable (uncurry K)) (hK2 : Integrable (fun p : X × Y => K p.1 p.2 ^ 2) (P.prod Q)) (i k : Fin m) (j : Fin n) (hik : i ≠ k) : (∫ p : (Fin m → X) × (Fin n → Y), K (p.1 i) (p.2 j) * K (p.1 k) (p.2 j) ∂((Measure.pi fun _ : Fin m => P).prod (Measure.pi fun _ : Fin n => Q))) = ∫ x, ∫ x', ∫ y, K x y * K x' y ∂Q ∂P ∂P := by let μ := (Measure.pi fun _ : Fin m => P).prod (Measure.pi fun _ : Fin n => Q) let φ : ((Fin m → X) × (Fin n → Y)) → (X × X) × Y := fun p => ((p.1 i, p.1 k), p.2 j) let F : (X × X) × Y → ℝ := fun z => K z.1.1 z.2 * K z.1.2 z.2 have hφ : MeasurePreserving φ μ ((P.prod P).prod Q) := by convert (measurePreserving_fixedCount_two P m i k hik).prod (measurePreserving_eval (fun _ : Fin n => Q) j) using 1 rfl have hFmeas : Measurable F := by have h₁ : Measurable (fun z : (X × X) × Y => (z.1.1, z.2)) := by fun_prop have h₂ : Measurable (fun z : (X × X) × Y => (z.1.2, z.2)) := by fun_prop exact (hK.comp h₁).mul (hK.comp h₂) have hI := integrable_fixedCount_kernelProduct P Q K m n hK hK2 i k j j have hF : Integrable F ((P.prod P).prod Q) := by apply (hφ.integrable_comp hFmeas.aestronglyMeasurable).mp exact hI have houter : (∫ p, F (φ p) ∂μ) = ∫ z, F z ∂((P.prod P).prod Q) := by have e := integral_map (μ := μ) (φ := φ) hφ.measurable.aemeasurable (f := F) hFmeas.aestronglyMeasurable rw [hφ.map_eq] at e exact e.symm change (∫ p, F (φ p) ∂μ) = _ rw [houter, integral_prod _ hF] exact integral_prod _ hF.integral_prod_left
    Causalean.Mathlib.Probability.Poisson.PairSecondMoment.integral_fixedCount_shared_right · Causalean/Mathlib/Probability/Poisson/PairSecondMoment/Coordinates.lean:164
Count­Envelope 1 core · 0 supporting The product of two scalar Poisson count laws gives a finite weighted double series of squared counts. ★ poisson_pair_count_sq_series_lt_top

Summability of the two independent squared Poisson counts

The product of two scalar Poisson count laws gives a finite weighted double series of squared counts. This is the count envelope used for the square of a bilinear sum over independent finite samples.

theorem poisson_pair_count_sq_series_lt_top reviewed
Causalean.Mathlib.Probability.Poisson.PairSecondMoment

Given two nonnegative Poisson rates, the double series weighted by both squared counts is finite.

Formal statement
rateA rateB :
ℝ≥0
(∑' m : ℕ, ∑' n : ℕ, (poissonMeasure rateA) ({m} : Set ℕ) * (poissonMeasure rateB) ({n} : Set ℕ) * ((m : ℝ≥0∞) ^ 2 * (n : ℝ≥0∞) ^ 2)) < ⊤
Proof (Lean source)
theorem poisson_pair_count_sq_series_lt_top (rateA rateB : ℝ≥0) : (∑' m : ℕ, ∑' n : ℕ, (poissonMeasure rateA) ({m} : Set ℕ) * (poissonMeasure rateB) ({n} : Set ℕ) * ((m : ℝ≥0∞) ^ 2 * (n : ℝ≥0∞) ^ 2)) < ⊤ := by have scalar (rate : ℝ≥0) : (∑' n : ℕ, (poissonMeasure rate) ({n} : Set ℕ) * (n : ℝ≥0∞) ^ 2) < ⊤ := by have h := (integrable_poisson_count_sq rate).lintegral_lt_top rw [lintegral_countable'] at h simp_rw [ENNReal.ofReal_pow (Nat.cast_nonneg _) 2, ENNReal.ofReal_natCast] at h simpa only [mul_comm] using h calc (∑' m : ℕ, ∑' n : ℕ, (poissonMeasure rateA) ({m} : Set ℕ) * (poissonMeasure rateB) ({n} : Set ℕ) * ((m : ℝ≥0∞) ^ 2 * (n : ℝ≥0∞) ^ 2)) = ∑' m : ℕ, ∑' n : ℕ, ((poissonMeasure rateA) ({m} : Set ℕ) * (m : ℝ≥0∞) ^ 2) * ((poissonMeasure rateB) ({n} : Set ℕ) * (n : ℝ≥0∞) ^ 2) := by congr 1 funext m congr 1 funext n ac_rfl _ = ∑' m : ℕ, ((poissonMeasure rateA) ({m} : Set ℕ) * (m : ℝ≥0∞) ^ 2) * (∑' n : ℕ, (poissonMeasure rateB) ({n} : Set ℕ) * (n : ℝ≥0∞) ^ 2) := by simp_rw [ENNReal.tsum_mul_left] _ = (∑' m : ℕ, (poissonMeasure rateA) ({m} : Set ℕ) * (m : ℝ≥0∞) ^ 2) * (∑' n : ℕ, (poissonMeasure rateB) ({n} : Set ℕ) * (n : ℝ≥0∞) ^ 2) := by rw [ENNReal.tsum_mul_right] _ < ⊤ := ENNReal.mul_lt_top (scalar rateA) (scalar rateB)
Causalean.Mathlib.Probability.Poisson.PairSecondMoment.poisson_pair_count_sq_series_lt_top · Causalean/Mathlib/Probability/Poisson/PairSecondMoment/CountEnvelope.lean:20
Fixed­Count 1 core · 2 supporting Two independently sampled finite arrays have a bilinear square whose four terms are indexed by the two possible equality decisions in each stream. ★ integral_fixedCount_pairSum_sq

Second moment of a bilinear sum on fixed iid arrays

Two independently sampled finite arrays have a bilinear square whose four terms are indexed by the two possible equality decisions in each stream.

theorem integral_fixedCount_pairSum_sq reviewed
Causalean.Mathlib.Probability.Poisson.PairSecondMoment

Given two probability laws, a measurable real kernel, an integrable kernel square, and two fixed array lengths, the expected squared bilinear sum over two independent iid arrays is the sum of four terms: m·n times the mean squared kernel; m·n(n-1) times the mean product of two kernel values sharing the left point with independent right points; m(m-1)·n times the mean product sharing the right point with independent left points; and m(m-1)·n(n-1) times the mean product at four independent points.

Formal statement
X :
Type u_1
shared
Y :
Type u_2
shared
K :
X → Y → ℝ
m n :
ℕ
hK :
hK2 :
Integrable (fun p : X × Y => K p.1 p.2 ^ 2) (P.prod Q)
(∫ p : (Fin m → X) × (Fin n → Y), (∑ i : Fin m, ∑ j : Fin n, K (p.1 i) (p.2 j)) ^ 2 ∂((Measure.pi fun _ : Fin m => P).prod (Measure.pi fun _ : Fin n => Q)))
= (m : ℝ) * (n : ℝ) * (∫ x, ∫ y, K x y * K x y ∂Q ∂P)
+ (m : ℝ) * ((n : ℝ) * ((n : ℝ) - 1)) * (∫ x, ∫ y, ∫ y', K x y * K x y' ∂Q ∂Q ∂P)
+ ((m : ℝ) * ((m : ℝ) - 1)) * (n : ℝ) * (∫ x, ∫ x', ∫ y, K x y * K x' y ∂Q ∂P ∂P)
+ ((m : ℝ) * ((m : ℝ) - 1)) * ((n : ℝ) * ((n : ℝ) - 1)) * (∫ x, ∫ x', ∫ y, ∫ y', K x y * K x' y' ∂Q ∂Q ∂P ∂P)
Proof (Lean source)
theorem integral_fixedCount_pairSum_sq (P : Measure X) [IsProbabilityMeasure P] (Q : Measure Y) [IsProbabilityMeasure Q] (K : X → Y → ℝ) (m n : ℕ) (hK : Measurable (uncurry K)) (hK2 : Integrable (fun p : X × Y => K p.1 p.2 ^ 2) (P.prod Q)) : (∫ p : (Fin m → X) × (Fin n → Y), (∑ i : Fin m, ∑ j : Fin n, K (p.1 i) (p.2 j)) ^ 2 ∂((Measure.pi fun _ : Fin m => P).prod (Measure.pi fun _ : Fin n => Q))) = (m : ℝ) * (n : ℝ) * (∫ x, ∫ y, K x y * K x y ∂Q ∂P) + (m : ℝ) * ((n : ℝ) * ((n : ℝ) - 1)) * (∫ x, ∫ y, ∫ y', K x y * K x y' ∂Q ∂Q ∂P) + ((m : ℝ) * ((m : ℝ) - 1)) * (n : ℝ) * (∫ x, ∫ x', ∫ y, K x y * K x' y ∂Q ∂P ∂P) + ((m : ℝ) * ((m : ℝ) - 1)) * ((n : ℝ) * ((n : ℝ) - 1)) * (∫ x, ∫ x', ∫ y, ∫ y', K x y * K x' y' ∂Q ∂Q ∂P ∂P) := by classical let μ := (Measure.pi fun _ : Fin m => P).prod (Measure.pi fun _ : Fin n => Q) have hprod (i k : Fin m) (j l : Fin n) := integrable_fixedCount_kernelProduct P Q K m n hK hK2 i k j l change (∫ p, (∑ i, ∑ j, K (p.1 i) (p.2 j)) ^ 2 ∂μ) = _ rw [integral_bilinearSum_sq_eq_coincidence μ (fun i j p => K (p.1 i) (p.2 j)) (fun i j k l => hprod i k j l)] dsimp only [μ] simp_rw [integral_fixedCount_both_equal P Q K m n hK hK2] have hB : (∑ i : Fin m, ∑ j : Fin n, ∑ l ∈ Finset.univ.erase j, ∫ p, K (p.1 i) (p.2 j) * K (p.1 i) (p.2 l) ∂μ) = ∑ i : Fin m, ∑ j : Fin n, ∑ l ∈ Finset.univ.erase j, ∫ x, ∫ y, ∫ y', K x y * K x y' ∂Q ∂Q ∂P := by apply Finset.sum_congr rfl; intro i _ apply Finset.sum_congr rfl; intro j _ apply Finset.sum_congr rfl; intro l hl exact integral_fixedCount_shared_left P Q K m n hK hK2 i j l ((Finset.mem_erase.mp hl).1.symm) have hC : (∑ i : Fin m, ∑ j : Fin n, ∑ k ∈ Finset.univ.erase i, ∫ p, K (p.1 i) (p.2 j) * K (p.1 k) (p.2 j) ∂μ) = ∑ i : Fin m, ∑ j : Fin n, ∑ k ∈ Finset.univ.erase i, ∫ x, ∫ x', ∫ y, K x y * K x' y ∂Q ∂P ∂P := by apply Finset.sum_congr rfl; intro i _ apply Finset.sum_congr rfl; intro j _ apply Finset.sum_congr rfl; intro k hk exact integral_fixedCount_shared_right P Q K m n hK hK2 i k j ((Finset.mem_erase.mp hk).1.symm) have hD : (∑ i : Fin m, ∑ j : Fin n, ∑ k ∈ Finset.univ.erase i, ∑ l ∈ Finset.univ.erase j, ∫ p, K (p.1 i) (p.2 j) * K (p.1 k) (p.2 l) ∂μ) = ∑ i : Fin m, ∑ j : Fin n, ∑ k ∈ Finset.univ.erase i, ∑ l ∈ Finset.univ.erase j, ∫ x, ∫ x', ∫ y, ∫ y', K x y * K x' y' ∂Q ∂Q ∂P ∂P := by apply Finset.sum_congr rfl; intro i _ apply Finset.sum_congr rfl; intro j _ apply Finset.sum_congr rfl; intro k hk apply Finset.sum_congr rfl; intro l hl exact integral_fixedCount_both_distinct P Q K m n hK hK2 i k j l ((Finset.mem_erase.mp hk).1.symm) ((Finset.mem_erase.mp hl).1.symm) rw [hB, hC, hD] simp only [Finset.sum_const, nsmul_eq_mul, Finset.card_univ, Fintype.card_fin] simp only [Finset.cast_card_erase_of_mem (Finset.mem_univ _)] simp only [Finset.sum_const, nsmul_eq_mul, Finset.card_univ, Fintype.card_fin] ring
Causalean.Mathlib.Probability.Poisson.PairSecondMoment.integral_fixedCount_pairSum_sq · Causalean/Mathlib/Probability/Poisson/PairSecondMoment/FixedCount.lean:115
2 supporting declarations (lemmas, instances)
Integrability 1 core · 3 supporting The squared bilinear statistic is bounded on each fixed-count fibre by the count product squared times the one-pair squared-kernel moment. ★ lintegral_pairSum_sq_lt_top

Measurability and count envelopes for a Poisson pair sum

The squared bilinear statistic is bounded on each fixed-count fibre by the count product squared times the one-pair squared-kernel moment. This provides the summable nonnegative envelope for the two independent Poisson counts.

theorem lintegral_pairSum_sq_lt_top reviewed
Causalean.Mathlib.Probability.Poisson.PairSecondMoment

Given two probability laws, their nonnegative Poisson rates, a measurable real kernel, and an integrable kernel square, the nonnegative integral of the squared bilinear sample sum is finite.

Formal statement
X :
Type u_1
shared
Y :
Type u_2
shared
rateA rateB :
ℝ≥0
K :
X → Y → ℝ
hK :
hK2 :
Integrable (fun p : X × Y => K p.1 p.2 ^ 2) (P.prod Q)
(∫⁻ p : FiniteSample X × FiniteSample Y, ofReal (pairSum K p.1 p.2 ^ 2) ∂((finitePoissonSampleLaw P rateA).prod (finitePoissonSampleLaw Q rateB))) < ⊤
Proof (Lean source)
theorem lintegral_pairSum_sq_lt_top (P : Measure X) [IsProbabilityMeasure P] (Q : Measure Y) [IsProbabilityMeasure Q] (rateA rateB : ℝ≥0) (K : X → Y → ℝ) (hK : Measurable (uncurry K)) (hK2 : Integrable (fun p : X × Y => K p.1 p.2 ^ 2) (P.prod Q)) : (∫⁻ p : FiniteSample X × FiniteSample Y, ofReal (pairSum K p.1 p.2 ^ 2) ∂((finitePoissonSampleLaw P rateA).prod (finitePoissonSampleLaw Q rateB))) < ⊤ := by -- Expand by `lintegral_pair_count_mixture`. Apply -- `lintegral_fixedCount_pairSum_sq_le` termwise, factor the constant -- one-pair lintegral out of the double series, and apply -- `poisson_pair_count_sq_series_lt_top`. Measurability of the ENNReal -- integrand follows from `measurable_pairSum K hK`, `Measurable.pow_const`, -- and `ENNReal.measurable_ofReal`. The one-pair lintegral is finite by -- `hK2.lintegral_lt_top`; handle a zero value before cancelling or -- reassociating an infinite ENNReal factor. let C : ℝ≥0∞ := ∫⁻ p : X × Y, ofReal (K p.1 p.2 ^ 2) ∂(P.prod Q) have hC : C < ⊤ := by have h := hK2.lintegral_lt_top exact h have hmeas : Measurable (fun p : FiniteSample X × FiniteSample Y => ofReal (pairSum K p.1 p.2 ^ 2)) := ENNReal.measurable_ofReal.comp ((measurable_pairSum K hK).pow_const 2) rw [lintegral_pair_count_mixture P Q rateA rateB _ hmeas] have hbound (m n : ℕ) : (poissonMeasure rateA) ({m} : Set ℕ) * (poissonMeasure rateB) ({n} : Set ℕ) * (∫⁻ p : (Fin m → X) × (Fin n → Y), ofReal (pairSum K ⟨m, p.1⟩ ⟨n, p.2⟩ ^ 2) ∂((Measure.pi fun _ : Fin m => P).prod (Measure.pi fun _ : Fin n => Q))) ≤ ((poissonMeasure rateA) ({m} : Set ℕ) * (poissonMeasure rateB) ({n} : Set ℕ) * ((m : ℝ≥0∞) ^ 2 * (n : ℝ≥0∞) ^ 2)) * C := by have h := lintegral_fixedCount_pairSum_sq_le P Q K m n hK hK2 dsimp only [pairSum] calc _ ≤ (poissonMeasure rateA) ({m} : Set ℕ) * (poissonMeasure rateB) ({n} : Set ℕ) * ((m : ℝ≥0∞) ^ 2 * (n : ℝ≥0∞) ^ 2 * C) := by gcongr _ = _ := by ac_rfl have hsum := poisson_pair_count_sq_series_lt_top rateA rateB have hle : (∑' m : ℕ, ∑' n : ℕ, (poissonMeasure rateA) ({m} : Set ℕ) * (poissonMeasure rateB) ({n} : Set ℕ) * (∫⁻ p : (Fin m → X) × (Fin n → Y), ofReal (pairSum K ⟨m, p.1⟩ ⟨n, p.2⟩ ^ 2) ∂((Measure.pi fun _ : Fin m => P).prod (Measure.pi fun _ : Fin n => Q)))) ≤ (∑' m : ℕ, ∑' n : ℕ, (poissonMeasure rateA) ({m} : Set ℕ) * (poissonMeasure rateB) ({n} : Set ℕ) * ((m : ℝ≥0∞) ^ 2 * (n : ℝ≥0∞) ^ 2)) * C := by calc _ ≤ ∑' m : ℕ, ∑' n : ℕ, ((poissonMeasure rateA) ({m} : Set ℕ) * (poissonMeasure rateB) ({n} : Set ℕ) * ((m : ℝ≥0∞) ^ 2 * (n : ℝ≥0∞) ^ 2)) * C := by exact ENNReal.tsum_le_tsum fun m => ENNReal.tsum_le_tsum fun n => hbound m n _ = _ := by simp_rw [ENNReal.tsum_mul_right] exact lt_of_le_of_lt hle (ENNReal.mul_lt_top hsum hC)
Causalean.Mathlib.Probability.Poisson.PairSecondMoment.lintegral_pairSum_sq_lt_top · Causalean/Mathlib/Probability/Poisson/PairSecondMoment/Integrability.lean:198 · uses FiniteSample , finitePoissonSampleLaw , pairSum
3 supporting declarations (lemmas, instances)
  • measurable_pairSum theorem — Given a real kernel with a measurable uncurried form, its bilinear sum over pairs of finite samples is measurable.
    X :
    Type u_1
    shared
    Y :
    Type u_2
    shared
    K :
    X → Y → ℝ
    hK :
    Measurable (fun p : FiniteSample X × FiniteSample Y => pairSum K p.1 p.2)
    Proof (Lean source)
    @[fun_prop] theorem measurable_pairSum (K : X → Y → ℝ) (hK : Measurable (uncurry K)) : Measurable (fun p : FiniteSample X × FiniteSample Y => pairSum K p.1 p.2) := by -- Use the sigma-type measurable-space constructor: on each pair of count -- fibres this is a finite sum of measurable coordinate evaluations. classical have hEmbedX (k : ℕ) : MeasurableEmbedding (fixedSizeEmbed (X := X) k) := by refine ⟨?_, measurable_fixedSizeEmbed k, ?_⟩ · intro x y h simpa [fixedSizeEmbed] using h · intro s hs change MeasurableSet[⨅ a, MeasurableSpace.map (@Sigma.mk ℕ (fun r => Fin r → X) a) inferInstance] (@Sigma.mk ℕ (fun r => Fin r → X) k '' s) simp only [MeasurableSpace.measurableSet_iInf] intro a change MeasurableSet ((@Sigma.mk ℕ (fun r => Fin r → X) a) ⁻¹' (@Sigma.mk ℕ (fun r => Fin r → X) k '' s)) by_cases h : a = k · subst a have hinj : Injective (@Sigma.mk ℕ (fun r => Fin r → X) k) := by intro x y hxy simpa using hxy rw [hinj.preimage_image] exact hs · rw [Set.preimage_image_sigmaMk_of_ne h] exact MeasurableSet.empty have hEmbedY (k : ℕ) : MeasurableEmbedding (fixedSizeEmbed (X := Y) k) := by refine ⟨?_, measurable_fixedSizeEmbed k, ?_⟩ · intro x y h simpa [fixedSizeEmbed] using h · intro s hs change MeasurableSet[⨅ a, MeasurableSpace.map (@Sigma.mk ℕ (fun r => Fin r → Y) a) inferInstance] (@Sigma.mk ℕ (fun r => Fin r → Y) k '' s) simp only [MeasurableSpace.measurableSet_iInf] intro a change MeasurableSet ((@Sigma.mk ℕ (fun r => Fin r → Y) a) ⁻¹' (@Sigma.mk ℕ (fun r => Fin r → Y) k '' s)) by_cases h : a = k · subst a have hinj : Injective (@Sigma.mk ℕ (fun r => Fin r → Y) k) := by intro x y hxy simpa using hxy rw [hinj.preimage_image] exact hs · rw [Set.preimage_image_sigmaMk_of_ne h] exact MeasurableSet.empty have hfiber (m n : ℕ) : Measurable (fun p : (Fin m → X) × (Fin n → Y) => ∑ i : Fin m, ∑ j : Fin n, K (p.1 i) (p.2 j)) := by apply Finset.measurable_sum intro i _ apply Finset.measurable_sum intro j _ have hpair : Measurable (fun p : (Fin m → X) × (Fin n → Y) => (p.1 i, p.2 j)) := ((measurable_pi_apply i).comp measurable_fst).prodMk ((measurable_pi_apply j).comp measurable_snd) simpa only [Function.comp_def, uncurry] using hK.comp hpair intro s hs have hpre : (fun p : FiniteSample X × FiniteSample Y => pairSum K p.1 p.2) ⁻¹' s = ⋃ m : ℕ, ⋃ n : ℕ, (map (fixedSizeEmbed (X := X) m) (fixedSizeEmbed (X := Y) n)) '' ((fun p : (Fin m → X) × (Fin n → Y) => ∑ i : Fin m, ∑ j : Fin n, K (p.1 i) (p.2 j)) ⁻¹' s) := by ext p rcases p with ⟨⟨m, x⟩, ⟨n, y⟩⟩ constructor · intro hp refine Set.mem_iUnion.mpr ⟨m, Set.mem_iUnion.mpr ⟨n, ?_⟩⟩ refine ⟨(x, y), ?_, ?_⟩ · simpa [pairSum] using hp · rfl · simp only [Set.mem_iUnion, Set.mem_image, Set.mem_preimage] at * rintro ⟨m', n', q, hq, heq⟩ change (fun p : FiniteSample X × FiniteSample Y => pairSum K p.1 p.2) (⟨m, x⟩, ⟨n, y⟩) ∈ s rw [← heq] change (∑ i : Fin m', ∑ j : Fin n', K (q.1 i) (q.2 j)) ∈ s exact hq rw [hpre] exact MeasurableSet.iUnion fun m => MeasurableSet.iUnion fun n => ((hEmbedX m).prodMap (hEmbedY n)).measurableSet_image.mpr ((hfiber m n) hs)
    Causalean.Mathlib.Probability.Poisson.PairSecondMoment.measurable_pairSum · Causalean/Mathlib/Probability/Poisson/PairSecondMoment/Integrability.lean:26
  • integral_fixedCount_pairSum_sq_le theorem — Given two probability laws, a measurable real kernel, an integrable kernel square, and two fixed array lengths, the expected squared bilinear sum is bounded by the squared length product times the one-pair squared-kernel moment.
    X :
    Type u_1
    shared
    Y :
    Type u_2
    shared
    K :
    X → Y → ℝ
    m n :
    ℕ
    hK :
    hK2 :
    Integrable (fun p : X × Y => K p.1 p.2 ^ 2) (P.prod Q)
    (∫ p : (Fin m → X) × (Fin n → Y), (∑ i : Fin m, ∑ j : Fin n, K (p.1 i) (p.2 j)) ^ 2 ∂((Measure.pi fun _ : Fin m => P).prod (Measure.pi fun _ : Fin n => Q)))
    ≤ (m : ℝ) ^ 2 * (n : ℝ) ^ 2 * (∫ x, ∫ y, K x y ^ 2 ∂Q ∂P)
    Proof (Lean source)
    theorem integral_fixedCount_pairSum_sq_le (P : Measure X) [IsProbabilityMeasure P] (Q : Measure Y) [IsProbabilityMeasure Q] (K : X → Y → ℝ) (m n : ℕ) (hK : Measurable (uncurry K)) (hK2 : Integrable (fun p : X × Y => K p.1 p.2 ^ 2) (P.prod Q)) : (∫ p : (Fin m → X) × (Fin n → Y), (∑ i : Fin m, ∑ j : Fin n, K (p.1 i) (p.2 j)) ^ 2 ∂((Measure.pi fun _ : Fin m => P).prod (Measure.pi fun _ : Fin n => Q))) ≤ (m : ℝ) ^ 2 * (n : ℝ) ^ 2 * (∫ x, ∫ y, K x y ^ 2 ∂Q ∂P) := by -- Integrate `pairSum_sq_le_count_mul_sum_sq`, using -- `integrable_fixedCount_pairSum_sq` and the termwise integrability from -- `integral_fixedCount_sum_kernel_sq`; then evaluate the finite sum. classical let μ := (Measure.pi fun _ : Fin m => P).prod (Measure.pi fun _ : Fin n => Q) have hsum : Integrable (fun p : (Fin m → X) × (Fin n → Y) => ∑ i : Fin m, ∑ j : Fin n, K (p.1 i) (p.2 j) ^ 2) μ := by apply integrable_finsetSum intro i _ apply integrable_finsetSum intro j _ simpa only [pow_two] using (integrable_fixedCount_kernelProduct P Q K m n hK hK2 i i j j) have hle := integral_mono (integrable_fixedCount_pairSum_sq P Q K m n hK hK2) (hsum.const_mul ((m : ℝ) * (n : ℝ))) (fun p => pairSum_sq_le_count_mul_sum_sq K ⟨m, p.1⟩ ⟨n, p.2⟩) change (∫ p, (∑ i : Fin m, ∑ j : Fin n, K (p.1 i) (p.2 j)) ^ 2 ∂μ) ≤ _ at hle ⊢ rw [integral_const_mul, integral_fixedCount_sum_kernel_sq P Q K m n hK hK2] at hle nlinarith [hle]
    Causalean.Mathlib.Probability.Poisson.PairSecondMoment.integral_fixedCount_pairSum_sq_le · Causalean/Mathlib/Probability/Poisson/PairSecondMoment/Integrability.lean:120
  • lintegral_fixedCount_pairSum_sq_le theorem — Given two probability laws, a measurable real kernel, an integrable kernel square, and two fixed array lengths, the nonnegative squared-sum integral is bounded by the two squared counts times the one-pair squared-kernel integral.
    X :
    Type u_1
    shared
    Y :
    Type u_2
    shared
    K :
    X → Y → ℝ
    m n :
    ℕ
    hK :
    hK2 :
    Integrable (fun p : X × Y => K p.1 p.2 ^ 2) (P.prod Q)
    (∫⁻ p : (Fin m → X) × (Fin n → Y), ofReal ((∑ i : Fin m, ∑ j : Fin n, K (p.1 i) (p.2 j)) ^ 2) ∂((Measure.pi fun _ : Fin m => P).prod (Measure.pi fun _ : Fin n => Q)))
    ≤ (m : ℝ≥0∞) ^ 2 * (n : ℝ≥0∞) ^ 2 * (∫⁻ p : X × Y, ofReal (K p.1 p.2 ^ 2) ∂(P.prod Q))
    Proof (Lean source)
    theorem lintegral_fixedCount_pairSum_sq_le (P : Measure X) [IsProbabilityMeasure P] (Q : Measure Y) [IsProbabilityMeasure Q] (K : X → Y → ℝ) (m n : ℕ) (hK : Measurable (uncurry K)) (hK2 : Integrable (fun p : X × Y => K p.1 p.2 ^ 2) (P.prod Q)) : (∫⁻ p : (Fin m → X) × (Fin n → Y), ofReal ((∑ i : Fin m, ∑ j : Fin n, K (p.1 i) (p.2 j)) ^ 2) ∂((Measure.pi fun _ : Fin m => P).prod (Measure.pi fun _ : Fin n => Q))) ≤ (m : ℝ≥0∞) ^ 2 * (n : ℝ≥0∞) ^ 2 * (∫⁻ p : X × Y, ofReal (K p.1 p.2 ^ 2) ∂(P.prod Q)) := by -- Convert both nonnegative lintegrals to real integrals with -- `ofReal_integral_eq_lintegral_ofReal`; use the proved fixed-count real -- bound, `integral_prod`, and nonnegativity of each square. Reassociate -- `ofReal` products using nonnegative factors. classical let μ := (Measure.pi fun _ : Fin m => P).prod (Measure.pi fun _ : Fin n => Q) have hfixed := ofReal_integral_eq_lintegral_ofReal (integrable_fixedCount_pairSum_sq P Q K m n hK hK2) (Filter.Eventually.of_forall fun p => sq_nonneg (∑ i : Fin m, ∑ j : Fin n, K (p.1 i) (p.2 j))) have hpair := ofReal_integral_eq_lintegral_ofReal hK2 (Filter.Eventually.of_forall fun p => sq_nonneg (K p.1 p.2)) have hbound := integral_fixedCount_pairSum_sq_le P Q K m n hK hK2 rw [← integral_prod _ hK2] at hbound change (∫ p, (∑ i : Fin m, ∑ j : Fin n, K (p.1 i) (p.2 j)) ^ 2 ∂μ) ≤ _ at hbound change (∫⁻ p, ofReal ((∑ i : Fin m, ∑ j : Fin n, K (p.1 i) (p.2 j)) ^ 2) ∂μ) ≤ _ rw [← hfixed, ← hpair] rw [← ENNReal.ofReal_natCast, ← ENNReal.ofReal_natCast] rw [← ENNReal.ofReal_pow, ← ENNReal.ofReal_pow, ← ENNReal.ofReal_mul (by positivity : 0 ≤ (m : ℝ) ^ 2), ← ENNReal.ofReal_mul (by positivity : 0 ≤ (m : ℝ) ^ 2 * (n : ℝ) ^ 2)] all_goals first | exact ENNReal.ofReal_le_ofReal hbound | positivity
    Causalean.Mathlib.Probability.Poisson.PairSecondMoment.lintegral_fixedCount_pairSum_sq_le · Causalean/Mathlib/Probability/Poisson/PairSecondMoment/Integrability.lean:157
Main 1 core · 1 supporting The bilinear statistic over two independent streams splits into the four index-coincidence patterns. ★ integral_pairSum_sq

Exact second moment for two independent finite Poisson samples

The bilinear statistic over two independent streams splits into the four index-coincidence patterns. Separate count laws supply the two rate factors.

theorem integral_pairSum_sq reviewed
Causalean.Mathlib.Probability.Poisson.PairSecondMoment

Given two probability laws, their nonnegative Poisson rates, a measurable real kernel, and an integrable kernel square, the expected squared bilinear sum over two independent finite Poisson samples is the sum of four terms: the product of the two rates times the mean squared kernel; the first rate times the squared second rate times the mean product of two kernel values sharing the left point with independent right points; the squared first rate times the second rate times the mean product sharing the right point with independent left points; and the product of the squared rates times the mean product at four independent points.

Formal statement
X :
Type u_1
shared
Y :
Type u_2
shared
rateA rateB :
ℝ≥0
K :
X → Y → ℝ
hK :
hK2 :
Integrable (fun p : X × Y => K p.1 p.2 ^ 2) (P.prod Q)
(∫ p : FiniteSample X × FiniteSample Y, pairSum K p.1 p.2 ^ 2 ∂((finitePoissonSampleLaw P rateA).prod (finitePoissonSampleLaw Q rateB)))
= (rateA : ℝ) * (rateB : ℝ) * (∫ x, ∫ y, K x y * K x y ∂Q ∂P)
+ (rateA : ℝ) * (rateB : ℝ) ^ 2 * (∫ x, ∫ y, ∫ y', K x y * K x y' ∂Q ∂Q ∂P)
+ (rateA : ℝ) ^ 2 * (rateB : ℝ) * (∫ x, ∫ x', ∫ y, K x y * K x' y ∂Q ∂P ∂P)
+ (rateA : ℝ) ^ 2 * (rateB : ℝ) ^ 2 * (∫ x, ∫ x', ∫ y, ∫ y', K x y * K x' y' ∂Q ∂Q ∂P ∂P)
Proof (Lean source)
theorem integral_pairSum_sq (P : Measure X) [IsProbabilityMeasure P] (Q : Measure Y) [IsProbabilityMeasure Q] (rateA rateB : ℝ≥0) (K : X → Y → ℝ) (hK : Measurable (uncurry K)) (hK2 : Integrable (fun p : X × Y => K p.1 p.2 ^ 2) (P.prod Q)) : (∫ p : FiniteSample X × FiniteSample Y, pairSum K p.1 p.2 ^ 2 ∂((finitePoissonSampleLaw P rateA).prod (finitePoissonSampleLaw Q rateB))) = (rateA : ℝ) * (rateB : ℝ) * (∫ x, ∫ y, K x y * K x y ∂Q ∂P) + (rateA : ℝ) * (rateB : ℝ) ^ 2 * (∫ x, ∫ y, ∫ y', K x y * K x y' ∂Q ∂Q ∂P) + (rateA : ℝ) ^ 2 * (rateB : ℝ) * (∫ x, ∫ x', ∫ y, K x y * K x' y ∂Q ∂P ∂P) + (rateA : ℝ) ^ 2 * (rateB : ℝ) ^ 2 * (∫ x, ∫ x', ∫ y, ∫ y', K x y * K x' y' ∂Q ∂Q ∂P ∂P) := by let f (m : ℕ) : ℝ := m let g (m : ℕ) : ℝ := (m : ℝ) * ((m : ℝ) - 1) let c₀ : ℝ := ∫ x, ∫ y, K x y * K x y ∂Q ∂P let c₁ : ℝ := ∫ x, ∫ y, ∫ y', K x y * K x y' ∂Q ∂Q ∂P let c₂ : ℝ := ∫ x, ∫ x', ∫ y, K x y * K x' y ∂Q ∂P ∂P let c₃ : ℝ := ∫ x, ∫ x', ∫ y, ∫ y', K x y * K x' y' ∂Q ∂Q ∂P ∂P let wA (m : ℕ) : ℝ := ((poissonMeasure rateA) ({m} : Set ℕ)).toReal let wB (n : ℕ) : ℝ := ((poissonMeasure rateB) ({n} : Set ℕ)).toReal let term (u v : ℕ → ℝ) (c : ℝ) (p : ℕ × ℕ) : ℝ := wA p.1 * wB p.2 * (u p.1 * v p.2 * c) have hfA : Integrable f (poissonMeasure rateA) := (poisson_natCast_memLp_two rateA).integrable (by norm_num) have hfB : Integrable f (poissonMeasure rateB) := (poisson_natCast_memLp_two rateB).integrable (by norm_num) have hgA : Integrable g (poissonMeasure rateA) := integrable_poisson_ordered_pairs rateA have hgB : Integrable g (poissonMeasure rateB) := integrable_poisson_ordered_pairs rateB have h₀ : Summable (term f f c₀) := summable_poisson_pair_product rateA rateB f f c₀ hfA hfB have h₁ : Summable (term f g c₁) := summable_poisson_pair_product rateA rateB f g c₁ hfA hgB have h₂ : Summable (term g f c₂) := summable_poisson_pair_product rateA rateB g f c₂ hgA hfB have h₃ : Summable (term g g c₃) := summable_poisson_pair_product rateA rateB g g c₃ hgA hgB rw [integral_pair_count_mixture P Q rateA rateB _ (integrable_pairSum_sq P Q rateA rateB K hK hK2)] have hfixed (m n : ℕ) : (∫ p : (Fin m → X) × (Fin n → Y), pairSum K ⟨m, p.1⟩ ⟨n, p.2⟩ ^ 2 ∂((Measure.pi fun _ : Fin m => P).prod (Measure.pi fun _ : Fin n => Q))) = f m * f n * c₀ + f m * g n * c₁ + g m * f n * c₂ + g m * g n * c₃ := by simpa only [pairSum, f, g, c₀, c₁, c₂, c₃] using integral_fixedCount_pairSum_sq P Q K m n hK hK2 simp_rw [hfixed] have hsum : Summable (fun p => term f f c₀ p + term f g c₁ p + term g f c₂ p + term g g c₃ p) := ((h₀.add h₁).add h₂).add h₃ calc (∑' m : ℕ, ∑' n : ℕ, wA m * wB n * (f m * f n * c₀ + f m * g n * c₁ + g m * f n * c₂ + g m * g n * c₃)) = ∑' p : ℕ × ℕ, (term f f c₀ p + term f g c₁ p + term g f c₂ p + term g g c₃ p) := by rw [hsum.tsum_prod] congr 1 funext m congr 1 funext n dsimp [term] ring _ = (∑' p : ℕ × ℕ, term f f c₀ p) + (∑' p : ℕ × ℕ, term f g c₁ p) + (∑' p : ℕ × ℕ, term g f c₂ p) + (∑' p : ℕ × ℕ, term g g c₃ p) := by rw [(h₀.add h₁).add h₂ |>.tsum_add h₃, (h₀.add h₁).tsum_add h₂, h₀.tsum_add h₁] _ = _ := by have hfactor (u v : ℕ → ℝ) (c : ℝ) (hu : Integrable u (poissonMeasure rateA)) (hv : Integrable v (poissonMeasure rateB)) (_hs : Summable (term u v c)) : (∑' p : ℕ × ℕ, term u v c p) = (∫ m : ℕ, u m ∂poissonMeasure rateA) * (∫ n : ℕ, v n ∂poissonMeasure rateB) * c := by have hsbase := summable_poisson_pair_product rateA rateB u v 1 hu hv have h := poisson_pair_weighted_tsum_mul rateA rateB u v hu hv calc _ = (∑' p : ℕ × ℕ, term u v 1 p) * c := by rw [← hsbase.tsum_mul_right c] congr 1 funext p dsimp [term] ring _ = (∑' m : ℕ, ∑' n : ℕ, wA m * wB n * (u m * v n)) * c := by rw [hsbase.tsum_prod] simp only [wA, wB, mul_one] _ = _ := by simpa only [wA, wB] using congrArg (· * c) h rw [hfactor f f c₀ hfA hfB h₀, hfactor f g c₁ hfA hgB h₁, hfactor g f c₂ hgA hfB h₂, hfactor g g c₃ hgA hgB h₃] simp only [f, g, c₀, c₁, c₂, c₃, poisson_count_first_moment, poisson_ordered_pairs_second_moment]
Causalean.Mathlib.Probability.Poisson.PairSecondMoment.integral_pairSum_sq · Causalean/Mathlib/Probability/Poisson/PairSecondMoment/Main.lean:86 · uses FiniteSample , finitePoissonSampleLaw , pairSum
1 supporting declaration (lemmas, instances)
Mixture 1 core · 1 supporting The nonnegative integral of a statistic of two independent finite Poisson samples is a double mixture of fixed-size iid-array integrals. ★ integral_pair_count_mixture

Two independent finite Poisson count fibres

The nonnegative integral of a statistic of two independent finite Poisson samples is a double mixture of fixed-size iid-array integrals. This isolates the count decomposition needed for real-valued moment calculations.

theorem integral_pair_count_mixture reviewed
Causalean.Mathlib.Probability.Poisson.PairSecondMoment

Given two probability observation laws, their nonnegative Poisson rates, and an integrable real statistic of their finite samples, its expectation is the double Poisson-weighted series of fixed-count iid-array expectations.

Formal statement
X :
Type u_1
shared
Y :
Type u_2
shared
rateA rateB :
ℝ≥0
f :
FiniteSample X × FiniteSample Y → ℝ
(∫ p, f p ∂((finitePoissonSampleLaw P rateA).prod (finitePoissonSampleLaw Q rateB)))
= ∑' m : ℕ, ∑' n : ℕ, ((poissonMeasure rateA) ({m} : Set ℕ)).toReal * ((poissonMeasure rateB) ({n} : Set ℕ)).toReal * (∫ p : (Fin m → X) × (Fin n → Y), f (⟨m, p.1⟩, ⟨n, p.2⟩) ∂((Measure.pi fun _ : Fin m => P).prod (Measure.pi fun _ : Fin n => Q)))
Proof (Lean source)
theorem integral_pair_count_mixture (P : Measure X) [IsProbabilityMeasure P] (Q : Measure Y) [IsProbabilityMeasure Q] (rateA rateB : ℝ≥0) (f : FiniteSample X × FiniteSample Y → ℝ) (hf : Integrable f ((finitePoissonSampleLaw P rateA).prod (finitePoissonSampleLaw Q rateB))) : (∫ p, f p ∂((finitePoissonSampleLaw P rateA).prod (finitePoissonSampleLaw Q rateB))) = ∑' m : ℕ, ∑' n : ℕ, ((poissonMeasure rateA) ({m} : Set ℕ)).toReal * ((poissonMeasure rateB) ({n} : Set ℕ)).toReal * (∫ p : (Fin m → X) × (Fin n → Y), f (⟨m, p.1⟩, ⟨n, p.2⟩) ∂((Measure.pi fun _ : Fin m => P).prod (Measure.pi fun _ : Fin n => Q))) := by -- Expand both laws by their disjoint count fibres as in the preceding -- nonnegative theorem. Use `integral_sum_measure hf` twice; integrability -- descends to each fibre by `Integrable.mono_measure`. Then rewrite each -- fibre with `finitePoissonSampleLaw_restrict_count_eq`, map-product -- compatibility, and `integral_smul_measure`. let μA := finitePoissonSampleLaw P rateA let μB := finitePoissonSampleLaw Q rateB change Integrable f (μA.prod μB) at hf change ∫ p, f p ∂(μA.prod μB) = _ rw [finiteSample_count_sum μA, finiteSample_count_sum μB, Measure.prod_sum] at hf ⊢ rw [integral_sum_measure hf] rw [(hasSum_integral_measure hf).summable.tsum_prod] congr 1 funext m congr 1 funext n rw [finitePoissonSampleLaw_restrict_count_eq, finitePoissonSampleLaw_restrict_count_eq, Measure.prod_smul_left, Measure.prod_smul_right, Measure.map_prod_map _ _ (measurable_fixedSizeEmbed m) (measurable_fixedSizeEmbed n), integral_smul_measure, integral_smul_measure] by_cases hA : (poissonMeasure rateA) ({m} : Set ℕ) = 0 · simp [hA] by_cases hB : (poissonMeasure rateB) ({n} : Set ℕ) = 0 · simp [hB] have hFibre : Integrable f ((μA.restrict (FiniteSample.count ⁻¹' ({m} : Set ℕ))).prod (μB.restrict (FiniteSample.count ⁻¹' ({n} : Set ℕ)))) := by apply hf.mono_measure exact Measure.le_sum _ (m, n) rw [finitePoissonSampleLaw_restrict_count_eq, finitePoissonSampleLaw_restrict_count_eq, Measure.prod_smul_left, Measure.prod_smul_right, smul_smul, Measure.map_prod_map _ _ (measurable_fixedSizeEmbed m) (measurable_fixedSizeEmbed n)] at hFibre have hmap : AEStronglyMeasurable f (Measure.map (map (fixedSizeEmbed m) (fixedSizeEmbed n)) ((Measure.pi fun _ : Fin m => P).prod (Measure.pi fun _ : Fin n => Q))) := ((aemeasurable_smul_measure_iff (mul_ne_zero hA hB)).mp hFibre.aestronglyMeasurable.aemeasurable).aestronglyMeasurable rw [integral_map ((measurable_fixedSizeEmbed m).prodMap (measurable_fixedSizeEmbed n)).aemeasurable hmap] simp only [smul_eq_mul, map, fixedSizeEmbed, mul_assoc]
Causalean.Mathlib.Probability.Poisson.PairSecondMoment.integral_pair_count_mixture · Causalean/Mathlib/Probability/Poisson/PairSecondMoment/Mixture.lean:81 · uses FiniteSample , finitePoissonSampleLaw
1 supporting declaration (lemmas, instances)
Moments 1 core · 4 supporting This module supplies the first, ordered-pair, and raw second moments of a scalar Poisson count used to weight the count fibres of a finite Poisson sample. ★ poisson_ordered_pairs_second_moment

Scalar factorial moments of a Poisson count

This module supplies the first, ordered-pair, and raw second moments of a scalar Poisson count used to weight the count fibres of a finite Poisson sample.

theorem poisson_ordered_pairs_second_moment reviewed
Causalean.Mathlib.Probability.Poisson.PairSecondMoment

Under a Poisson law with nonnegative rate, the expected number of ordered pairs of distinct positions, the count times the count minus one, equals the squared rate.

Formal statement
rate :
ℝ≥0
(∫ n : ℕ, (n : ℝ) * ((n : ℝ) - 1) ∂poissonMeasure rate) = (rate : ℝ) ^ 2
Proof (Lean source)
theorem poisson_ordered_pairs_second_moment (rate : ℝ≥0) : (∫ n : ℕ, (n : ℝ) * ((n : ℝ) - 1) ∂poissonMeasure rate) = (rate : ℝ) ^ 2 := by rw [show (fun n : ℕ => (n : ℝ) * ((n : ℝ) - 1)) = fun n => (n.descFactorial 2 : ℝ) by funext n simp only [Nat.cast_descFactorial_two]] rw [integral_poissonMeasure] simp only [smul_eq_mul] let f : ℕ → ℝ := fun n => exp (-(rate : ℝ)) * (rate : ℝ) ^ n / (n.factorial : ℝ) * (n.descFactorial 2 : ℝ) have hshift : Summable (fun k => f (k + 2)) := by apply Summable.congr ((NormedSpace.expSeries_div_hasSum_exp (rate : ℝ)).summable.mul_left ((rate : ℝ) ^ 2 * exp (-(rate : ℝ)))) intro k exact (poisson_descFactorial_two_shift rate k).symm have hprefix : ∑ k ∈ range 2, f k = 0 := by apply Finset.sum_eq_zero intro k hk have hklt : k < 2 := Finset.mem_range.mp hk have hzero : k.descFactorial 2 = 0 := Nat.descFactorial_eq_zero_iff_lt.mpr hklt simp only [f, hzero, Nat.cast_zero, mul_zero] calc ∑' n, exp (-(rate : ℝ)) * (rate : ℝ) ^ n / ↑n.factorial * ↑(n.descFactorial 2) = ∑' n, f n := by rfl _ = ∑ k ∈ range 2, f k + ∑' k, f (k + 2) := (hshift.sum_add_tsum_nat_add').symm _ = ∑' k, (((rate : ℝ) ^ 2 * exp (-(rate : ℝ))) * ((rate : ℝ) ^ k / (k.factorial : ℝ))) := by rw [hprefix, zero_add] congr 1 funext k exact poisson_descFactorial_two_shift rate k _ = ((rate : ℝ) ^ 2 * exp (-(rate : ℝ))) * exp (rate : ℝ) := by rw [tsum_mul_left] simpa only [Real.exp_eq_exp_ℝ] using congrArg (fun z : ℝ => ((rate : ℝ) ^ 2 * exp (-(rate : ℝ))) * z) (NormedSpace.expSeries_div_hasSum_exp (rate : ℝ)).tsum_eq _ = (rate : ℝ) ^ 2 := by rw [mul_assoc, ← Real.exp_add] ring_nf simp
Causalean.Mathlib.Probability.Poisson.PairSecondMoment.poisson_ordered_pairs_second_moment · Causalean/Mathlib/Probability/Poisson/PairSecondMoment/Moments.lean:56
4 supporting declarations (lemmas, instances)
Series 1 core · 0 supporting An integrable function of each count has a product expectation under two independent scalar Poisson laws. ★ poisson_pair_weighted_tsum_mul

Factoring the two independent Poisson count series

An integrable function of each count has a product expectation under two independent scalar Poisson laws. The iterated count series uses the weights that occur in the finite-sample count-mixture formula.

theorem poisson_pair_weighted_tsum_mul reviewed
Causalean.Mathlib.Probability.Poisson.PairSecondMoment

Given two nonnegative Poisson rates, two scalar count functions, and their integrability under the respective Poisson laws, the weighted double count series factors into their two expectations.

Formal statement
rateA rateB :
ℝ≥0
f g :
ℕ → ℝ
hf :
hg :
(∑' m : ℕ, ∑' n : ℕ, ((poissonMeasure rateA) ({m} : Set ℕ)).toReal * ((poissonMeasure rateB) ({n} : Set ℕ)).toReal * (f m * g n))
= (∫ m : ℕ, f m ∂poissonMeasure rateA) * (∫ n : ℕ, g n ∂poissonMeasure rateB)
Proof (Lean source)
theorem poisson_pair_weighted_tsum_mul (rateA rateB : ℝ≥0) (f g : ℕ → ℝ) (hf : Integrable f (poissonMeasure rateA)) (hg : Integrable g (poissonMeasure rateB)) : (∑' m : ℕ, ∑' n : ℕ, ((poissonMeasure rateA) ({m} : Set ℕ)).toReal * ((poissonMeasure rateB) ({n} : Set ℕ)).toReal * (f m * g n)) = (∫ m : ℕ, f m ∂poissonMeasure rateA) * (∫ n : ℕ, g n ∂poissonMeasure rateB) := by -- Apply `integral_countable` to each scalar law, using `hf` and `hg`. -- The weighted series is absolutely summable by the integrability of -- `(fun p : ℕ × ℕ => f p.1 * g p.2)` under the product measure; -- `Summable.tsum_prod` (or two `tsum_mul_*` rewrites) then separates it. let a (m : ℕ) : ℝ := ((poissonMeasure rateA) ({m} : Set ℕ)).toReal * f m let b (n : ℕ) : ℝ := ((poissonMeasure rateB) ({n} : Set ℕ)).toReal * g n have ha : Summable a := by have hdirac : Integrable f (Measure.sum fun m : ℕ => (poissonMeasure rateA) ({m} : Set ℕ) • Measure.dirac m) := by simpa only [Measure.sum_smul_dirac] using hf apply Summable.of_norm simpa only [a, norm_mul, Real.norm_eq_abs, abs_of_nonneg ENNReal.toReal_nonneg] using hdirac.summable_of_dirac have hb : Summable b := by have hdirac : Integrable g (Measure.sum fun n : ℕ => (poissonMeasure rateB) ({n} : Set ℕ) • Measure.dirac n) := by simpa only [Measure.sum_smul_dirac] using hg apply Summable.of_norm simpa only [b, norm_mul, Real.norm_eq_abs, abs_of_nonneg ENNReal.toReal_nonneg] using hdirac.summable_of_dirac have hfa : (∫ m : ℕ, f m ∂poissonMeasure rateA) = ∑' m, a m := by simpa only [a, smul_eq_mul, measureReal_def] using integral_countable hf have hgb : (∫ n : ℕ, g n ∂poissonMeasure rateB) = ∑' n, b n := by simpa only [b, smul_eq_mul, measureReal_def] using integral_countable hg rw [hfa, hgb] calc _ = ∑' m : ℕ, ∑' n : ℕ, a m * b n := by congr 1 funext m congr 1 funext n dsimp [a, b] ring _ = (∑' m : ℕ, a m) * (∑' n : ℕ, b n) := by simpa only [Summable.tsum_mul_left _ hb] using (Summable.tsum_mul_right (∑' n : ℕ, b n) ha)
Causalean.Mathlib.Probability.Poisson.PairSecondMoment.poisson_pair_weighted_tsum_mul · Causalean/Mathlib/Probability/Poisson/PairSecondMoment/Series.lean:20