Exact Lean source
CountMultinomialLocal
formalization/Cloning/CountMultinomialLocal.lean
Source hash: b75d6ff7c109f1ce2b2e19a0989d9f89ab0840c63d4caba0abcc10b1d2c63baf
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.CountMultinomialDensity
2import Cloning.YoungUniformLocalScheffe
3
4/-! Conditional count central limits for moving multinomial parameters at the flat base. -/
5noncomputable section
6open scoped BigOperators Topology Classical
7open Filter MeasureTheory
8namespace Cloning.CountMultinomial
9open Cloning.YoungGeneral Cloning.YoungHyperplane Cloning.YoungFlat Cloning.YoungMultinomial
10set_option backward.isDefEq.respectTransparency false
11set_option maxHeartbeats 1400000
12
13theorem sampleCenter_change_probability (d N : ℕ) (hN : 0<N)
14 (p q : Fin (d+1) → ℝ) (hp : ∑ i, p i=1) (hq : ∑ i, q i=1)
15 (μ : Lattice d (N : ℤ)) (i : Fin (d+1)) :
16 (sampleCenter d N p μ).1 i=(sampleCenter d N q μ).1 i-
17 Real.sqrt (N : ℝ)*(p i-q i) := by
18 rw [sampleCenter_apply d N p hp, sampleCenter_apply d N q hq]
19 simp only [Int.cast_natCast]
20 have hn : Real.sqrt (N : ℝ)≠0 := by positivity
21 have hs := Real.sq_sqrt (Nat.cast_nonneg N)
22 field_simp
23 linear_combination (p i-q i)*hs
24
25/-- The local count CLT is proved from the factorial mass, at every shifted point. -/
26theorem density_moving_tendsto_of_positive (d : ℕ) (n : ℕ → ℕ)
27 (hn : Tendsto n atTop atTop) (hn0 : ∀ k, 0<n k)
28 (p : ℕ → Fin (d+1) → ℝ) (hp : ∀ k i, 0≤p k i) (hs : ∀ k, ∑ i, p k i=1)
29 (hp0 : ∀ k i, 0<p k i)
30 (hlim : ∀ i, Tendsto (fun k ↦ p k i) atTop (𝓝 (flatSpectrum (d+1) i)))
31 (h : rootSpace d)
32 (hshift : ∀ i, Tendsto (fun k ↦ Real.sqrt (n k : ℝ)*(p k i-flatSpectrum (d+1) i))
33 atTop (𝓝 (h.1 i)))
34 (x : rootSpace d) :
35 Tendsto (fun k ↦ density d (n k) (p k) (hp k) (hs k) x) atTop
36 (𝓝 (covarianceGaussian d (flatSpectrum (d+1)) (flatSpectrum_sum _ (by omega)) (x-h))) := by
37 let p₀ := flatSpectrum (d+1)
38 have hp₀ : ∑ i, p₀ i=1 := flatSpectrum_sum _ (by omega)
39 have hp₀0 i : 0<p₀ i := by dsimp [p₀,flatSpectrum]; positivity
40 let μ := fun k ↦ sampleShape d (n k) p₀ x
41 let c := fun k ↦ sampleCenter d (n k) (p k) (sampleLabel d (n k) p₀ x)
42 have hv := eventually_flat_sampleShape_valid d n hn (fun _ ↦ x) x (fun _ ↦ tendsto_const_nhds)
43 have hc i : Tendsto (fun k ↦ (c k).1 i) atTop (𝓝 ((x-h).1 i)) := by
44 have hh := (sampleLabel_center_tendsto d n hn (fun _ ↦ p₀) (fun _ ↦ hp₀) x i).sub (hshift i)
45 apply hh.congr'
46 exact Eventually.of_forall fun k ↦ (sampleCenter_change_probability d (n k) (hn0 k)
47 (p k) p₀ (hs k) hp₀ _ i).symm
48 have hpa : ∀ᶠ k in atTop, ∀ i, (1/((d+1 : ℕ) : ℝ))/2 ≤ p k i := by
49 apply eventually_all.mpr
50 intro i
51 exact (hlim i).eventually (eventually_ge_nhds (by change (1/((d+1 : ℕ) : ℝ))/2 < 1/((d+1 : ℕ) : ℝ); exact half_lt_self (hp₀0 i)))
52 have hb : ∀ᶠ k in atTop, ∀ i, |(c k).1 i| ≤ ‖x-h‖+1 := by
53 apply eventually_all.mpr
54 intro i
55 filter_upwards [(hc i).eventually (Metric.ball_mem_nhds _ (by norm_num : (0:ℝ)<1))] with k hk
56 have hbound : |(x-h).1 i| ≤ ‖x-h‖ := by simpa using PiLp.norm_apply_le (x-h).1 i
57 have ha := abs_add_le ((c k).1 i-(x-h).1 i) ((x-h).1 i)
58 simp only [Metric.mem_ball, Real.dist_eq] at hk
59 rw [sub_add_cancel] at ha
60 linarith
61 have hcount k (hvk : (∑ i, (μ k i).val)=n k ∧ shapeLattice d (n k) (μ k)=sampleLabel d (n k) p₀ x) i :
62 ((μ k i).val : ℝ)=n k*(p k i+(c k).1 i/Real.sqrt (n k : ℝ)) := by
63 have he := shapeLattice_apply d (n k) (μ k) hvk.1 i
64 rw [hvk.2] at he
65 have her : ((sampleLabel d (n k) p₀ x).1 i : ℝ)=((μ k i).val : ℝ) := by exact_mod_cast he
66 have hh := lattice_ratio_eq_center d (n k) (hn0 k) (p k) (hs k) (sampleLabel d (n k) p₀ x) i
67 rw [her] at hh
68 exact ((div_eq_iff (by exact_mod_cast (hn0 k).ne' : (n k : ℝ)≠0)).mp hh).trans (mul_comm _ _)
69 have hm : Tendsto (fun k ↦ multinomialMass (n k) (p k) (fun i ↦ (μ k i).val)/
70 gaussianMass (n k) (p k) (fun i ↦ (c k).1 i)) atTop (𝓝 1) := by
71 apply Metric.tendsto_nhds.mpr
72 intro ε hε
73 obtain ⟨N₀,hN₀⟩ := uniform_multinomial_local_limit (ι := Fin (d+1))
74 ((1/((d+1 : ℕ) : ℝ))/2) (‖x-h‖+1) (by positivity) (by positivity) ε hε
75 filter_upwards [hpa,hb,hv,hn.eventually (eventually_ge_atTop N₀)] with k hpak hbk hvk hnk
76 rw [Real.dist_eq]
77 exact hN₀ (n k) hnk (p k) (fun i ↦ (c k).1 i) (fun i ↦ (μ k i).val)
78 hpak (hs k) (c k).2 hbk (hcount k hvk)
79 have hg := covarianceGaussian_tendsto d p p₀ hs hp₀ hp0 hp₀0 hlim c (x-h) hc
80 have hh := hm.mul hg
81 simp only [one_mul] at hh
82 apply hh.congr'
83 filter_upwards [hv] with k hk
84 have hx : x∈sampleCell d (n k) p₀ (shapeLattice d (n k) (μ k)) := by
85 rw [hk.2]
86 exact mem_sampleCell_sampleLabel d (n k) p₀ x
87 rw [density_eq_on_cell d (n k) (hn0 k) (p k) (hp k) (hs k) (μ k) hk.1 x hx,
88 ← scaled_gaussianMass_eq_covarianceGaussian d (n k) (hn0 k) (p k) (hs k) (hp0 k) (c k)]
89 have hg0 : gaussianMass (n k) (p k) (fun i ↦ (c k).1 i)≠0 := Real.exp_ne_zero _
90 field_simp
91
92end Cloning.CountMultinomial