Stat.Finite­Rao­Blackwell.Poisson.Paired­Histogram.Histogram­Reconstruction

This roll-up module provides parameter-free uniform reconstruction of finite ordered Poisson samples from count histograms, exact reconstruction identities, and total-variation transport for one or two experiments.

Count­Law 2 core · 1 supporting This module defines the product law of independent singleton-cell Poisson counts and identifies it with the histogram image of a finite Poisson sample. ★ finitePoissonSampleLaw_map_histogram

Independent Poisson law of a finite-sample histogram

This module defines the product law of independent singleton-cell Poisson counts and identifies it with the histogram image of a finite Poisson sample.

def independentPoissonCountLaw reviewed
Causalean.Stat.FiniteRaoBlackwell.PairedPoissonHistogram

Given a finite-alphabet probability law and a Poisson intensity, the independent Poisson count law is the product over alphabet symbols of Poisson laws with rates equal to intensity times singleton probability.

Definition (Lean source)
independentPoissonCountLaw P lambda :
Measure (X → ℕ)
Measure.pi fun x : X ↦ poissonMeasure (lambda * (P {x}).toNNReal)
Causalean.Stat.FiniteRaoBlackwell.PairedPoissonHistogram.independentPoissonCountLaw · Causalean/Stat/FiniteRaoBlackwell/Poisson/PairedHistogram/HistogramReconstruction/CountLaw.lean:29
theorem finitePoissonSampleLaw_map_histogram reviewed
Causalean.Stat.FiniteRaoBlackwell.PairedPoissonHistogram

Given a finite-alphabet probability law and a Poisson intensity, the histogram of its finite Poisson sample has the product law of independent Poisson cell counts.

Formal statement
Measure.map (fun s : FiniteSample X ↦ finiteSampleHistogram s.points) (finitePoissonSampleLaw P lambda)
Proof (Lean source)
theorem finitePoissonSampleLaw_map_histogram {X : Type*} [Fintype X] [MeasurableSpace X] [MeasurableSingletonClass X] [DecidableEq X] (P : Measure X) [IsProbabilityMeasure P] (lambda : ℝ≥0) : Measure.map (fun s : FiniteSample X ↦ finiteSampleHistogram s.points) (finitePoissonSampleLaw P lambda) = independentPoissonCountLaw P lambda := by let p : FiniteMeasurablePartition X X := { cell := id measurable_cell := measurable_id } let R : Measure ℝ := Measure.dirac 0 let markedCounts : FiniteSample (X × ℝ) → X → ℕ := fun s x => (p.restrictCell x s).count let countFamily : (X → FiniteSample (X × ℝ)) → X → ℕ := fun q x => (q x).count have hcountFamily : Measurable countFamily := measurable_pi_lambda _ fun x => measurable_finiteSample_count.comp (measurable_pi_apply x) have hmarked : Measure.map markedCounts (finiteMarkedPoissonSampleLaw P R lambda) = Measure.pi (fun x : X => poissonMeasure (lambda * p.cellMass P x)) := by calc Measure.map markedCounts (finiteMarkedPoissonSampleLaw P R lambda) = Measure.map countFamily (Measure.map p.restrictPartition (finiteMarkedPoissonSampleLaw P R lambda)) := by rw [Measure.map_map hcountFamily p.measurable_restrictPartition] rfl _ = Measure.map countFamily (Measure.pi (fun x : X => finiteMarkedPoissonSampleLaw (p.cellObservationLaw P x) R (lambda * p.cellMass P x))) := by rw [p.map_restrictPartition_finiteMarkedPoissonSampleLaw] _ = Measure.pi (fun x : X => Measure.map FiniteSample.count (finiteMarkedPoissonSampleLaw (p.cellObservationLaw P x) R (lambda * p.cellMass P x))) := by exact Measure.pi_map_pi (fun _ => measurable_finiteSample_count.aemeasurable) _ = Measure.pi (fun x : X => poissonMeasure (lambda * p.cellMass P x)) := by congr with x rw [finiteMarkedPoissonSampleLaw_map_count] have herase := map_finitePoissonSampleLaw_finiteSampleMap (P.prod (Measure.dirac (0 : ℝ))) Prod.fst measurable_fst lambda have hprod : Measure.map Prod.fst (P.prod (Measure.dirac (0 : ℝ))) = P := by rw [Measure.map_fst_prod, measure_univ, one_smul] have herase' : Measure.map (finiteSampleMap Prod.fst) (finitePoissonSampleLaw (P.prod (Measure.dirac (0 : ℝ))) lambda) = finitePoissonSampleLaw P lambda := by simpa only [hprod] using herase have hcounts (s : FiniteSample (X × ℝ)) : markedCounts s = finiteSampleHistogram (finiteSampleMap Prod.fst s).points := by classical rcases s with ⟨n, points⟩ funext x unfold markedCounts finiteSampleHistogram FiniteMeasurablePartition.restrictCell simp only [FiniteSample.count, finiteSampleMap, FiniteSample.points] unfold FiniteMeasurablePartition.cellIndices let q : Fin n → Prop := fun i => p.cell (FiniteSample.points (⟨n, points⟩ : FiniteSample (X × ℝ)) i).1 = x let hq : DecidablePred q := fun _ => Classical.propDecidable _ letI : DecidablePred q := hq change (Finset.univ.filter q).card = card {i : Fin n // (points i).1 = x} calc (Finset.univ.filter q).card = card {i : Fin n // q i} := (Fintype.card_subtype q).symm _ = card {i : Fin n // (points i).1 = x} := Fintype.card_congr (Equiv.subtypeEquivRight fun i => by simp [q, p, FiniteSample.points]) have hhist : Measurable (fun s : FiniteSample X => finiteSampleHistogram s.points) := by apply measurable_to_countable' intro c rw [MeasurableSpace.measurableSet_iInf] intro n change MeasurableSet ((Sigma.mk n) ⁻¹' {s : FiniteSample X | finiteSampleHistogram s.points = c}) exact (Set.to_countable _).measurableSet unfold independentPoissonCountLaw change _ = Measure.pi (fun x : X => poissonMeasure (lambda * p.cellMass P x)) rw [← hmarked, ← herase', show finiteMarkedPoissonSampleLaw P (Measure.dirac (0 : ℝ)) lambda = finitePoissonSampleLaw (P.prod (Measure.dirac (0 : ℝ))) lambda by rfl, Measure.map_map hhist (measurable_finiteSampleMap Prod.fst measurable_fst)] exact congrArg (fun f : FiniteSample (X × ℝ) → (X → ℕ) => Measure.map f (finitePoissonSampleLaw (P.prod (Measure.dirac (0 : ℝ))) lambda)) (funext fun s => (hcounts s).symm)
1 supporting declaration (lemmas, instances)
Kernel 3 core · 3 supporting This module constructs the parameter-free Markov kernel which reconstructs a finite ordered sample uniformly from the orderings compatible with a supplied finite count vector, and records its singleton mass and support i ★ histogramReconstructionKernel_histogram_eq

The uniform histogram-fibre kernel

This module constructs the parameter-free Markov kernel which reconstructs a finite ordered sample uniformly from the orderings compatible with a supplied finite count vector, and records its singleton mass and support identities.

def histogramReconstructionPMF reviewed
Causalean.Stat.FiniteRaoBlackwell.PairedPoissonHistogram

Given a finite count vector, the histogram reconstruction distribution is uniform over all ordered samples having exactly those counts. Its definition depends only on the count vector, not on a sampling law or intensity.

Definition (Lean source)
histogramReconstructionPMF c :
by classical letI : Nonempty (HistogramFiber c) := histogramFiber_nonempty c exact (uniformOfFintype (HistogramFiber c)).map (fun x ↦ fixedSizeEmbed (histogramTotal c) x.1)
Causalean.Stat.FiniteRaoBlackwell.PairedPoissonHistogram.histogramReconstructionPMF · Causalean/Stat/FiniteRaoBlackwell/Poisson/PairedHistogram/HistogramReconstruction/Kernel.lean:30 · uses FiniteSample
def histogramReconstructionKernel reviewed
Causalean.Stat.FiniteRaoBlackwell.PairedPoissonHistogram

On a finite measurable alphabet, the histogram reconstruction kernel sends every count vector to the uniform distribution on its ordered histogram fibre.

Definition (Lean source)
histogramReconstructionKernel X :
Kernel (X → ℕ) (FiniteSample X)
Kernel.ofFunOfCountable fun c ↦ (histogramReconstructionPMF c).toMeasure
Causalean.Stat.FiniteRaoBlackwell.PairedPoissonHistogram.histogramReconstructionKernel · Causalean/Stat/FiniteRaoBlackwell/Poisson/PairedHistogram/HistogramReconstruction/Kernel.lean:43 · uses FiniteSample
theorem histogramReconstructionKernel_histogram_eq reviewed
Causalean.Stat.FiniteRaoBlackwell.PairedPoissonHistogram

Given a count vector, reconstruction is supported entirely on finite ordered samples whose histogram is exactly that vector.

Formal statement
Proof (Lean source)
theorem histogramReconstructionKernel_histogram_eq {X : Type*} [Fintype X] [MeasurableSpace X] [MeasurableSingletonClass X] [DecidableEq X] (c : X → ℕ) : histogramReconstructionKernel X c {s : FiniteSample X | finiteSampleHistogram s.points = c} = 1 := by -- Rewrite the PMF map on this event. Every fibre element lands in it by -- its subtype certificate, so the preimage is `univ`. classical change (histogramReconstructionPMF c).toMeasure {s : FiniteSample X | finiteSampleHistogram s.points = c} = 1 have hs : MeasurableSet {s : FiniteSample X | finiteSampleHistogram s.points = c} := by rw [MeasurableSpace.measurableSet_iInf] intro n change @MeasurableSet (Fin n → X) inferInstance ((Sigma.mk (β := fun k => Fin k → X) n) ⁻¹' {s : FiniteSample X | finiteSampleHistogram s.points = c}) exact Set.Finite.measurableSet (Set.toFinite _) rw [PMF.toMeasure_apply_eq_toOuterMeasure_apply _ hs] unfold histogramReconstructionPMF rw [PMF.toOuterMeasure_map_apply] have hpre : (fun x : HistogramFiber c => fixedSizeEmbed (histogramTotal c) x.1) ⁻¹' {s : FiniteSample X | finiteSampleHistogram s.points = c} = univ := by ext x simp only [mem_preimage, mem_ofPred_eq, mem_univ, iff_true] exact x.2 rw [hpre] letI : MeasurableSpace (HistogramFiber c) := ⊤ rw [← PMF.toMeasure_apply_eq_toOuterMeasure_apply _ MeasurableSet.univ] exact measure_univ
3 supporting declarations (lemmas, instances)
Paired­Transport 2 core · 2 supporting This module forms the independent product of two histogram reconstruction channels and transfers total variation from paired count experiments to paired ordered finite Poisson samples over possibly unequal finite alphabe ★ pairedIndependentPoissonCountLaw_comp_reconstruction

Paired histogram reconstruction transport

This module forms the independent product of two histogram reconstruction channels and transfers total variation from paired count experiments to paired ordered finite Poisson samples over possibly unequal finite alphabets.

def pairedHistogramReconstructionKernel reviewed
Causalean.Stat.FiniteRaoBlackwell.PairedPoissonHistogram

On two finite measurable alphabets, the paired histogram reconstruction kernel independently reconstructs the two ordered samples from their two count vectors.

Definition (Lean source)
pairedHistogramReconstructionKernel X Y :
Kernel ((X → ℕ) × (Y → ℕ)) (FiniteSample X × FiniteSample Y)
Causalean.Stat.FiniteRaoBlackwell.PairedPoissonHistogram.pairedHistogramReconstructionKernel · Causalean/Stat/FiniteRaoBlackwell/Poisson/PairedHistogram/HistogramReconstruction/PairedTransport.lean:30 · uses FiniteSample
theorem pairedIndependentPoissonCountLaw_comp_reconstruction reviewed
Causalean.Stat.FiniteRaoBlackwell.PairedPoissonHistogram

Given two finite-alphabet probability laws and possibly different Poisson intensities, independently reconstructing their product count law recovers the product of their ordered finite Poisson sample laws exactly.

Formal statement
Proof (Lean source)
theorem pairedIndependentPoissonCountLaw_comp_reconstruction {X Y : Type*} [Fintype X] [MeasurableSpace X] [MeasurableSingletonClass X] [DecidableEq X] [Fintype Y] [MeasurableSpace Y] [MeasurableSingletonClass Y] [DecidableEq Y] (P : Measure X) [IsProbabilityMeasure P] (Q : Measure Y) [IsProbabilityMeasure Q] (lambdaX lambdaY : ℝ≥0) : pairedHistogramReconstructionKernel X Y ∘ₘ ((independentPoissonCountLaw P lambdaX).prod (independentPoissonCountLaw Q lambdaY)) = (finitePoissonSampleLaw P lambdaX).prod (finitePoissonSampleLaw Q lambdaY) := by unfold pairedHistogramReconstructionKernel calc ((histogramReconstructionKernel X) ∥ₖ (histogramReconstructionKernel Y)) ∘ₘ ((independentPoissonCountLaw P lambdaX).prod (independentPoissonCountLaw Q lambdaY)) = ((histogramReconstructionKernel X) ∥ₖ Kernel.id) ∘ₘ ((Kernel.id ∥ₖ (histogramReconstructionKernel Y)) ∘ₘ ((independentPoissonCountLaw P lambdaX).prod (independentPoissonCountLaw Q lambdaY))) := by rw [Measure.comp_assoc, Kernel.parallelComp_comp_parallelComp, Kernel.comp_id, Kernel.id_comp] _ = ((histogramReconstructionKernel X) ∥ₖ Kernel.id) ∘ₘ ((independentPoissonCountLaw P lambdaX).prod ((histogramReconstructionKernel Y) ∘ₘ independentPoissonCountLaw Q lambdaY)) := by rw [← Measure.prod_comp_right] _ = ((histogramReconstructionKernel X) ∘ₘ independentPoissonCountLaw P lambdaX).prod ((histogramReconstructionKernel Y) ∘ₘ independentPoissonCountLaw Q lambdaY) := by rw [Measure.prod_comp_left] _ = (finitePoissonSampleLaw P lambdaX).prod (finitePoissonSampleLaw Q lambdaY) := by rw [independentPoissonCountLaw_comp_reconstruction, independentPoissonCountLaw_comp_reconstruction]
2 supporting declarations (lemmas, instances)
Reconstruction 2 core · 1 supporting This module states the fixed-total and Poissonized identities obtained by mixing the parameter-free uniform histogram-fibre reconstruction kernel. ★ independentPoissonCountLaw_comp_reconstruction

Reconstruction of finite ordered samples from histograms

This module states the fixed-total and Poissonized identities obtained by mixing the parameter-free uniform histogram-fibre reconstruction kernel.

def multinomialHistogramLaw reviewed
Causalean.Stat.FiniteRaoBlackwell.PairedPoissonHistogram

Given a finite-alphabet probability law and a fixed sample size, the multinomial histogram law is the count-vector image of the ordered iid product law.

Definition (Lean source)
multinomialHistogramLaw P n :
Measure (X → ℕ)
Measure.map finiteSampleHistogram (Measure.pi fun _ : Fin n ↦ P)
Causalean.Stat.FiniteRaoBlackwell.PairedPoissonHistogram.multinomialHistogramLaw · Causalean/Stat/FiniteRaoBlackwell/Poisson/PairedHistogram/HistogramReconstruction/Reconstruction.lean:28
theorem independentPoissonCountLaw_comp_reconstruction reviewed
Causalean.Stat.FiniteRaoBlackwell.PairedPoissonHistogram

Given a finite-alphabet probability law and a Poisson intensity, passing its independent cell counts through the parameter-free reconstruction kernel recovers the ordered finite Poisson sample law exactly.

Formal statement
Proof (Lean source)
theorem independentPoissonCountLaw_comp_reconstruction {X : Type*} [Fintype X] [MeasurableSpace X] [MeasurableSingletonClass X] [DecidableEq X] (P : Measure X) [IsProbabilityMeasure P] (lambda : ℝ≥0) : histogramReconstructionKernel X ∘ₘ independentPoissonCountLaw P lambda = finitePoissonSampleLaw P lambda := by let K := histogramReconstructionKernel X let ν := independentPoissonCountLaw P lambda let μ := finitePoissonSampleLaw P lambda have hpiece (N : ℕ) : K ∘ₘ ν.restrict (histogramTotal ⁻¹' ({N} : Set ℕ)) = μ.restrict (FiniteSample.count ⁻¹' ({N} : Set ℕ)) := by rw [show ν.restrict (histogramTotal ⁻¹' ({N} : Set ℕ)) = (poissonMeasure lambda) {N} • multinomialHistogramLaw P N by exact independentPoissonCountLaw_restrict_histogramTotal_eq P lambda N, Measure.bind_smul, multinomialHistogramLaw_comp_reconstruction, show μ.restrict (FiniteSample.count ⁻¹' ({N} : Set ℕ)) = (poissonMeasure lambda) {N} • Measure.map (fixedSizeEmbed N) (Measure.pi fun _ : Fin N ↦ P) by exact finitePoissonSampleLaw_restrict_count_eq P lambda N] calc K ∘ₘ ν = K ∘ₘ Measure.sum (fun N ↦ ν.restrict (histogramTotal ⁻¹' ({N} : Set ℕ))) := by rw [← measure_eq_sum_restrict_histogramTotal ν] _ = Measure.sum (fun N ↦ K ∘ₘ ν.restrict (histogramTotal ⁻¹' ({N} : Set ℕ))) := by exact Measure.bind_sum _ _ K.aemeasurable _ = Measure.sum (fun N ↦ μ.restrict (FiniteSample.count ⁻¹' ({N} : Set ℕ))) := by congr 1 funext N exact hpiece N _ = μ := (measure_eq_sum_restrict_finiteSample_count μ).symm
1 supporting declaration (lemmas, instances)