Download data/lean/OAI/Combinatorics/FiniteCircle/UpperParameters.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 6.84 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/FiniteCircle/UpperParameters.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/FiniteCircle/UpperParameters.lean
-
curl -L -o UpperParameters.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/FiniteCircle/UpperParameters.lean
6.84 kB
| import OAI.Combinatorics.FiniteCircle.HistogramEmbedding | |
| namespace OAI | |
| namespace FiniteCircle | |
| open scoped BigOperators List | |
| open scoped ComplexConjugate | |
| open RCLike Module | |
| open Classical | |
| theorem log_add_one_le_dyadic_count (n : β) : | |
| Real.log ((n:β)+1) β€ Nat.log 2 n + 1 := by | |
| have hpow : n+1 β€ 2^(Nat.log 2 n + 1) := | |
| Nat.succ_le_of_lt (Nat.lt_pow_succ_log_self (by norm_num) n) | |
| have hlog := Real.log_le_log (by positivity : (0:β) < (n:β)+1) | |
| (show (n:β)+1 β€ (2:β)^(Nat.log 2 n+1) by exact_mod_cast hpow) | |
| rw [Real.log_pow] at hlog | |
| have hl2 : Real.log 2 β€ 1 := by linarith [Real.log_two_lt_d9] | |
| have hc : (0:β) β€ Nat.log 2 n + 1 := by positivity | |
| push_cast at hlog | |
| nlinarith | |
| theorem log_large_aux {t : β} (ht : 16 β€ t) : | |
| 1 β€ Real.log t β§ 4 * Real.log t β€ t := by | |
| have ht0 : 0 < t := by linarith | |
| have hl16 : Real.log 16 = 4 * Real.log 2 := by | |
| rw [show (16:β) = 2^4 by norm_num, Real.log_pow] | |
| norm_num | |
| have hl2lo : (1:β)/2 β€ Real.log 2 := by linarith [Real.log_two_gt_d9] | |
| have hl2hi : Real.log 2 β€ 1 := by linarith [Real.log_two_lt_d9] | |
| have hlo := Real.log_le_log (by norm_num : (0:β) < 16) ht | |
| rw [hl16] at hlo | |
| refine β¨by linarith, ?_β© | |
| have hr := Real.log_le_sub_one_of_pos (div_pos ht0 (by norm_num) : 0 < t/16) | |
| rw [Real.log_div ht0.ne' (by norm_num), hl16] at hr | |
| linarith | |
| theorem natLog_le_twice_log (n : β) : (Nat.log 2 n : β) β€ 2 * Real.log n := by | |
| have h := Real.natLog_le_logb n 2 | |
| simp only [Real.logb, Nat.cast_ofNat] at h | |
| have hl : (1:β)/2 β€ Real.log 2 := by linarith [Real.log_two_gt_d9] | |
| have hl0 : 0 < Real.log 2 := by linarith | |
| have hn := Real.log_natCast_nonneg n | |
| refine h.trans ((div_le_iffβ hl0).mpr ?_) | |
| nlinarith | |
| theorem exists_power_parameters {d : β} (hd : 16 β€ Real.log d) : | |
| β b H : β, 2 β€ b β§ 1 β€ H β§ d β€ b^H β§ | |
| (4 * (b:β) * (1024 * ((Nat.log 2 (b^H) : β)+1)^2)^H) β€ | |
| Real.exp (32 * Real.sqrt (Real.log d * Real.log (Real.log d))) := by | |
| let t := Real.log d | |
| let l := Real.log t | |
| have ht : 16 β€ t := hd | |
| obtain β¨hl, hltβ© := log_large_aux ht | |
| change 1 β€ l at hl | |
| change 4*l β€ t at hlt | |
| have ht0 : 0 < t := by linarith | |
| have hl0 : 0 < l := by linarith | |
| let r := Real.sqrt (t/l) | |
| let s := Real.sqrt (t*l) | |
| have hr0 : 0 β€ r := Real.sqrt_nonneg _ | |
| have hs0 : 0 β€ s := Real.sqrt_nonneg _ | |
| have hr2 : r^2 = t/l := Real.sq_sqrt (div_nonneg ht0.le hl0.le) | |
| have hs2 : s^2 = t*l := Real.sq_sqrt (mul_nonneg ht0.le hl0.le) | |
| have hrl : r^2*l = t := by rw [hr2]; field_simp | |
| have hrlo : 2 β€ r := by | |
| have h : (4:β) β€ t/l := (le_div_iffβ hl0).mpr (by linarith) | |
| nlinarith only [h, hr2, hr0] | |
| have hrhi : r β€ t := by | |
| have h : t/l β€ t := div_le_self ht0.le hl | |
| nlinarith only [h, hr2, hr0, ht] | |
| have hrs : r*l = s := by | |
| have hsq : (r*l)^2 = s^2 := by | |
| calc | |
| _ = (r^2*l)*l := by ring | |
| _ = t*l := by rw [hrl] | |
| _ = _ := hs2.symm | |
| have hp : 0 β€ r*l := mul_nonneg hr0 hl0.le | |
| nlinarith only [hsq, hp, hs0] | |
| have htr : t = r*s := by rw [β hrs, β hrl]; ring | |
| have hslo : 1 β€ s := by nlinarith only [hs2, hs0, ht, hl] | |
| let H := βrββ | |
| have hHhi : (H:β) β€ r := Nat.floor_le hr0 | |
| have hHlow : r < (H:β)+1 := Nat.lt_floor_add_one r | |
| have hHhalf : r/2 β€ (H:β) := by linarith | |
| have hHpos : 0 < (H:β) := by linarith | |
| have hHnat : 1 β€ H := by exact_mod_cast (show (1:β) β€ H by linarith only [hrlo, hHhalf]) | |
| let b := βReal.exp (t/H)ββ | |
| have hbexp : Real.exp (t/H) β€ (b:β) := Nat.le_ceil _ | |
| have hbupper : (b:β) β€ 2 * Real.exp (t/H) := by | |
| have hc : (b:β) < Real.exp (t/H)+1 := Nat.ceil_lt_add_one (Real.exp_pos _).le | |
| have he : 1 β€ Real.exp (t/H) := Real.one_le_exp_iff.mpr (div_nonneg ht0.le hHpos.le) | |
| linarith | |
| have hb2 : 2 β€ b := by | |
| have he : 1 < Real.exp (t/H) := Real.one_lt_exp_iff.mpr (div_pos ht0 hHpos) | |
| have hb1 : (1:β) < b := he.trans_le hbexp | |
| exact_mod_cast hb1 | |
| have hb0 : (0:β) < b := by exact_mod_cast (by omega : 0 < b) | |
| have hlblo : t/H β€ Real.log b := by | |
| have h := Real.log_le_log (Real.exp_pos _) hbexp | |
| simpa only [Real.log_exp] using h | |
| have hlbhi : Real.log b β€ 1 + t/H := by | |
| have h := Real.log_le_log hb0 hbupper | |
| rw [Real.log_mul (by norm_num) (Real.exp_pos _).ne', Real.log_exp] at h | |
| linarith [Real.log_two_lt_d9] | |
| let n := b^H | |
| have hn0 : (0:β) < n := by dsimp [n]; positivity | |
| have hlogn : Real.log n = (H:β)*Real.log b := by simp [n, Real.log_pow] | |
| have htn : t β€ Real.log n := by | |
| rw [hlogn] | |
| calc | |
| _ = (H:β)*(t/H) := by field_simp | |
| _ β€ _ := mul_le_mul_of_nonneg_left hlblo hHpos.le | |
| have hnt : Real.log n β€ 2*t := by | |
| rw [hlogn] | |
| have h := mul_le_mul_of_nonneg_left hlbhi hHpos.le | |
| have he : (H:β)*(1+t/H) = H+t := by field_simp | |
| rw [he] at h | |
| linarith | |
| have hd0 : (0:β) < d := by | |
| by_contra h | |
| have hd0 : d = 0 := by exact_mod_cast (le_antisymm (not_lt.mp h) (Nat.cast_nonneg d)) | |
| norm_num [hd0] at hd | |
| have hdn : d β€ n := by | |
| exact_mod_cast (Real.log_le_log_iff hd0 hn0).mp htn | |
| let K : β := (Nat.log 2 n : β)+1 | |
| have hKpos : 0 < K := by dsimp [K]; positivity | |
| have hKbound : K β€ 5*t := by | |
| have h := natLog_le_twice_log n | |
| dsimp [K] | |
| linarith | |
| have hlogK : Real.log K β€ 4+l := by | |
| have h := Real.log_le_log hKpos hKbound | |
| rw [Real.log_mul (by norm_num) ht0.ne'] at h | |
| have h5 := Real.log_le_sub_one_of_pos (by norm_num : (0:β) < 5) | |
| dsimp [l] | |
| linarith | |
| let B : β := 1024*K^2 | |
| have hBpos : 0 < B := by dsimp [B]; positivity | |
| have hlogB : Real.log B β€ 20*l := by | |
| have h1024 : Real.log 1024 = 10 * Real.log 2 := by | |
| rw [show (1024:β)=2^10 by norm_num, Real.log_pow] | |
| norm_num | |
| dsimp [B] | |
| rw [Real.log_mul (by norm_num) (pow_pos hKpos 2).ne', Real.log_pow, h1024] | |
| norm_num | |
| linarith only [hlogK, hl, Real.log_two_lt_d9] | |
| have hdiv : t/(H:β) β€ 2*s := by | |
| apply (div_le_iffβ hHpos).mpr | |
| rw [htr] | |
| nlinarith only [hHhalf, hs0] | |
| have hHl : (H:β)*l β€ s := by rw [β hrs]; exact mul_le_mul_of_nonneg_right hHhi hl0.le | |
| have hprodpos : 0 < 4*(b:β)*B^H := by positivity | |
| have hlogprod : Real.log (4*(b:β)*B^H) β€ 32*s := by | |
| rw [Real.log_mul (by positivity) (pow_pos hBpos H).ne', | |
| Real.log_mul (by norm_num) hb0.ne', Real.log_pow] | |
| have h4 : Real.log 4 β€ 2 := by | |
| rw [show (4:β)=2^2 by norm_num, Real.log_pow] | |
| norm_num only [Nat.cast_ofNat] | |
| nlinarith only [Real.log_two_lt_d9] | |
| have h := mul_le_mul_of_nonneg_left hlogB hHpos.le | |
| nlinarith only [h4, hlbhi, hdiv, h, hHl, hslo] | |
| refine β¨b, H, hb2, hHnat, hdn, ?_β© | |
| change 4*(b:β)*B^H β€ Real.exp (32*s) | |
| exact (Real.log_le_iff_le_exp hprodpos).mp hlogprod | |
| end FiniteCircle | |
| end OAI | |