Download data/lean/OAI/Geometry/LatticeCovering/Rates.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 31.7 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Geometry/LatticeCovering/Rates.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Geometry/LatticeCovering/Rates.lean
-
curl -L -o Rates.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Geometry/LatticeCovering/Rates.lean
31.7 kB
| import OAI.Geometry.LatticeCovering.Sections | |
| namespace OAI | |
| section | |
| section | |
| noncomputable section | |
| open Real Filter Topology Asymptotics | |
| namespace SingleLatticeCovering.FinalRates | |
| def firstSize (n : β) : β := β(Real.log (Real.log (n : β)))^2ββ | |
| lemma loglog_nat_atTop : Tendsto (fun n : β => Real.log (Real.log (n : β))) atTop atTop := | |
| Real.tendsto_log_atTop.comp (Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop) | |
| lemma log_nat_atTop : Tendsto (fun n : β => Real.log (n : β)) atTop atTop := | |
| Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop | |
| lemma loglog_sq_littleO : | |
| (fun n : β => (Real.log (Real.log (n : β)))^2) =o[atTop] | |
| (fun n : β => Real.log (n : β)) := by | |
| simpa only [Function.comp_def,Real.rpow_two,Real.rpow_one] using | |
| (isLittleO_log_rpow_rpow_atTop (2 : β) (by norm_num : (0 : β) < 1)).comp_tendsto log_nat_atTop | |
| lemma firstSize_tendsto : Tendsto firstSize atTop atTop := by | |
| apply tendsto_nat_ceil_atTop.comp | |
| simpa only [Function.comp_def,Real.rpow_two] using (tendsto_rpow_atTop (by norm_num : (0 : β) < 2)).comp loglog_nat_atTop | |
| lemma eventually_firstSize_le_log {c : β} (hc : 0 < c) : | |
| βαΆ n : β in atTop, (firstSize n : β)+1 β€ c*Real.log (n : β) := by | |
| filter_upwards [loglog_sq_littleO.bound (half_pos hc), | |
| log_nat_atTop.eventually (eventually_ge_atTop (4/c))] with n hs hl | |
| rw [Real.norm_eq_abs,Real.norm_eq_abs,abs_of_nonneg (sq_nonneg _), | |
| abs_of_nonneg (Real.log_natCast_nonneg n)] at hs | |
| have hceil := Nat.ceil_lt_add_one (sq_nonneg (Real.log (Real.log (n : β)))) | |
| have he : 4 β€ c*Real.log (n : β) := by simpa only [mul_comm] using (div_le_iffβ hc).mp hl | |
| change (firstSize n : β) < (Real.log (Real.log (n : β)))^2+1 at hceil | |
| linarith | |
| lemma eventually_dimension_power {C a r : β} (hC : 0 < C) (ha : 1 < a) (hr : 0 < r) : | |
| βαΆ n : β in atTop, β D : β, (D : β) β€ C*((firstSize n : β)+1) β | |
| a^D β€ (n : β)^r := by | |
| have hal : 0 < Real.log a := Real.log_pos ha | |
| have ha0 : 0 < a := lt_trans zero_lt_one ha | |
| filter_upwards [eventually_firstSize_le_log (div_pos hr (mul_pos hC hal)), | |
| eventually_ge_atTop (1 : β)] with n hn hn1 D hD | |
| have hn0 : (0 : β) < n := by exact_mod_cast hn1 | |
| apply (Real.log_le_log_iff (pow_pos ha0 _) (Real.rpow_pos_of_pos hn0 r)).mp | |
| rw [Real.log_pow,Real.log_rpow hn0] | |
| calc | |
| (D : β)*Real.log a β€ C*((firstSize n : β)+1)*Real.log a := | |
| mul_le_mul_of_nonneg_right hD hal.le | |
| _ = (C*Real.log a)*((firstSize n : β)+1) := by ring | |
| _ β€ (C*Real.log a)*(r/(C*Real.log a)*Real.log (n : β)) := | |
| mul_le_mul_of_nonneg_left hn (mul_pos hC hal).le | |
| _ = r*Real.log (n : β) := by field_simp | |
| lemma eventually_superlinear_power {k : β} (hk : 0 < k) : | |
| βαΆ s : β in atTop, 2*s β€ k*s^(7/5 : β) := by | |
| filter_upwards [eventually_ge_atTop (1 : β), | |
| (tendsto_rpow_atTop (by norm_num : (0 : β) < 2/5)).eventually | |
| (eventually_ge_atTop (2/k))] with s hs hpow | |
| have hs0 : 0 < s := lt_of_lt_of_le zero_lt_one hs | |
| have hmul : 2 β€ k*s^(2/5 : β) := by simpa only [mul_comm] using (div_le_iffβ hk).mp hpow | |
| have he : s^(7/5 : β)=s*s^(2/5 : β) := by | |
| rw [show (7/5 : β)=1+2/5 by norm_num,Real.rpow_add hs0,Real.rpow_one] | |
| rw [he] | |
| nlinarith [mul_nonneg hs0.le (sub_nonneg.mpr hmul)] | |
| lemma cap_log_tendsto {k : β} (hk : 0 < k) : | |
| Tendsto (fun n : β => Real.log (n : β)* | |
| Real.exp (-k*(firstSize n : β)^(70/100 : β))) atTop (π 0) := by | |
| have hexp : Tendsto (fun n : β => Real.exp (-Real.log (Real.log (n : β)))) atTop (π 0) := | |
| Real.tendsto_exp_atBot.comp (tendsto_neg_atTop_atBot.comp loglog_nat_atTop) | |
| apply squeeze_zero' (Eventually.of_forall (fun n => | |
| mul_nonneg (Real.log_natCast_nonneg n) (Real.exp_pos _).le)) ?_ hexp | |
| filter_upwards [loglog_nat_atTop.eventually (eventually_superlinear_power hk), | |
| loglog_nat_atTop.eventually (eventually_ge_atTop (1 : β)), | |
| eventually_ge_atTop (2 : β)] with n hpow hs hn | |
| have hnlog : 0 < Real.log (n : β) := Real.log_pos (by exact_mod_cast hn) | |
| have hs0 : 0 β€ Real.log (Real.log (n : β)) := le_trans zero_le_one hs | |
| have hceil := Nat.le_ceil ((Real.log (Real.log (n : β)))^2) | |
| have hcappow : (Real.log (Real.log (n : β)))^(7/5 : β) β€ | |
| (firstSize n : β)^(70/100 : β) := by | |
| have hh := Real.rpow_le_rpow (sq_nonneg (Real.log (Real.log (n : β)))) hceil | |
| (by norm_num : (0 : β) β€ 70/100) | |
| rw [βReal.rpow_natCast _ 2,βReal.rpow_mul hs0] at hh | |
| norm_num at hh | |
| simpa only [firstSize,show (70/100 : β)=(7/10 : β) by norm_num] using hh | |
| conv_lhs => rw [βReal.exp_log hnlog,βReal.exp_add] | |
| apply Real.exp_le_exp.mpr | |
| nlinarith [mul_le_mul_of_nonneg_left hcappow hk.le] | |
| end SingleLatticeCovering.FinalRates | |
| noncomputable section | |
| namespace SingleLatticeCovering.FinalRates | |
| open Real Filter Topology Asymptotics | |
| lemma eventually_log_power_bound (k : β) {r Ξ΅ : β} (hr : 0 < r) (hΞ΅ : 0 < Ξ΅) : | |
| βαΆ n : β in atTop, (Real.log (n : β))^k β€ Ξ΅*(n : β)^r := by | |
| have h : (fun n : β => (Real.log (n : β))^k) =o[atTop] | |
| (fun n : β => (n : β)^r) := by | |
| simpa only [Function.comp_def,Real.rpow_natCast] using | |
| (isLittleO_log_rpow_rpow_atTop (k : β) hr).comp_tendsto tendsto_natCast_atTop_atTop | |
| filter_upwards [h.bound hΞ΅] with n hn | |
| simpa only [Real.norm_eq_abs,abs_of_nonneg (pow_nonneg (Real.log_natCast_nonneg n) _), | |
| abs_of_nonneg (Real.rpow_nonneg (Nat.cast_nonneg n) _)] using hn | |
| lemma eventually_dimension_small {C : β} (hC : 0 < C) : | |
| βαΆ n : β in atTop, β D : β, (D : β) β€ C*((firstSize n : β)+1) β | |
| (D : β) β€ Real.log (n : β) β§ (D : β) β€ (n : β)/2 := by | |
| filter_upwards [eventually_firstSize_le_log (inv_pos.mpr hC), | |
| eventually_log_power_bound 1 (by norm_num : (0 : β) < 1) | |
| (by norm_num : (0 : β) < 1/2)] with n hn hlog D hD | |
| have hDl : (D : β) β€ Real.log (n : β) := by | |
| calc | |
| _ β€ C*((firstSize n : β)+1) := hD | |
| _ β€ C*(Cβ»ΒΉ*Real.log (n : β)) := mul_le_mul_of_nonneg_left hn hC.le | |
| _ = Real.log (n : β) := by field_simp | |
| refine β¨hDl,hDl.trans ?_β© | |
| simpa only [pow_one,Real.rpow_one,one_div,mul_comm,div_eq_mul_inv,one_mul] using hlog | |
| def eta (m : β) : β := (m : β)/4*Real.log (27/16 : β)-3*Real.log (m : β) | |
| lemma eta_linear_lower : | |
| βαΆ m : β in atTop, (Real.log (27/16 : β)/8)*(m : β) β€ eta m := by | |
| have hlog : 0 < Real.log (27/16 : β) := Real.log_pos (by norm_num) | |
| filter_upwards [eventually_log_power_bound 1 (by norm_num : (0 : β) < 1) | |
| (div_pos hlog (by norm_num : (0 : β) < 24))] with m hm | |
| simp only [pow_one,Real.rpow_one] at hm | |
| dsimp [eta] | |
| linarith | |
| lemma eventually_cap_linear {k H Ξ΅ : β} (hk : 0 < k) (hH : 0 β€ H) (hΞ΅ : 0 < Ξ΅) : | |
| βαΆ n : β in atTop, β m : β, (n : β)/2 β€ m β | |
| H*(n : β)*Real.log (n : β)*Real.exp (-k*(firstSize n : β)^(70/100 : β)) β€ Ξ΅*m := by | |
| have _ := hH | |
| have ht : Tendsto (fun n : β => H*(Real.log (n : β)* | |
| Real.exp (-k*(firstSize n : β)^(70/100 : β)))) atTop (π 0) := | |
| by simpa only [mul_zero] using (cap_log_tendsto hk).const_mul H | |
| filter_upwards [ht.eventually (gt_mem_nhds (half_pos hΞ΅))] with n hn m hm | |
| calc | |
| _ = (n : β)*(H*(Real.log (n : β)*Real.exp (-k*(firstSize n : β)^(70/100 : β)))) := by ring | |
| _ β€ (n : β)*(Ξ΅/2) := mul_le_mul_of_nonneg_left hn.le (Nat.cast_nonneg n) | |
| _ β€ Ξ΅*m := by nlinarith | |
| lemma eventually_cap_eta {C k H : β} (hC : 0 < C) (hk : 0 < k) (hH : 0 β€ H) : | |
| βαΆ n : β in atTop, β D : β, (D : β) β€ C*((firstSize n : β)+1) β | |
| D β€ n β§ H*(n : β)*Real.log (n : β)* | |
| Real.exp (-k*(firstSize n : β)^(70/100 : β)) β€ eta (n-D) := by | |
| obtain β¨M,hMβ© := eventually_atTop.mp eta_linear_lower | |
| have hlog : 0 < Real.log (27/16 : β) := Real.log_pos (by norm_num) | |
| filter_upwards [eventually_dimension_small hC, | |
| eventually_cap_linear hk hH (div_pos hlog (by norm_num : (0 : β) < 8)), | |
| eventually_ge_atTop (2*M)] with n hD hn hnM D hdim | |
| have hhalf := (hD D hdim).2 | |
| have hDn : D β€ n := by exact_mod_cast (show (D : β) β€ n by linarith) | |
| have hm : (n : β)/2 β€ (n-D : β) := by rw [Nat.cast_sub hDn]; linarith | |
| have hMm : M β€ n-D := by | |
| have hnMr : (2 : β)*M β€ n := by exact_mod_cast hnM | |
| exact_mod_cast (show (M : β) β€ (n-D : β) from by linarith) | |
| exact β¨hDn,(hn (n-D) hm).trans (hM _ hMm)β© | |
| lemma eventually_rpow_bound {a b Ξ΅ : β} (hab : a < b) (hΞ΅ : 0 < Ξ΅) : | |
| βαΆ n : β in atTop, (n : β)^a β€ Ξ΅*(n : β)^b := by | |
| filter_upwards [((tendsto_rpow_atTop (sub_pos.mpr hab)).comp | |
| tendsto_natCast_atTop_atTop).eventually (eventually_ge_atTop (1/Ξ΅)), | |
| eventually_ge_atTop (1 : β)] with n hn hn1 | |
| have hn0 : (0 : β) < n := by exact_mod_cast hn1 | |
| have hm : 1 β€ Ξ΅*(n : β)^(b-a) := by | |
| simpa only [Function.comp_def,mul_comm] using (div_le_iffβ hΞ΅).mp hn | |
| have he : (n : β)^b=(n : β)^a*(n : β)^(b-a) := by | |
| rw [βReal.rpow_add hn0]; congr 1; ring | |
| rw [he] | |
| nlinarith [mul_le_mul_of_nonneg_left hm (Real.rpow_pos_of_pos hn0 a).le] | |
| lemma sqrt_nat_atTop : Tendsto (fun n : β => Real.sqrt (n : β)) atTop atTop := by | |
| simpa only [Function.comp_def,Real.sqrt_eq_rpow] using | |
| (tendsto_rpow_atTop (by norm_num : (0 : β) < 1/2)).comp tendsto_natCast_atTop_atTop | |
| lemma sqrt_half_bound {n m : β} (hm : (n : β)/2 β€ m) : | |
| Real.sqrt (n : β) β€ 2*Real.sqrt (m : β) := by | |
| have hn0 := Real.sqrt_nonneg (n : β) | |
| have hm0 := Real.sqrt_nonneg (m : β) | |
| have hn2 := Real.sq_sqrt (Nat.cast_nonneg n : (0 : β) β€ n) | |
| have hm2 := Real.sq_sqrt (Nat.cast_nonneg m : (0 : β) β€ m) | |
| nlinarith | |
| lemma eventually_discard_bound {C Ξ΅ : β} (hC : 0 < C) (hΞ΅ : 0 < Ξ΅) : | |
| βαΆ n : β in atTop, β D m : β, (D : β) β€ C*((firstSize n : β)+1) β m β€ n β | |
| (2 : β)^D*Real.sqrt (m : β) β€ Ξ΅*(n : β)*Real.log (n : β) := by | |
| filter_upwards [eventually_dimension_power hC (by norm_num : (1 : β) < 2) | |
| (by norm_num : (0 : β) < 1/4), | |
| eventually_rpow_bound (by norm_num : (3/4 : β) < 1) hΞ΅, | |
| log_nat_atTop.eventually (eventually_ge_atTop (1 : β)), | |
| eventually_ge_atTop (1 : β)] with n hp hr hlog hn1 D m hD hmn | |
| have hn0 : (0 : β) < n := by exact_mod_cast hn1 | |
| calc | |
| _ β€ (n : β)^(1/4 : β)*Real.sqrt (n : β) := | |
| mul_le_mul (hp D hD) (Real.sqrt_le_sqrt (by exact_mod_cast hmn)) | |
| (Real.sqrt_nonneg _) (Real.rpow_pos_of_pos hn0 _).le | |
| _ = (n : β)^(3/4 : β) := by | |
| rw [Real.sqrt_eq_rpow,βReal.rpow_add hn0]; norm_num | |
| _ β€ Ξ΅*(n : β) := by simpa only [Real.rpow_one] using hr | |
| _ β€ Ξ΅*(n : β)*Real.log (n : β) := le_mul_of_one_le_right (by positivity) hlog | |
| lemma eventually_label_criterion {C Cs CR : β} (hC : 0 < C) (hCs : 1 β€ Cs) (hCR : 0 β€ CR) : | |
| βαΆ n : β in atTop, β D m : β, (D : β) β€ C*((firstSize n : β)+1) β | |
| (n : β)/2 β€ m β m β€ n β | |
| (1+CR)*(Cs*(m : β)^2)^D*Real.exp (-Real.sqrt (m : β)/2) < 1 := by | |
| have hCR1 : 0 < 1+CR := by linarith | |
| have hCs0 : 0 < Cs := lt_of_lt_of_le zero_lt_one hCs | |
| filter_upwards [eventually_dimension_small hC, | |
| eventually_log_power_bound 2 (by norm_num : (0 : β) < 1/2) | |
| (by norm_num : (0 : β) < 1/48), | |
| sqrt_nat_atTop.eventually (eventually_ge_atTop (16*(Real.log (1+CR)+1))), | |
| tendsto_natCast_atTop_atTop.eventually (eventually_ge_atTop Cs), | |
| eventually_ge_atTop (2 : β)] with n hdim hpoly hsqrt hCsn hn2 D m hD hm hmn | |
| have hn1 : (1 : β) β€ n := by exact_mod_cast (show 1 β€ n by omega) | |
| have hm1 : (1 : β) β€ m := by | |
| have hn2r : (2 : β) β€ n := by exact_mod_cast hn2 | |
| linarith | |
| have hm0 : (0 : β) < m := lt_of_lt_of_le zero_lt_one hm1 | |
| have hn0 : (0 : β) < n := lt_of_lt_of_le zero_lt_one hn1 | |
| have hDl := (hdim D hD).1 | |
| have hlogm : Real.log (m : β) β€ Real.log (n : β) := Real.log_le_log hm0 (by exact_mod_cast hmn) | |
| have hlogC : Real.log Cs β€ Real.log (n : β) := Real.log_le_log hCs0 hCsn | |
| have hlogm0 : 0 β€ Real.log (m : β) := Real.log_nonneg hm1 | |
| have hlogC0 : 0 β€ Real.log Cs := Real.log_nonneg hCs | |
| have hlogs : (D : β)*(Real.log Cs+2*Real.log (m : β)) β€ 3*(Real.log (n : β))^2 := by | |
| calc | |
| _ β€ Real.log (n : β)*(Real.log Cs+2*Real.log (m : β)) := | |
| mul_le_mul_of_nonneg_right hDl (by linarith) | |
| _ β€ Real.log (n : β)*(3*Real.log (n : β)) := | |
| mul_le_mul_of_nonneg_left (by linarith) (Real.log_natCast_nonneg n) | |
| _ = _ := by ring | |
| rw [βReal.sqrt_eq_rpow] at hpoly | |
| have hs := sqrt_half_bound hm | |
| have hneg : Real.log (1+CR)+(D : β)*(Real.log Cs+2*Real.log (m : β))- | |
| Real.sqrt (m : β)/2 < 0 := by linarith [Real.sqrt_nonneg (m : β)] | |
| have he : (1+CR)*(Cs*(m : β)^2)^D*Real.exp (-Real.sqrt (m : β)/2) = | |
| Real.exp (Real.log (1+CR)+(D : β)*(Real.log Cs+2*Real.log (m : β))- | |
| Real.sqrt (m : β)/2) := by | |
| have hp : (Cs*(m : β)^2)^D = | |
| Real.exp ((D : β)*(Real.log Cs+2*Real.log (m : β))) := by | |
| rw [Real.exp_nat_mul,Real.exp_add,Real.exp_log hCs0] | |
| rw [show (2 : β)*Real.log (m : β)=Real.log ((m : β)^2) by rw [Real.log_pow]; norm_num, | |
| Real.exp_log (pow_pos hm0 2)] | |
| calc | |
| _ = Real.exp (Real.log (1+CR))* | |
| Real.exp ((D : β)*(Real.log Cs+2*Real.log (m : β)))* | |
| Real.exp (-Real.sqrt (m : β)/2) := by rw [Real.exp_log hCR1,hp] | |
| _ = _ := by rw [βReal.exp_add,βReal.exp_add]; congr 1; ring | |
| rw [he] | |
| exact Real.exp_lt_one_iff.mpr hneg | |
| end SingleLatticeCovering.FinalRates | |
| end | |
| end | |
| end | |
| section | |
| noncomputable section | |
| namespace SingleLatticeCovering.Shear | |
| open Real Filter Topology | |
| open scoped BigOperators | |
| def pointBudget {Ξ± : Type*} (A : β β Finset β) (s : Finset Ξ±) (D : β) : β := | |
| (s.card+1)*β j β Finset.range D, ((A j).card+1) | |
| lemma pointBudget_pos {Ξ± : Type*} (A : β β Finset β) (s : Finset Ξ±) (D : β) : | |
| 0 < pointBudget A s D := by | |
| dsimp [pointBudget] | |
| exact Nat.mul_pos (by omega) (Finset.prod_pos (fun j hj => by omega)) | |
| lemma alphabetPoints_card_le_budget {Ξ± : Type*} (A : β β Finset β) (s : Finset Ξ±) | |
| {q D : β} (hq : q β€ D) : (alphabetPoints A s q).card β€ pointBudget A s D := by | |
| classical | |
| have hp : β j β Finset.range q, (A j).card β€ | |
| β j β Finset.range D, ((A j).card+1) := by | |
| calc | |
| _ β€ β j β Finset.range q, ((A j).card+1) := Finset.prod_le_prodβ (fun j hj => Nat.zero_le _) (fun j hj => Nat.le_succ _) | |
| _ β€ _ := Finset.prod_le_prod_of_subset_of_one_leβ (Finset.range_mono hq) (fun j hj => Nat.zero_le _) (fun j hj _ => Nat.succ_pos _) | |
| dsimp [alphabetPoints,pointBudget] | |
| rw [Finset.card_product,Fintype.card_piFinset] | |
| have he : (β i : Fin q, (A i.val).card) = β j β Finset.range q, (A j).card := | |
| Fin.prod_univ_eq_prod_range (fun j => (A j).card) q | |
| rw [he] | |
| exact le_trans (Nat.mul_le_mul_right s.card hp) (by simp [mul_comm]) | |
| def patternTotal {Ξ± : Type*} (A : β β Finset β) (s : Finset Ξ±) (D : β) : β := | |
| β q β Finset.range (D+1), (allPatterns A s q).card | |
| lemma patternTotal_bound {Ξ± : Type*} (A : β β Finset β) (s : Finset Ξ±) (D : β) : | |
| patternTotal A s D β€ (D+1)*(pointBudget A s D+1)^(2^D) := | |
| allPatterns_total_bound A s D (pointBudget A s D) (fun _ hq => alphabetPoints_card_le_budget A s hq) | |
| lemma log_pointBudget {Ξ± : Type*} (A : β β Finset β) (s : Finset Ξ±) (D : β) : | |
| Real.log (pointBudget A s D : β) = Real.log (s.card+1 : β)+ | |
| β j β Finset.range D, Real.log ((A j).card+1 : β) := by | |
| simp only [pointBudget,Nat.cast_mul,Nat.cast_add,Nat.cast_one,Nat.cast_prod] | |
| rw [Real.log_mul (by positivity) (by positivity),Real.log_prod] | |
| intro j hj; positivity | |
| lemma scalar_pattern_cost (D N Q : β) (hN : 0 < N) | |
| (hQ : Q β€ (D+1)*(N+1)^(2^D)) : | |
| (2 : β)^D*Real.log (2*((Q : β)+1)) β€ | |
| (4 : β)^D*(Real.log 8+Real.log ((D : β)+1)+Real.log (N : β)) := by | |
| have hNr : (1 : β) β€ N := by exact_mod_cast hN | |
| have hNp : (0 : β) < N := lt_of_lt_of_le zero_lt_one hNr | |
| have hD : (0 : β) < (D : β)+1 := by positivity | |
| have hbase : (1 : β) β€ ((D : β)+1)*((N : β)+1)^(2^D) := | |
| one_le_mul_of_one_le_of_one_le (by linarith [(Nat.cast_nonneg D : (0 : β) β€ D)]) (one_le_powβ (by linarith)) | |
| have hQr : (Q : β) β€ ((D : β)+1)*((N : β)+1)^(2^D) := by exact_mod_cast hQ | |
| have hl : Real.log (2*((Q : β)+1)) β€ Real.log 4+Real.log ((D : β)+1)+ | |
| (2^D : β)*Real.log ((N : β)+1) := by | |
| calc | |
| _ β€ Real.log (4*(((D : β)+1)*((N : β)+1)^(2^D))) := | |
| Real.log_le_log (by positivity) (by linarith) | |
| _ = _ := by rw [Real.log_mul (by norm_num) (by positivity), | |
| Real.log_mul hD.ne' (by positivity),Real.log_pow]; ring | |
| have hNl : Real.log ((N : β)+1) β€ Real.log 2+Real.log (N : β) := by | |
| rw [βReal.log_mul (by norm_num) hNp.ne'] | |
| exact Real.log_le_log (by positivity) (by linarith) | |
| have h2 : (1 : β) β€ (2 : β)^D := one_le_powβ (by norm_num) | |
| have hDl : 0 β€ Real.log ((D : β)+1) := Real.log_nonneg (by linarith [(Nat.cast_nonneg D : (0 : β) β€ D)]) | |
| have hNlog : 0 β€ Real.log (N : β) := Real.log_nonneg hNr | |
| have h4log : 0 β€ Real.log 4 := Real.log_nonneg (by norm_num) | |
| have h2log : 0 β€ Real.log 2 := Real.log_nonneg (by norm_num) | |
| have hcast : ((2^D : β) : β)=(2 : β)^D := by norm_cast | |
| rw [hcast] at hl | |
| have h24 : (2 : β)^D*(2 : β)^D=(4 : β)^D := by rw [βmul_pow]; norm_num | |
| have h8 : Real.log 8=Real.log 4+Real.log 2 := by | |
| rw [βReal.log_mul (by norm_num) (by norm_num)]; norm_num | |
| calc | |
| _ β€ (2 : β)^D*(Real.log 4+Real.log ((D : β)+1)+(2 : β)^D*Real.log ((N : β)+1)) := | |
| mul_le_mul_of_nonneg_left hl (by positivity) | |
| _ β€ (2 : β)^D*((2 : β)^D*(Real.log 4+Real.log ((D : β)+1))+ | |
| (2 : β)^D*(Real.log 2+Real.log (N : β))) := by gcongr; nlinarith | |
| _ = _ := by rw [h8,βh24]; ring | |
| lemma all_pattern_cost {Ξ± : Type*} (A : β β Finset β) (s : Finset Ξ±) (D : β) : | |
| (2 : β)^D*Real.log (2*((patternTotal A s D : β)+1)) β€ | |
| (4 : β)^D*(Real.log 8+Real.log ((D : β)+1)+Real.log (s.card+1 : β)+ | |
| β j β Finset.range D, Real.log ((A j).card+1 : β)) := by | |
| have h := scalar_pattern_cost D (pointBudget A s D) (patternTotal A s D) | |
| (pointBudget_pos A s D) (patternTotal_bound A s D) | |
| rw [log_pointBudget] at h | |
| convert h using 1 ; ring | |
| end SingleLatticeCovering.Shear | |
| noncomputable section | |
| namespace SingleLatticeCovering.Shear | |
| open Real Filter Topology | |
| open scoped BigOperators | |
| lemma polynomial_pattern_cost {Ξ± : Type*} (A : β β Finset β) (s : Finset Ξ±) | |
| (D : β) {L CL CA : β} (hL : 1 β€ L) (hCL : 0 β€ CL) (hCA : 0 β€ CA) | |
| (hD : (D : β) β€ L) | |
| (hlabel : Real.log (s.card+1 : β) β€ CL*L^2) | |
| (halphabet : β j < D, Real.log ((A j).card+1 : β) β€ CA*L^2) : | |
| (2 : β)^D*Real.log (2*((patternTotal A s D : β)+1)) β€ | |
| (4 : β)^D*(Real.log 8+1+CL+CA)*L^3 := by | |
| have hs : β j β Finset.range D, Real.log ((A j).card+1 : β) β€ (D : β)*(CA*L^2) := by | |
| calc | |
| _ β€ β j β Finset.range D, CA*L^2 := Finset.sum_le_sum (fun j hj => halphabet j (Finset.mem_range.mp hj)) | |
| _ = _ := by simp [nsmul_eq_mul] | |
| have hlogD : Real.log ((D : β)+1) β€ L := by | |
| have hh := Real.log_le_sub_one_of_pos (show (0 : β) < D+1 by positivity) | |
| linarith | |
| have h12 : L β€ L^2 := by nlinarith | |
| have h23 : L^2 β€ L^3 := by nlinarith [sq_nonneg (L-1)] | |
| have h01 : 0 β€ Real.log 8 := Real.log_nonneg (by norm_num) | |
| have hterm : Real.log 8+Real.log ((D : β)+1)+Real.log (s.card+1 : β)+ | |
| β j β Finset.range D, Real.log ((A j).card+1 : β) β€ (Real.log 8+1+CL+CA)*L^3 := by | |
| have hsd := mul_le_mul_of_nonneg_right hD (show 0 β€ CA*L^2 by positivity) | |
| have hlab := mul_le_mul_of_nonneg_left h23 hCL | |
| have hc := mul_le_mul_of_nonneg_left (show 1 β€ L^3 by nlinarith) h01 | |
| nlinarith | |
| calc | |
| _ β€ (4 : β)^D*(Real.log 8+Real.log ((D : β)+1)+Real.log (s.card+1 : β)+ | |
| β j β Finset.range D, Real.log ((A j).card+1 : β)) := all_pattern_cost A s D | |
| _ β€ _ := by nlinarith [mul_le_mul_of_nonneg_left hterm (show 0 β€ (4 : β)^D by positivity)] | |
| lemma log_label_count {Ξ± : Type*} (s : Finset Ξ±) {D n : β} {Cs : β} | |
| (hn : 1 β€ Real.log (n : β)) (hCs : 1 β€ Cs) (hD : (D : β) β€ Real.log (n : β)) | |
| (hs : (s.card : β) β€ (Cs*(n : β)^2)^D) : | |
| Real.log (s.card+1 : β) β€ (Real.log 2+Real.log Cs+2)*(Real.log (n : β))^2 := by | |
| have hn0 : (0 : β) < n := by | |
| by_contra h; have h0 : n=0 := by exact_mod_cast le_antisymm (le_of_not_gt h) (Nat.cast_nonneg n) | |
| subst n; norm_num at hn | |
| have hn1 : (1 : β) β€ n := by exact_mod_cast (show 1 β€ n by exact_mod_cast (Nat.succ_le_iff.mpr (by exact_mod_cast hn0))) | |
| have hp : 0 < Cs*(n : β)^2 := by positivity | |
| have hp1 : 1 β€ (Cs*(n : β)^2)^D := one_le_powβ (by nlinarith [sq_nonneg ((n : β)-1)]) | |
| have hl : Real.log (s.card+1 : β) β€ Real.log 2+(D : β)*(Real.log Cs+2*Real.log (n : β)) := by | |
| calc | |
| _ β€ Real.log (2*(Cs*(n : β)^2)^D) := Real.log_le_log (by positivity) (by linarith) | |
| _ = _ := by rw [Real.log_mul (by norm_num) (pow_pos hp _).ne',Real.log_pow, | |
| Real.log_mul (by positivity) (by positivity),Real.log_pow]; ring | |
| have hc : 0 β€ Real.log Cs := Real.log_nonneg hCs | |
| have hl2 : Real.log (n : β) β€ (Real.log (n : β))^2 := by nlinarith | |
| have h2 : 0 β€ Real.log 2 := Real.log_nonneg (by norm_num) | |
| have hh := mul_le_mul_of_nonneg_right hD (show 0 β€ Real.log Cs+2*Real.log (n : β) by linarith) | |
| nlinarith [mul_le_mul_of_nonneg_left hl2 hc, | |
| mul_le_mul_of_nonneg_left (show 1 β€ (Real.log (n : β))^2 by nlinarith) h2] | |
| lemma log_alphabet_bound {b D : β} {L : β} (hL : 1 β€ L) | |
| (hD : (D : β) β€ L) (hb : (b : β) β€ L) : | |
| Real.log 8+(D : β)*Real.log ((D : β)+2)+(b : β)^2 β€ | |
| (Real.log 8+3)*L^2 := by | |
| have hlog : Real.log ((D : β)+2) β€ 2*L := by | |
| have hh := Real.log_le_sub_one_of_pos (show (0 : β) < D+2 by positivity) | |
| linarith | |
| have hp := mul_le_mul_of_nonneg_left hlog (Nat.cast_nonneg D) | |
| have hD' := mul_le_mul_of_nonneg_right hD (show 0 β€ 2*L by linarith) | |
| have hb2 := pow_le_pow_leftβ (Nat.cast_nonneg b) hb 2 | |
| have hc := mul_le_mul_of_nonneg_left (show 1 β€ L^2 by nlinarith) | |
| (Real.log_nonneg (by norm_num : (1 : β) β€ 8)) | |
| nlinarith | |
| lemma eventually_pattern_cost {C Cs Ξ΅ : β} (hC : 0 < C) (hCs : 1 β€ Cs) (hΞ΅ : 0 < Ξ΅) : | |
| βαΆ n : β in atTop, β D : β, (D : β) β€ C*((FinalRates.firstSize n : β)+1) β | |
| β {Ξ± : Type*} (s : Finset Ξ±) (A : β β Finset β), | |
| (s.card : β) β€ (Cs*(n : β)^2)^D β | |
| (β j < D, Real.log ((A j).card+1 : β) β€ | |
| Real.log 8+(D : β)*Real.log ((D : β)+2)+(FinalRates.firstSize n : β)^2) β | |
| (2 : β)^D*Real.log (2*((patternTotal A s D : β)+1)) β€ Ξ΅*(n : β)*Real.log (n : β) := by | |
| let H := Real.log 8+1+(Real.log 2+Real.log Cs+2)+(Real.log 8+3) | |
| have hH : 0 < H := by | |
| dsimp [H] | |
| linarith [Real.log_nonneg hCs,Real.log_nonneg (by norm_num : (1 : β) β€ 8), | |
| Real.log_nonneg (by norm_num : (1 : β) β€ 2)] | |
| filter_upwards [FinalRates.eventually_dimension_small hC, | |
| FinalRates.eventually_dimension_power (C := C) (a := 4) (r := 1/2) hC (by norm_num) (by norm_num), | |
| FinalRates.eventually_firstSize_le_log (c := 1) (by norm_num), | |
| FinalRates.eventually_log_power_bound 3 (r := 1/2) (by norm_num) (div_pos hΞ΅ hH), | |
| FinalRates.log_nat_atTop.eventually (eventually_ge_atTop (1 : β)),eventually_ge_atTop (1 : β)] | |
| with n hdim hpow hb hlog hn hn1 | |
| intro D hD Ξ± s A hs hA | |
| have hDL := (hdim D hD).1 | |
| have hbL : (FinalRates.firstSize n : β) β€ Real.log (n : β) := by linarith | |
| have hc := polynomial_pattern_cost A s D hn | |
| (show 0 β€ Real.log 2+Real.log Cs+2 by linarith [Real.log_nonneg hCs,Real.log_nonneg (by norm_num : (1 : β) β€ 2)]) | |
| (show 0 β€ Real.log 8+3 by linarith [Real.log_nonneg (by norm_num : (1 : β) β€ 8)]) hDL | |
| (log_label_count s hn hCs hDL hs) | |
| (fun j hj => (hA j hj).trans (log_alphabet_bound hn hDL hbL)) | |
| have hn0 : (0 : β) β€ n := Nat.cast_nonneg n | |
| have he : (n : β)^(1/2 : β)*(n : β)^(1/2 : β)=(n : β) := by | |
| rw [βReal.rpow_add (show (0 : β) < n by exact_mod_cast hn1)] | |
| norm_num | |
| calc | |
| _ β€ (4 : β)^D*H*(Real.log (n : β))^3 := hc | |
| _ β€ (n : β)^(1/2 : β)*H*((Ξ΅/H)*(n : β)^(1/2 : β)) := by gcongr; exact hpow D hD | |
| _ = Ξ΅*(n : β) := by calc | |
| _ = Ξ΅*((n : β)^(1/2 : β)*(n : β)^(1/2 : β)) := by field_simp | |
| _ = _ := by rw [he] | |
| _ β€ _ := le_mul_of_one_le_right (mul_nonneg hΞ΅.le hn0) hn | |
| end SingleLatticeCovering.Shear | |
| end | |
| end | |
| end | |
| section | |
| noncomputable section | |
| namespace SingleLatticeCovering.FinalRates | |
| open Real Filter Topology Shear | |
| open scoped BigOperators | |
| lemma exp_error {n : β} (hn : 2 β€ n) {cost : β} | |
| (hcost : cost β€ (n : β)*Real.log (n : β)) : | |
| Real.exp (cost-(8*(n : β)*Real.log (n : β))/2) β€ | |
| 1/(n : β)^(2*n) := by | |
| have hn0 : (0 : β) < n := by exact_mod_cast (show 0 < n by omega) | |
| have hlog : 0 β€ Real.log (n : β) := Real.log_nonneg (by exact_mod_cast (show 1 β€ n by omega)) | |
| have hemp : cost-(8*(n : β)*Real.log (n : β))/2 β€ -((2*n : β) : β)*Real.log (n : β) := by | |
| push_cast; nlinarith [mul_nonneg (Nat.cast_nonneg n) hlog] | |
| apply (Real.exp_le_exp.mpr hemp).trans_eq | |
| rw [neg_mul,Real.exp_neg,Real.exp_nat_mul,Real.exp_log hn0,one_div] | |
| theorem final_conditions {C k csec Csec ΞΊ Cs CR : β} | |
| (hC : 0 < C) (hk : 0 < k) (hcsec : 0 < csec) (hCsec : 0 β€ Csec) | |
| (hΞΊ : 0 < ΞΊ) (hCs : 1 β€ Cs) (hCR : 0 β€ CR) : | |
| β Cstar : β, 0 < Cstar β§ βαΆ n : β in atTop, | |
| 2 β€ n β§ β D : β, (D : β) β€ C*((firstSize n : β)+1) β | |
| D β€ n β§ 2 β€ n-D β§ | |
| Csec*(Cstar*(n : β)*Real.log (n : β))*Real.exp (-k*(firstSize n : β)^(70/100 : β)) β€ eta (n-D) β§ | |
| 8*(n : β)*Real.log (n : β)+(2 : β)^D*Real.sqrt ((n-D : β) : β) β€ | |
| csec*ΞΊ*(Cstar*(n : β)*Real.log (n : β)) β§ | |
| (1+CR)*(Cs*((n-D : β) : β)^2)^D*Real.exp (-Real.sqrt ((n-D : β) : β)/2)<1 β§ | |
| β {Ξ± : Type*} (s : Finset Ξ±) (A : β β Finset β), | |
| (s.card : β) β€ (Cs*(n : β)^2)^D β | |
| (β j < D, Real.log ((A j).card+1 : β) β€ | |
| Real.log 8+(D : β)*Real.log ((D : β)+2)+(firstSize n : β)^2) β | |
| let Lstar := 2*((patternTotal A s D : β)+1) | |
| 1 β€ Lstar β§ (patternTotal A s D : β)<Lstar β§ | |
| Real.exp ((2 : β)^D*Real.log Lstar-(8*(n : β)*Real.log (n : β))/2) β€ | |
| 1/(n : β)^(2*n) := by | |
| let Cstar : β := 16/(csec*ΞΊ) | |
| have hstar : 0 < Cstar := div_pos (by norm_num) (mul_pos hcsec hΞΊ) | |
| have hprod : csec*ΞΊ*Cstar=16 := by dsimp [Cstar]; field_simp | |
| refine β¨Cstar,hstar,?_β© | |
| filter_upwards [eventually_cap_eta (C := C) (H := Csec*Cstar) hC hk (mul_nonneg hCsec hstar.le), | |
| eventually_discard_bound (C := C) (Ξ΅ := 8) hC (by norm_num), | |
| eventually_label_criterion hC hCs hCR, | |
| eventually_pattern_cost (C := C) (Cs := Cs) (Ξ΅ := 1) hC hCs (by norm_num), | |
| eventually_dimension_small hC,eventually_ge_atTop (4 : β)] with n hcap hdiscard hlabel hpat hdim hn | |
| refine β¨by omega,?_β© | |
| intro D hD | |
| have hDn := (hcap D hD).1 | |
| have hm : (n : β)/2 β€ ((n-D : β) : β) := by rw [Nat.cast_sub hDn]; linarith [(hdim D hD).2] | |
| have hmn : n-D β€ n := Nat.sub_le _ _ | |
| have hmh : (2 : β) β€ ((n-D : β) : β) := by | |
| have hn4 : (4 : β) β€ n := by exact_mod_cast hn | |
| linarith | |
| refine β¨hDn,by exact_mod_cast hmh,?_,?_,?_,?_β© | |
| Β· convert (hcap D hD).2 using 1 ; ring | |
| Β· have hh := hdiscard D (n-D) hD hmn | |
| have he : csec*ΞΊ*(Cstar*(n : β)*Real.log (n : β))=16*(n : β)*Real.log (n : β) := by | |
| calc | |
| _ = (csec*ΞΊ*Cstar)*(n : β)*Real.log (n : β) := by ring | |
| _ = _ := by rw [hprod] | |
| rw [he]; linarith | |
| Β· exact hlabel D (n-D) hD hm hmn | |
| Β· intro Ξ± s A hs hA | |
| have hQ : 0 β€ (patternTotal A s D : β) := Nat.cast_nonneg _ | |
| refine β¨by linarith,by linarith,?_β© | |
| exact exp_error (by omega) (by simpa using hpat D hD s A hs hA) | |
| end SingleLatticeCovering.FinalRates | |
| end | |
| end | |
| section | |
| namespace SingleLatticeCovering.Horizontal | |
| open MeasureTheory Filter | |
| open scoped BigOperators ENNReal | |
| lemma finite_threshold_selection {X I : Type*} [MeasurableSpace X] | |
| (ΞΌ : Measure X) [IsProbabilityMeasure ΞΌ] | |
| (s : Finset I) (f : I β X β ββ₯0β) (t b : I β ββ₯0β) | |
| (hf : β i β s, Measurable (f i)) | |
| (ht0 : β i β s, t i β 0) (htt : β i β s, t i β β) | |
| (hint : β i β s, β«β» x, f i x βΞΌ β€ t i*b i) | |
| (hsum : β i β s, b i < 1) : | |
| β x, β i β s, f i x β€ t i := by | |
| classical | |
| let F : X β ββ₯0β := fun x => β i β s, (t i)β»ΒΉ*f i x | |
| have hF : β«β» x, F x βΞΌ < 1 := by | |
| dsimp [F] | |
| rw [lintegral_finsetSum s (fun i hi => (hf i hi).const_mul _)] | |
| apply lt_of_le_of_lt _ hsum | |
| apply Finset.sum_le_sum | |
| intro i hi | |
| rw [lintegral_const_mul _ (hf i hi)] | |
| calc | |
| _ β€ (t i)β»ΒΉ*(t i*b i) := mul_le_mul' le_rfl (hint i hi) | |
| _ = b i := by rw [βmul_assoc,ENNReal.inv_mul_cancel (ht0 i hi) (htt i hi),one_mul] | |
| have hsome : β x, F x < 1 := by | |
| by_contra h | |
| push Not at h | |
| have hh : (1 : ββ₯0β) β€ β«β» x, F x βΞΌ := by | |
| simpa using lintegral_mono (ΞΌ := ΞΌ) (fun x => h x) | |
| exact (not_le_of_gt hF) hh | |
| obtain β¨x,hxβ© := hsome | |
| refine β¨x,fun i hi => ?_β© | |
| have hix : (t i)β»ΒΉ*f i x β€ F x := by | |
| exact Finset.single_le_sum (f := fun i => (t i)β»ΒΉ*f i x) (fun j _ => bot_le) hi | |
| have hmul : (t i)β»ΒΉ*f i x β€ 1 := hix.trans hx.le | |
| have hm := mul_le_mul' (le_refl (t i)) hmul | |
| simpa only [βmul_assoc,ENNReal.mul_inv_cancel (ht0 i hi) (htt i hi),one_mul,mul_one] using hm | |
| lemma common_hole_sample {X I : Type*} [MeasurableSpace X] | |
| (ΞΌ : Measure X) [IsProbabilityMeasure ΞΌ] (s : Finset I) | |
| (hole : I β X β ββ₯0β) (u : I β β) (C Ξ· : β) (hC : 0 β€ C) | |
| (hhole : β i β s, Measurable (hole i)) | |
| (hu : β i β s, u i β€ Ξ·) | |
| (hmean : β i β s, β«β» x, hole i x βΞΌ β€ | |
| ENNReal.ofReal (Real.exp (-u i)+C*Real.exp (-Ξ·))) | |
| (hsum : (1+C)*(β i β s, Real.exp (-u i/2)) < 1) : | |
| β x, β i β s, hole i x β€ ENNReal.ofReal (Real.exp (-u i/2)) := by | |
| apply finite_threshold_selection ΞΌ s hole | |
| (fun i => ENNReal.ofReal (Real.exp (-u i/2))) | |
| (fun i => ENNReal.ofReal ((1+C)*Real.exp (-u i/2))) hhole | |
| (fun _ _ => (ENNReal.ofReal_pos.mpr (Real.exp_pos _)).ne') | |
| (fun _ _ => ENNReal.ofReal_ne_top) | |
| Β· intro i hi | |
| apply (hmean i hi).trans | |
| rw [βENNReal.ofReal_mul (Real.exp_pos _).le] | |
| apply ENNReal.ofReal_le_ofReal | |
| have he : Real.exp (-Ξ·) β€ Real.exp (-u i) := Real.exp_le_exp.mpr (neg_le_neg (hu i hi)) | |
| have hsq : Real.exp (-u i/2)*Real.exp (-u i/2)=Real.exp (-u i) := by | |
| rw [βReal.exp_add]; congr 1; ring | |
| nlinarith [mul_le_mul_of_nonneg_left he hC] | |
| Β· rw [βENNReal.ofReal_sum_of_nonneg (fun i hi => mul_nonneg (by linarith) (Real.exp_pos _).le)] | |
| rw [βFinset.mul_sum] | |
| exact ENNReal.ofReal_lt_one.mpr hsum | |
| end SingleLatticeCovering.Horizontal | |
| end | |
| section | |
| noncomputable section | |
| end | |
| end | |
| end | |
| end OAI | |