Download data/lean/OAI/Computability/FourierTransform/Asymptotics.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 7.65 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/FourierTransform/Asymptotics.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/FourierTransform/Asymptotics.lean
-
curl -L -o Asymptotics.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/FourierTransform/Asymptotics.lean
7.65 kB
| import OAI.Computability.FourierTransform.UniformBounds | |
| namespace OAI | |
| /- asymptotic analysis, one n for both length functions -/ | |
| namespace PowerSaving | |
| open RAM Bench Selection Slant Filter Asymptotics Real | |
| noncomputable section | |
| namespace Skies | |
| abbrev Tm (n : β) : β := log (n:β) | |
| abbrev Qm (n : β) : β := log (Tm n) | |
| lemma Ttop : Tendsto Tm atTop atTop := Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop | |
| lemma Qtop : Tendsto Qm atTop atTop := Real.tendsto_log_atTop.comp Ttop | |
| lemma log2_min : 2/3 β€ log (2:β) := by | |
| have hh := le_log_one_add_of_nonneg (show (0:β)β€1 by norm_num) | |
| norm_num at * | |
| exact hh | |
| -- n is problem size, N allowed between n and 2n | |
| lemma stack_lim (n N : β) (hn : 0<n) (h : nβ€N) (hk : N β€ 2*n) (ht : 1β€Tm n) : | |
| (stackN N:β) β€ 10 * Tm n := by | |
| let k := Nat.log 2 (2*N) | |
| have H : 2^k β€ 2*N := Nat.pow_log_le_self _ (by omega) | |
| have H0 : 2^k β€ 4*n := by omega | |
| have he : 0<(n:β) := by exact_mod_cast hn | |
| have HH := log_le_log (by positivity : 0<(2:β)^k) | |
| (show (2:β)^k β€ 4*n by exact_mod_cast H0) | |
| rw [log_pow,log_mul (by norm_num) he.ne'] at HH | |
| have H4 := log_le_sub_one_of_pos (show (0:β)<4 by norm_num) | |
| change (((k+1:β):β)) β€ _ | |
| push_cast | |
| unfold Tm at * | |
| nlinarith [log2_min,show 0β€(k:β) by positivity] | |
| lemma order_pow_lim (n N : β) (hn : 0<n) (h : nβ€N) (hk : N β€ 2*n) (ht : 1 β€ Tm n) : | |
| (2:β)^orderE N β€ 10^6*Tm n^2 := by | |
| have hh : (2:β)^orderE N β€ 8*harvestN N := by exact_mod_cast orderE_small N | |
| refine hh.trans ?_ | |
| unfold harvestN silo; push_cast | |
| have hg := stack_lim n N hn h hk ht | |
| calc | |
| _ β€ 8*(16*(14*Tm n))^2 := by gcongr; linarith | |
| _ β€ _ := by nlinarith [sq_nonneg (Tm n)] | |
| lemma order_lim (n N : β) (hn : 0<n) (h : nβ€N) (hk : N β€ 2*n) (ht : 1 β€ Tm n) (hu : 1 β€ Qm n) : | |
| (orderE N:β) β€ 3*10^6 * Qm n := by | |
| have H := log_le_log (by positivity : 0<(2:β)^orderE N) (order_pow_lim n N hn h hk ht) | |
| have he : 0<Tm n := by linarith | |
| rw [log_pow,log_mul (by norm_num) (by positivity),log_pow,log_pow] at H | |
| have H4 := log_le_sub_one_of_pos (show 0 < (10:β) by norm_num) | |
| unfold Qm at * | |
| have h0 : 0 β€ (orderE N:β) := by positivity | |
| push_cast at H | |
| nlinarith [log2_min] | |
| lemma score_lim (n N : β) (hn : 0<n) (h : nβ€N) (hk : N β€ 2*n) (ht : 1 β€ Tm n) (hu : 1 β€ Qm n) : | |
| (score (orderE N):β)+1 β€ 10^32*Qm n^2 := by | |
| have H := order_lim n N hn h hk ht hu | |
| have hk : (score (orderE N):β) β€ 20000000*((orderE N:β)+1)^2+7 := by | |
| exact_mod_cast score_le (orderE N) | |
| calc | |
| _ β€ (20000000*((orderE N:β)+1)^2+7)+1 := by gcongr | |
| _ β€ (20000000*(4*10^6*Qm n)^2+7)+1 := by gcongr; linarith | |
| _ β€ _ := by nlinarith | |
| lemma hills_lim (n N : β) (hn : 0<n) (h : nβ€N) (hk : N β€ 2*n) (ht : 1 β€ Tm n) : | |
| (hills (barge N).l:β) β€ 100*Tm n^alpha := by | |
| have he : 0<Tm n := by linarith | |
| have H := stack_lim n N hn h hk ht | |
| have G : ((barge N).l:β) β€ stackN N := by | |
| exact_mod_cast (barge_spec N (lt_of_lt_of_le hn h)).count | |
| have hg := alpha_pos | |
| refine (hills_real _).trans ?_ | |
| calc | |
| _ β€ 2*(11*Tm n)^alpha := by gcongr; linarith | |
| _ = 2*(11^alpha*Tm n^alpha) := by rw [mul_rpow (by norm_num) he.le] | |
| _ β€ 2*(11^(1:β)*Tm n^alpha) := by gcongr <;> first | exact alpha_lt.le | norm_num | |
| _ β€ _ := by | |
| rw [rpow_one] | |
| have hTT : 0 < Tm n^alpha := by positivity | |
| linarith | |
| def flight (n : β) := (n:β)*(Tm n)^alpha*Qm n^2 | |
| lemma leg_lim (n N : β) (hn : 0<n) (h : nβ€N) (hk : N β€ 2*n) (ht : 1 β€ Tm n) (hu : 1 β€ Qm n) : | |
| (leg N:β) β€ 10^40*flight n := by | |
| have hg : (barge N).vol β€ 8*n := by | |
| have hh := (barge_spec N (by omega)).upper | |
| omega | |
| have hh : ((barge N).vol:β) β€ 8*n := by exact_mod_cast hg | |
| have hT : 0 < Tm n := by linarith | |
| unfold leg; push_cast | |
| calc | |
| _ β€ (10^32 * Qm n^2)*((8*n)*(100*Tm n^alpha)) := | |
| mul_le_mul (score_lim n N hn h hk ht hu) | |
| (mul_le_mul hh (hills_lim n N hn h hk ht) (by positivity) (by positivity)) | |
| (by positivity) (by positivity) | |
| _ = 8*100*10^32*flight n := by unfold flight; ring | |
| _ β€ _ := by | |
| have hh : 0 β€ flight n := by unfold flight; positivity | |
| gcongr; norm_num | |
| lemma flight_big (n : β) (ht : 1 β€ Tm n) (hu : 1 β€ Qm n) : | |
| (n:β) β€ flight n := by | |
| have H := Real.one_le_rpow ht alpha_pos.le | |
| unfold flight | |
| calc | |
| (n:β) = n*1*1 := by ring | |
| _ β€ _ := by gcongr; nlinarith | |
| -- little o fournishes eventual caps. | |
| lemma dwarf {v : βββ} (h : Tendsto v atTop atTop) (d : β) {p c : β} (hp : 0<p) (hc : 0<c) : | |
| βαΆ n in atTop, log (v n)^d β€ c*v n^p := by | |
| have H := (isLittleO_log_rpow_rpow_atTop (d:β) hp).comp_tendsto h | |
| have hg := H.def hc | |
| filter_upwards [hg,h.eventually_ge_atTop 1] with n hn he | |
| have he' : 0<v n := by linarith | |
| change βlog (v n)^(d:β)β β€ c*βv n^pβ at hn | |
| rw [rpow_natCast,Real.norm_of_nonneg (pow_nonneg (Real.log_nonneg he) _), | |
| Real.norm_of_nonneg (by positivity)] at hn | |
| exact hn | |
| variable {N : βββ} | |
| -- initial branch disappears | |
| lemma docks_ev (h : β n:β,n β€ N n β§ N n β€ 2*n) : | |
| βαΆ n in atTop, Ports (N n) := by | |
| have H := dwarf (v:=fun n => (n:β)) tendsto_natCast_atTop_atTop 2 | |
| (c:=1/10^6) (p:=1) (by norm_num) (by norm_num) | |
| filter_upwards [H,eventually_gt_atTop 0,Ttop.eventually_ge_atTop 1] with n hh hn ht | |
| rw [rpow_one] at hh | |
| have hh' : (Tm n)^2 β€ 1/10^6*n := hh | |
| have hh1 := order_pow_lim n (N n) hn (h n).1 (h n).2 ht | |
| have hh2 : (2:β)^(orderE (N n)) β€ n := by linarith | |
| exact (show 2^orderE (N n) β€ n by exact_mod_cast hh2).trans (h n).1 | |
| lemma polylog_ev (h : β n:β,n β€ N n β§ N n β€ 2*n) (d : β) : | |
| βαΆ n in atTop, ((stackN (N n):β)+2)^d β€ n := by | |
| have h0 : 0< (12:β)^d := by positivity | |
| have H := dwarf (v:=fun n => (n:β)) tendsto_natCast_atTop_atTop d | |
| (c:=((12:β)^d)β»ΒΉ) (p:=1) (by norm_num) (by positivity) | |
| filter_upwards [H,eventually_gt_atTop 0,Ttop.eventually_ge_atTop 1] with n hh hn ht | |
| rw [rpow_one] at hh | |
| have hh' : (Tm n)^d β€ ((12:β)^d)β»ΒΉ*n := hh | |
| have hh1 := stack_lim n (N n) hn (h n).1 (h n).2 ht | |
| calc | |
| _ β€ (12*Tm n)^d := by gcongr; linarith | |
| _ β€ _ := by | |
| rw [mul_pow] | |
| calc | |
| _ β€ _ := mul_le_mul_of_nonneg_left hh' h0.le | |
| _ = _ := by rw [β mul_assoc,mul_inv_cancelβ h0.ne',one_mul] | |
| lemma wind_ev (h : β n:β,n β€ N n β§ N n β€ 2*n) (d : β) : | |
| βαΆ n in atTop,(fairwind d (N n):β)+1 β€ 10^41*flight n := by | |
| filter_upwards [docks_ev h,polylog_ev h d,eventually_gt_atTop 0,Ttop.eventually_ge_atTop 1, | |
| Qtop.eventually_ge_atTop 1] with n hh hk hn ht hu | |
| unfold fairwind Bench.surf | |
| rw [ite_eq_left hh,Nat.add_zero] | |
| push_cast | |
| have hp := leg_lim n (N n) hn (h n).1 (h n).2 ht hu | |
| have he := flight_big n ht hu | |
| have he' : 1β€(n:β) := by exact_mod_cast hn | |
| have hx : (N n:β) β€ 2*n := by exact_mod_cast (h n).2 | |
| linarith | |
| lemma lunch_big (a b : Ration) (h : β n:β,n β€ N n β§ N n β€ 2*n) : | |
| (fun n : β => (lunch a b N n:β)) =O[atTop] flight := by | |
| let W := lunch a b N | |
| refine isBigO_iff.mpr β¨(a.c:β)*10^41+1+(b.c:β)*10^41,?_β© | |
| filter_upwards [wind_ev h a.d,wind_ev h b.d,eventually_gt_atTop 0,Ttop.eventually_ge_atTop 1, | |
| Qtop.eventually_ge_atTop 1] with n hh hk hn ht hu | |
| have he := flight_big n ht hu | |
| have h1 : 1β€(n:β) := by exact_mod_cast hn | |
| rw [Real.norm_of_nonneg (by positivity),Real.norm_of_nonneg (by linarith)] | |
| unfold lunch calorie | |
| push_cast; simp only [add_mul,one_mul,mul_assoc] | |
| gcongr | |
| exact h1.trans he | |
| end Skies | |
| end | |
| end PowerSaving | |
| end OAI | |