Download data/lean/OAI/Probability/BinarySweep/SparseBounds/FewSparseBases.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 7.07 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/BinarySweep/SparseBounds/FewSparseBases.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/BinarySweep/SparseBounds/FewSparseBases.lean
-
curl -L -o FewSparseBases.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/BinarySweep/SparseBounds/FewSparseBases.lean
7.07 kB
| import Mathlib | |
| import OAI.Probability.BinarySweep.SparseBounds.SparseReduction | |
| namespace OAI | |
| noncomputable section | |
| namespace BinaryCoordinateSweeps.Sparse | |
| lemma few_eta_good (b : β) {L : β} (hb : b β€ 16000) (hL : (10:β)^26 β€ L) : | |
| Real.exp (-L/160000) β€ 1/4 β§ | |
| 4*(b:β)*Real.sqrt (Real.exp (-L/160000)) β€ Real.exp (-L/640000) := by | |
| have hbR : (b:β) β€ 16000 := by exact_mod_cast hb | |
| constructor | |
| Β· have hc : (4:β) β€ Real.exp (L/160000) := by | |
| apply (show (4:β) β€ L/160000+1 from by linarith).trans (Real.add_one_le_exp _) | |
| rw [show -L/160000=-(L/160000) by ring,Real.exp_neg] | |
| simpa only [one_div] using inv_antiβ (by norm_num : (0:β)<4) hc | |
| Β· have hc : 4*(b:β) β€ Real.exp (L/640000) := by | |
| apply (show 4*(b:β) β€ L/640000+1 from by linarith).trans (Real.add_one_le_exp _) | |
| have hs : Real.sqrt (Real.exp (-L/160000))=Real.exp (-L/320000) := by | |
| apply (Real.sqrt_eq_iff_mul_self_eq_of_pos (Real.exp_pos _)).mpr | |
| rw [βReal.exp_add] | |
| congr 1 | |
| ring | |
| rw [hs] | |
| refine (mul_le_mul_of_nonneg_right hc (Real.exp_pos _).le).trans_eq ?_ | |
| rw [βReal.exp_add] | |
| congr 1 | |
| ring | |
| lemma few_vertex_base (b h k : β) {s : β} (hs : 0<s) (hb : b β€ 16000) | |
| (hL : (10:β)^26 β€ Real.log s) (hk : ((k+h:β):β) β€ s^(1599/1600:β)) : | |
| ((k+h:β):β)*((b+1:β)/s) β€ Real.exp (-Real.log s/3200) := by | |
| have hbR : (b+1:β) β€ 16001 := by exact_mod_cast (by omega : b+1 β€ 16001) | |
| have hc : (b+1:β) β€ Real.exp (Real.log s/3200) := by | |
| apply (show (b+1:β) β€ Real.log s/3200+1 from by linarith).trans (Real.add_one_le_exp _) | |
| have hkE : ((k+h:β):β) β€ Real.exp ((1599/1600:β)*Real.log s) := by | |
| simpa only [Real.rpow_def_of_pos hs,mul_comm] using hk | |
| calc | |
| _ β€ Real.exp ((1599/1600:β)*Real.log s)*(Real.exp (Real.log s/3200)/s) := by | |
| exact mul_le_mul hkE (div_le_div_of_nonneg_right hc hs.le) (by positivity) (by positivity) | |
| _ = _ := by | |
| rw [βReal.exp_log hs,βReal.exp_sub,βReal.exp_add] | |
| simp only [Real.log_exp] | |
| congr 1 | |
| ring | |
| lemma few_line_base (u h k : β) {s : β} (hs : 0<s) | |
| (hL : (10:β)^26 β€ Real.log s) (hk : ((k+h:β):β) β€ s^(1599/1600:β)) | |
| (hu : u β€ k+h) : | |
| 2*(u:β)/(s*Real.exp (-Real.log s/160000)) β€ Real.exp (-Real.log s/3200) := by | |
| have huE : (u:β) β€ Real.exp ((1599/1600:β)*Real.log s) := by | |
| refine (show (u:β) β€ ((k+h:β):β) by exact_mod_cast hu).trans ?_ | |
| simpa only [Real.rpow_def_of_pos hs,mul_comm] using hk | |
| have hc : (2:β) β€ Real.exp ((49/160000:β)*Real.log s) := by | |
| apply (show (2:β) β€ (49/160000:β)*Real.log s+1 from by linarith).trans (Real.add_one_le_exp _) | |
| calc | |
| _ β€ (Real.exp ((49/160000:β)*Real.log s)*Real.exp ((1599/1600:β)*Real.log s))/ | |
| (s*Real.exp (-Real.log s/160000)) := by gcongr | |
| _ = _ := by | |
| rw [βReal.exp_log hs,βReal.exp_add,βReal.exp_add,βReal.exp_sub] | |
| simp only [Real.log_exp] | |
| congr 1 | |
| ring | |
| lemma adaptive_count_small (O k : β) {s m Ξ· : β} (hs : 0<s) | |
| (hL : (10:β)^26 β€ Real.log s) (hO : (O+1:β) β€ 2*s) (hm : 8000000000 β€ m*Ξ·) : | |
| (O+1:β)^β2*(k:β)/(m*Ξ·)ββ β€ Real.exp ((k:β)*Real.log s/2000000000) := by | |
| have hm0 : 0 < m*Ξ· := by linarith | |
| have hlog0 : 0 β€ Real.log (O+1:β) := Real.log_nonneg (by exact_mod_cast (Nat.le_add_left 1 O)) | |
| have hlog : Real.log (O+1:β) β€ 2*Real.log s := by | |
| have he := Real.log_le_log (by positivity : (0:β)<O+1) hO | |
| rw [Real.log_mul (by norm_num : (2:β)β 0) hs.ne'] at he | |
| have h2 := Real.log_le_sub_one_of_pos (by norm_num : (0:β)<2) | |
| linarith | |
| have hfloor : (β2*(k:β)/(m*Ξ·)ββ:β) β€ (k:β)/4000000000 := by | |
| refine (Nat.floor_le (by positivity)).trans ?_ | |
| apply (div_le_iffβ hm0).mpr | |
| have hh := mul_le_mul_of_nonneg_left hm (show (0:β) β€ k by positivity) | |
| nlinarith only [hh] | |
| rw [βReal.exp_log (by positivity : (0:β)<O+1),βReal.exp_nat_mul] | |
| apply Real.exp_le_exp.mpr | |
| calc | |
| _ β€ ((k:β)/4000000000)*(2*Real.log s) := | |
| mul_le_mul hfloor hlog hlog0 (by positivity) | |
| _ = _ := by ring | |
| end BinaryCoordinateSweeps.Sparse | |
| open scoped BigOperators Classical | |
| namespace BinaryCoordinateSweeps | |
| open Sparse | |
| lemma grid_log_upper {b r : β} {bits : Fin b β β} (hd : βj, bits j β€ 2*r) : | |
| Real.log (gridSize bits) β€ (b:β)*(2*(r:β)*Real.log 2) := by | |
| calc | |
| _ = βj : Fin b, (bits j:β)*Real.log 2 := by | |
| rw [log_gridSize] | |
| simp only [Nat.cast_pow,Nat.cast_ofNat,Real.log_pow] | |
| _ β€ β_j : Fin b, 2*(r:β)*Real.log 2 := by | |
| apply Finset.sum_le_sum | |
| intro j _ | |
| exact mul_le_mul_of_nonneg_right (by exact_mod_cast hd j) (Real.log_nonneg (by norm_num)) | |
| _ = _ := by simp | |
| lemma few_axis_eta_large {b r : β} {bits : Fin b β β} | |
| (hb : b β€ 16000) (hd : βj, r β€ bits j β§ bits j β€ 2*r) | |
| (hL : (10:β)^26 β€ Real.log (gridSize bits)) (j : Fin b) : | |
| (8000000000:β) β€ (2^bits j:β)*Real.exp (-Real.log (gridSize bits)/160000) := by | |
| have hbR : (b:β) β€ 16000 := by exact_mod_cast hb | |
| have hr : 0 β€ (r:β)*Real.log 2 := mul_nonneg (Nat.cast_nonneg _) (Real.log_nonneg (by norm_num)) | |
| have hu := grid_log_upper (fun j => (hd j).2) | |
| have hux := mul_le_mul_of_nonneg_right hbR hr | |
| have hj := mul_le_mul_of_nonneg_right (show (r:β) β€ bits j by exact_mod_cast (hd j).1) | |
| (Real.log_nonneg (by norm_num : (1:β) β€ 2)) | |
| calc | |
| _ β€ Real.log (gridSize bits)/40000+1 := by linarith | |
| _ β€ Real.exp (Real.log (gridSize bits)/40000) := Real.add_one_le_exp _ | |
| _ β€ _ := by | |
| rw [βReal.exp_log (by positivity : (0:β)<((2^bits j:β):β)),βReal.exp_add] | |
| apply Real.exp_le_exp.mpr | |
| simp only [Nat.cast_pow,Nat.cast_ofNat,Real.log_pow] | |
| linarith | |
| lemma outside_card_add_one_le {b : β} (bits : Fin b β β) (j : Fin b) : | |
| (Fintype.card (GridOutside bits j)+1:β) β€ 2*(gridSize bits:β) := by | |
| have he := outside_card_mul_axis bits j | |
| have hp : 1 β€ 2^bits j := Nat.one_le_pow _ _ (by omega) | |
| have hle : Fintype.card (GridOutside bits j) β€ gridSize bits := by nlinarith | |
| have hg : 1 β€ gridSize bits := gridSize_pos bits | |
| exact_mod_cast (show Fintype.card (GridOutside bits j)+1 β€ 2*gridSize bits from by omega) | |
| lemma few_cutoff_bounds (b k : β) (hb : 1 β€ b) (hbB : b β€ 16000) : | |
| 2*((k/4+1)-1+2*b*((k/(8*b)+1)-1)) β€ k β§ | |
| (k:β) β€ 8*(((k/4+1+1)/2:β):β) β§ | |
| (k:β) β€ 128000*(k/(8*b)+1:β) := by | |
| have h1 := Nat.div_mul_le_self k 4 | |
| have h2 := Nat.div_mul_le_self k (8*b) | |
| have hmod := Nat.mod_lt k (by omega : 0<8*b) | |
| have he := Nat.mod_add_div k (8*b) | |
| constructor | |
| Β· simp only [Nat.add_sub_cancel] | |
| nlinarith | |
| constructor | |
| Β· exact_mod_cast (show k β€ 8*((k/4+1+1)/2) from by omega) | |
| Β· have ht : k β€ (8*b)*(k/(8*b)+1) := by nlinarith | |
| have hh := ht.trans (Nat.mul_le_mul_right _ (show 8*b β€ 128000 from by omega)) | |
| exact_mod_cast hh | |
| end BinaryCoordinateSweeps | |
| end | |
| end OAI | |