Download data/lean/OAI/Combinatorics/EditDistance/UpperParameters.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 6.5 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/EditDistance/UpperParameters.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/EditDistance/UpperParameters.lean
-
curl -L -o UpperParameters.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/EditDistance/UpperParameters.lean
6.5 kB
| import OAI.Combinatorics.EditDistance.DepthInversion | |
| import OAI.Combinatorics.EditDistance.UpperRecursion | |
| namespace OAI | |
| /-! | |
| # Branching and depth choices at every sufficiently large length | |
| -/ | |
| namespace EditUpperParameters | |
| open Filter | |
| noncomputable def peak (t : β) : β := Real.sqrt (t*Real.log t) | |
| noncomputable def level (t : β) : β := βEditDepth.radius tββ | |
| noncomputable def branching (t : β) : β := βReal.exp (2*peak t)ββ | |
| lemma radius_peak {t : β} (ht : 1 β€ t) (hlt : 1 β€ Real.log t) : | |
| EditDepth.radius t * Real.log t = peak t β§ EditDepth.radius t * peak t = t β§ 1 β€ peak t := by | |
| have tp : 0 < t := by linarith | |
| have lp : 0 < Real.log t := by linarith | |
| have hr : 0 β€ EditDepth.radius t := EditDepth.radius_nonneg t | |
| have hr2 : EditDepth.radius t^2 = t/Real.log t := Real.sq_sqrt (div_nonneg tp.le lp.le) | |
| have hr2' : EditDepth.radius t^2*Real.log t = t := (eq_div_iff lp.ne').mp hr2 | |
| have hs : peak t = EditDepth.radius t*Real.log t := by | |
| apply (Real.sqrt_eq_iff_mul_self_eq (by positivity) (by positivity)).mpr | |
| nlinarith [congrArg (fun x : β => x*Real.log t) hr2'] | |
| refine β¨hs.symm,?_,?_β© | |
| Β· rw [hs] | |
| nlinarith [hr2'] | |
| Β· apply Real.le_sqrt_of_sq_le | |
| nlinarith | |
| lemma choose_parameters {t : β} (ht : 1 β€ t) (hlt : 1024 β€ Real.log t) | |
| (hr : 2 β€ EditDepth.radius t) : | |
| 1 β€ level t β§ 2 β€ branching t β§ | |
| Real.exp t β€ (branching t : β)^(level t) β§ | |
| 2*((branching t : β)+2)* | |
| (1024*(1+(level t : β)*Real.log (branching t : β))^2)^(level t) β€ | |
| Real.exp (32*peak t) := by | |
| have hlt1 : 1 β€ Real.log t := by linarith | |
| obtain β¨hRS,hRt,hSβ© := radius_peak ht hlt1 | |
| have hNup : (level t : β) β€ EditDepth.radius t := Nat.floor_le (EditDepth.radius_nonneg t) | |
| have hNfloor := Nat.lt_floor_add_one (EditDepth.radius t) | |
| change EditDepth.radius t < (level t : β)+1 at hNfloor | |
| have hNlo : EditDepth.radius t/2 β€ (level t : β) := by linarith | |
| have hNp : 1 β€ level t := by | |
| have hh : (1 : β) β€ level t := by linarith | |
| exact_mod_cast hh | |
| have helo : Real.exp (2*peak t) β€ (branching t : β) := Nat.le_ceil _ | |
| have hehi : (branching t : β) < Real.exp (2*peak t)+1 := Nat.ceil_lt_add_one (Real.exp_pos _).le | |
| have hexp : 3 β€ Real.exp (2*peak t) := by have := Real.add_one_le_exp (2*peak t); linarith | |
| have hb : 2 β€ branching t := by | |
| have hh : (2 : β) β€ branching t := by linarith | |
| exact_mod_cast hh | |
| have hbp : (0 : β) < branching t := by exact_mod_cast (show 0 < branching t by omega) | |
| have hBnon : 0 β€ Real.log (branching t : β) := Real.log_nonneg (by exact_mod_cast (show 1 β€ branching t by omega)) | |
| have hBlo : 2*peak t β€ Real.log (branching t : β) := (Real.le_log_iff_exp_le hbp).mpr helo | |
| have hBup : Real.log (branching t : β) β€ 3*peak t := by | |
| have hh : (branching t : β) β€ 2*Real.exp (2*peak t) := by linarith | |
| have hl := Real.log_le_log hbp hh | |
| rw [Real.log_mul (by norm_num) (Real.exp_ne_zero _),Real.log_exp] at hl | |
| have h2 := log_two_bounds | |
| linarith | |
| have hBlog : Real.log ((branching t : β)+2) β€ 5*peak t := by | |
| have hh : (branching t : β)+2 β€ 4*Real.exp (2*peak t) := by linarith | |
| have hl := Real.log_le_log (by positivity : 0 < (branching t : β)+2) hh | |
| rw [Real.log_mul (by norm_num) (Real.exp_ne_zero _),Real.log_exp] at hl | |
| have h4 := Real.log_le_sub_one_of_pos (by norm_num : (0 : β)<4) | |
| linarith | |
| have hNnon : 0 β€ (level t : β) := Nat.cast_nonneg _ | |
| have hNblo : t β€ (level t : β)*Real.log (branching t : β) := by | |
| have hh := mul_le_mul hNlo hBlo (by linarith : 0 β€ 2*peak t) hNnon | |
| nlinarith [hRt] | |
| have hNbup : (level t : β)*Real.log (branching t : β) β€ 3*t := by | |
| have hh := mul_le_mul hNup hBup hBnon (EditDepth.radius_nonneg t) | |
| nlinarith [hRt] | |
| have hcap : Real.exp t β€ (branching t : β)^(level t) := by | |
| apply (Real.le_log_iff_exp_le (pow_pos hbp _)).mp | |
| rw [Real.log_pow] | |
| exact hNblo | |
| let T := 1+(level t : β)*Real.log (branching t : β) | |
| let P := 1024*T^2 | |
| have hT : 0 < T := by dsimp [T]; positivity | |
| have hP : 0 < P := by dsimp [P]; positivity | |
| have hTup : T β€ 4*t := by dsimp [T]; linarith | |
| have hlogT : Real.log T β€ 3+Real.log t := by | |
| have hh := Real.log_le_log hT hTup | |
| rw [Real.log_mul (by norm_num) (by linarith : t β 0)] at hh | |
| have h4 := Real.log_le_sub_one_of_pos (by norm_num : (0 : β)<4) | |
| linarith | |
| have hlogP : Real.log P β€ 4*Real.log t := by | |
| dsimp [P] | |
| rw [Real.log_mul (by norm_num) (pow_ne_zero 2 hT.ne'),Real.log_pow] | |
| have h1024 := Real.log_le_sub_one_of_pos (by norm_num : (0 : β)<1024) | |
| norm_num only [Nat.cast_ofNat] | |
| linarith | |
| have hNP : (level t : β)*Real.log P β€ 4*peak t := by | |
| have h1 := mul_le_mul_of_nonneg_left hlogP hNnon | |
| have h2 := mul_le_mul_of_nonneg_right hNup (show 0 β€ 4*Real.log t by linarith) | |
| nlinarith [hRS] | |
| refine β¨hNp,hb,hcap,?_β© | |
| change 2*((branching t : β)+2)*P^(level t) β€ _ | |
| apply (Real.log_le_iff_le_exp (by positivity)).mp | |
| rw [Real.log_mul (by positivity) (pow_ne_zero _ hP.ne'), | |
| Real.log_mul (by norm_num) (by positivity : ((branching t : β)+2) β 0),Real.log_pow] | |
| have h2 := log_two_bounds | |
| nlinarith | |
| theorem eventual_choice : βαΆ d : β in atTop, | |
| 1 β€ level (Real.log (d : β)) β§ 2 β€ branching (Real.log (d : β)) β§ | |
| d β€ branching (Real.log (d : β))^level (Real.log (d : β)) β§ | |
| 2*((branching (Real.log (d : β)) : β)+2)* | |
| (1024*(1+(level (Real.log (d : β)) : β)*Real.log (branching (Real.log (d : β)) : β))^2)^level (Real.log (d : β)) β€ | |
| Real.exp (32*Real.sqrt (Real.log (d : β)*Real.log (Real.log (d : β)))) := by | |
| have htend : Tendsto (fun d : β => Real.log (d : β)) atTop atTop := | |
| Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop | |
| have h1 := htend.eventually (eventually_ge_atTop (1 : β)) | |
| have h2 := htend.eventually (Real.tendsto_log_atTop.eventually (eventually_ge_atTop (1024 : β))) | |
| have h3 := htend.eventually (EditDepth.eventually_radius_large 0) | |
| filter_upwards [h1,h2,h3,eventually_ge_atTop (1 : β)] with d ht hl hr hd | |
| have hr' : 2 β€ EditDepth.radius (Real.log (d : β)) := by norm_num at hr; linarith | |
| obtain β¨hN,hb,hcap,hboundβ© := choose_parameters ht hl hr' | |
| refine β¨hN,hb,?_,hboundβ© | |
| rw [Real.exp_log (by exact_mod_cast (show 0 < d by omega))] at hcap | |
| exact_mod_cast hcap | |
| end EditUpperParameters | |
| end OAI | |