Offline · exact source
Exact Lean source

CountMultinomialDensity

formalization/Cloning/CountMultinomialDensity.lean

Source hash: 7ae4b789ed18d2e73ed19868c040932a47785c9f0b04c121dc85d3488a87b659

Full source copied without mathematical changes from the snapshot whose input hash matches the passing audit. Select a line number for a stable source pointer.

The declarations belong to the compiled inventory covered by the project’s shared axiom audit. That audit records an aggregate union, without attributing axioms to individual declarations.

Declarations in this module
1import Cloning.CountMultinomialPMF
2import Cloning.YoungFlatCells
3 
4/-! The true count law smoothed on fixed-base Euclidean root-space cells. -/
5noncomputable section
6open scoped BigOperators Topology Classical
7open Filter MeasureTheory
8namespace Cloning.CountMultinomial
9open Cloning.YoungGeneral Cloning.YoungHyperplane
10set_option backward.isDefEq.respectTransparency false
11set_option maxHeartbeats 1200000
12 
13def latticePMF (d N : ℕ) (p : Fin (d+1) → ℝ) (hp : ∀ i, 0 ≤ p i) (hs : ∑ i, p i=1) :
14    PMF (Lattice d (N : ℤ)) := (countPMF (d+1) N p hp hs).map (shapeLattice d N)
15 
16theorem latticePMF_apply_shape (d N : ℕ) (p : Fin (d+1) → ℝ)
17    (hp : ∀ i, 0 ≤ p i) (hs : ∑ i, p i=1) (μ : Shape (d+1) N)
18    (hμ : ∑ i, (μ i).val=N) :
19    latticePMF d N p hp hs (shapeLattice d N μ)=countPMF (d+1) N p hp hs μ := by
20  rw [latticePMF, PMF.map_apply, tsum_eq_single μ]
21  · simp
22  · intro ν hν
23    by_cases ht : ∑ i, (ν i).val=N
24    · have hn : shapeLattice d N μ≠shapeLattice d N ν := by
25        intro he
26        exact hν (shapeLattice_injective_of_sum d N ν μ ht hμ he.symm)
27      simp only [hn, if_false]
28    · rw [countPMF_eq_zero_of_sum p hp hs ν ht]
29      split_ifs <;> rfl
30 
31/-- Centering is fixed independently of the sampled probability vector. -/
32def density (d N : ℕ) (p : Fin (d+1) → ℝ) (hp : ∀ i, 0 ≤ p i) (hs : ∑ i, p i=1) :
33    rootSpace d → ℝ :=
34  sampleInterpolate d N (flatSpectrum (d+1)) (fun μ ↦ (latticePMF d N p hp hs μ).toReal)
35 
36theorem density_eq_on_cell (d N : ℕ) (hN : 0<N) (p : Fin (d+1) → ℝ)
37    (hp : ∀ i, 0 ≤ p i) (hs : ∑ i, p i=1) (μ : Shape (d+1) N) (hμ : ∑ i, (μ i).val=N)
38    (x : rootSpace d) (hx : x∈sampleCell d N (flatSpectrum (d+1)) (shapeLattice d N μ)) :
39    density d N p hp hs x=(Real.sqrt (N : ℝ)^d/Real.sqrt ((d : ℝ)+1))*
40      YoungMultinomial.multinomialMass N p (fun i ↦ (μ i).val) := by
41  rw [density, sampleInterpolate_eq_on_cell d N (by exact_mod_cast hN) _ _ _ x hx,
42    latticePMF_apply_shape d N p hp hs μ hμ, countPMF_formula (d+1) N p hp hs μ hμ]
43  norm_cast
44 
45theorem integral_density (d N : ℕ) (hN : 0<N) (p : Fin (d+1) → ℝ)
46    (hp : ∀ i, 0 ≤ p i) (hs : ∑ i, p i=1) : (∫ x, density d N p hp hs x)=1 := by
47  rw [density, sampleInterpolate_integral d N (by exact_mod_cast hN)]
48  · exact (YoungCompatibility.hasSum_probability _).tsum_eq
49  · exact (YoungCompatibility.hasSum_probability _).summable
50 
51theorem density_nonneg (d N : ℕ) (p : Fin (d+1) → ℝ)
52    (hp : ∀ i, 0 ≤ p i) (hs : ∑ i, p i=1) (x : rootSpace d) : 0 ≤ density d N p hp hs x := by
53  unfold density sampleInterpolate euclideanInterpolate interpolate
54    YoungRounding.affineDensity YoungRounding.interpolate
55  positivity
56 
57theorem integrable_density (d N : ℕ) (hN : 0<N) (p : Fin (d+1) → ℝ)
58    (hp : ∀ i, 0 ≤ p i) (hs : ∑ i, p i=1) : Integrable (density d N p hp hs) := by
59  by_contra h
60  have he := integral_density d N hN p hp hs
61  rw [integral_undef h] at he
62  norm_num at he
63 
64end Cloning.CountMultinomial