Download data/lean/OAI/Combinatorics/EditDistance/DepthInversion.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 4.9 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/EditDistance/DepthInversion.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/EditDistance/DepthInversion.lean
-
curl -L -o DepthInversion.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/EditDistance/DepthInversion.lean
4.9 kB
| import OAI.Combinatorics.EditDistance.LowerParameters | |
| namespace OAI | |
| /-! | |
| # Inverting recursive depth for all sufficiently large lengths | |
| -/ | |
| namespace EditDepth | |
| open Filter | |
| noncomputable def radius (t : β) := Real.sqrt (t / Real.log t) | |
| noncomputable def depth (t : β) : β := βradius t / 100ββ | |
| lemma radius_nonneg (t : β) : 0 β€ radius t := Real.sqrt_nonneg _ | |
| lemma eventually_radius_large (K : β) : | |
| βαΆ t : β in atTop, (100 : β)*(K+2) β€ radius t := by | |
| let R : β := 100*((K : β)+2) | |
| have hR : 0 < R := by dsimp [R]; positivity | |
| have he : 0 < 1/R^2 := by positivity | |
| have hlog := Real.isLittleO_log_id_atTop.def he | |
| have hl := Real.tendsto_log_atTop.eventually (eventually_ge_atTop (1 : β)) | |
| filter_upwards [hlog,hl,eventually_ge_atTop (1 : β)] with t ht hlt htp | |
| have tp : 0 < t := by linarith | |
| have lp : 0 < Real.log t := by linarith | |
| have ht' : Real.log t β€ t/R^2 := by | |
| simpa only [Function.id_def,Real.norm_eq_abs,abs_of_pos tp,abs_of_pos lp,div_eq_mul_inv,one_mul,mul_comm] using ht | |
| have hs : R^2 β€ t/Real.log t := by | |
| apply (le_div_iffβ lp).mpr | |
| have hb := (le_div_iffβ (sq_pos_of_pos hR)).mp ht' | |
| nlinarith | |
| exact Real.le_sqrt_of_sq_le hs | |
| lemma depth_lower {t : β} (ht : 200 β€ radius t) : radius t/200 β€ (depth t : β) := by | |
| have hf := Nat.lt_floor_add_one (radius t/100) | |
| change radius t/100 < (depth t : β)+1 at hf | |
| linarith | |
| lemma depth_upper (t : β) : (depth t : β) β€ radius t/100 := | |
| Nat.floor_le (div_nonneg (radius_nonneg t) (by norm_num)) | |
| lemma depth_bounds {t : β} (ht : 1 β€ t) (hlt : 1 β€ Real.log t) | |
| (hr : 200 β€ radius t) (hll : Real.log (Real.log t) β€ Real.log t/6) | |
| (hlarge : 12*Real.log (200 : β) β€ Real.log t) : | |
| 1000*(depth t : β)^2*Real.log (depth t : β) β€ t β§ | |
| Real.sqrt (t*Real.log t)/1200 β€ (1/2 : β)*(depth t : β)*Real.log (depth t : β) := by | |
| have tp : 0 < t := by linarith | |
| have lp : 0 < Real.log t := by linarith | |
| have rp : 0 < radius t := by linarith | |
| have kp : 0 < (depth t : β) := lt_of_lt_of_le (by positivity) (depth_lower hr) | |
| have hr2 : radius t^2 = t/Real.log t := Real.sq_sqrt (div_nonneg tp.le lp.le) | |
| have hr2' : radius t^2*Real.log t = t := (eq_div_iff lp.ne').mp hr2 | |
| have hrle : radius t β€ t := by | |
| have hdiv : t/Real.log t β€ t := (div_le_iffβ lp).mpr (by nlinarith) | |
| nlinarith [radius_nonneg t] | |
| have hkle : (depth t : β) β€ t := by | |
| have hh := depth_upper t | |
| nlinarith [radius_nonneg t] | |
| have logupper : Real.log (depth t : β) β€ Real.log t := Real.log_le_log kp hkle | |
| have loglower : Real.log t/3 β€ Real.log (depth t : β) := by | |
| have hlog := Real.log_le_log (by positivity : 0 < radius t/200) (depth_lower hr) | |
| have logR : Real.log (radius t) = (Real.log t - Real.log (Real.log t))/2 := by | |
| dsimp [radius] | |
| rw [Real.log_sqrt (div_nonneg tp.le lp.le),Real.log_div tp.ne' lp.ne'] | |
| rw [Real.log_div rp.ne' (by norm_num),logR] at hlog | |
| linarith | |
| have hsq : (depth t : β)^2 β€ radius t^2/10000 := by | |
| have hh := depth_upper t | |
| nlinarith [sq_nonneg (radius t/100-(depth t : β))] | |
| have hsqrt : Real.sqrt (t*Real.log t) = 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'] | |
| constructor | |
| Β· calc | |
| _ β€ 1000*(depth t : β)^2*Real.log t := mul_le_mul_of_nonneg_left logupper (by positivity) | |
| _ β€ t := by | |
| have hh := mul_le_mul_of_nonneg_right hsq lp.le | |
| nlinarith | |
| Β· rw [hsqrt] | |
| have hh : radius t/200*(Real.log t/3) β€ (depth t : β)*Real.log (depth t : β) := by | |
| gcongr | |
| Β· exact depth_lower hr | |
| linarith | |
| theorem eventually_choose_depth (K : β) : βαΆ t : β in atTop, | |
| K β€ depth t β§ 1000*(depth t : β)^2*Real.log (depth t : β) β€ t β§ | |
| Real.sqrt (t*Real.log t)/1200 β€ (1/2 : β)*(depth t : β)*Real.log (depth t : β) := by | |
| have hsmall := Real.isLittleO_log_id_atTop.def (by norm_num : (0 : β)<1/6) | |
| have hsmall' := Real.tendsto_log_atTop.eventually hsmall | |
| have hl := Real.tendsto_log_atTop.eventually (eventually_ge_atTop (1 : β)) | |
| have hh := Real.tendsto_log_atTop.eventually (eventually_ge_atTop (12*Real.log (200 : β))) | |
| filter_upwards [eventually_radius_large K,hsmall',hl,hh,eventually_ge_atTop (1 : β)] with t hr hs hl hh ht | |
| have hK : (K : β) β€ radius t/100 := by nlinarith | |
| have hr' : 200 β€ radius t := by have := Nat.cast_nonneg (Ξ± := β) K; nlinarith | |
| have hll : Real.log (Real.log t) β€ Real.log t/6 := by | |
| have hlog := Real.log_nonneg hl | |
| have hpos : 0 β€ Real.log t := by linarith | |
| simpa only [Function.id_def,Real.norm_eq_abs,abs_of_nonneg hlog,abs_of_nonneg hpos, | |
| div_eq_mul_inv,one_mul,mul_comm] using hs | |
| exact β¨Nat.le_floor hK,depth_bounds ht hl hr' hll hhβ© | |
| end EditDepth | |
| end OAI | |