Download data/lean/OAI/Combinatorics/EditDistance/UpperRecursion.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 5.3 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/EditDistance/UpperRecursion.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/EditDistance/UpperRecursion.lean
-
curl -L -o UpperRecursion.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/EditDistance/UpperRecursion.lean
5.3 kB
| import OAI.Combinatorics.EditDistance.UpperBase | |
| namespace OAI | |
| /-! | |
| # Uniform finite-cut embeddings at recursive capacities | |
| -/ | |
| namespace EditUpperParameters | |
| open scoped BigOperators | |
| lemma log_two_bounds : (1/2 : β) β€ Real.log 2 β§ Real.log 2 β€ 1 := by | |
| constructor | |
| Β· have hh := Real.one_sub_inv_le_log_of_pos (by norm_num : (0 : β) < 2) | |
| norm_num at hh β’ | |
| exact hh | |
| Β· have hh := Real.log_le_sub_one_of_pos (by norm_num : (0 : β) < 2) | |
| norm_num at hh β’ | |
| exact hh | |
| lemma scale_count_bound {l : β} (hl : 0 < l) : | |
| ((Nat.log 2 l+1 : β) : β) β€ 2*(1+Real.log (l : β)) := by | |
| have hpow := Nat.pow_log_le_self 2 (Nat.ne_of_gt hl) | |
| have hpr : (2 : β)^(Nat.log 2 l) β€ l := by exact_mod_cast hpow | |
| have hh := Real.log_le_log (pow_pos (by norm_num : (0 : β)<2) _) hpr | |
| rw [Real.log_pow] at hh | |
| have hlog : 0 β€ Real.log (l : β) := Real.log_nonneg (by exact_mod_cast hl) | |
| have hm : 0 β€ (Nat.log 2 l : β) := Nat.cast_nonneg _ | |
| have h2 := log_two_bounds | |
| push_cast | |
| nlinarith | |
| lemma log_square_bound {l : β} (hl : 0 < l) : | |
| Real.log (2*(l : β)^2) β€ 2*(1+Real.log (l : β)) := by | |
| have hp : (0 : β)<l := by exact_mod_cast hl | |
| rw [Real.log_mul (by norm_num) (pow_ne_zero 2 hp.ne'),Real.log_pow] | |
| have h2 := log_two_bounds | |
| norm_num only [Nat.cast_ofNat] | |
| linarith | |
| lemma step_constant_bound {b l : β} (hl : 0 < l) {D : β} (hD : 0 β€ D) : | |
| 16*((Nat.log 2 l+1 : β) : β)*(2*(b : β)+4*Real.log (2*(l : β)^2)*D) β€ | |
| 512*(1+Real.log (l : β))^2*((b : β)+D) := by | |
| have hlog : 0 β€ Real.log (l : β) := Real.log_nonneg (by exact_mod_cast hl) | |
| have hcount := scale_count_bound hl | |
| have hsq := log_square_bound hl | |
| have hsnn : 0 β€ Real.log (2*(l : β)^2) := Real.log_nonneg (by | |
| have hh : (1 : β) β€ l := by exact_mod_cast hl | |
| nlinarith) | |
| have hb := Nat.cast_nonneg (Ξ± := β) b | |
| have hm := Nat.cast_nonneg (Ξ± := β) (Nat.log 2 l+1) | |
| have hleft : 2*(b : β)+4*Real.log (2*(l : β)^2)*D β€ 2*b+8*(1+Real.log (l : β))*D := by nlinarith | |
| calc | |
| _ β€ 16*(2*(1+Real.log (l : β)))*(2*b+8*(1+Real.log (l : β))*D) := by | |
| apply mul_le_mul | |
| Β· nlinarith | |
| Β· exact hleft | |
| Β· positivity | |
| Β· positivity | |
| _ β€ _ := by nlinarith [mul_nonneg hlog hb,mul_nonneg (sq_nonneg (1+Real.log (l : β))) hD, | |
| mul_nonneg (sq_nonneg (Real.log (l : β))) hb] | |
| end EditUpperParameters | |
| namespace EditUpper | |
| universe u | |
| attribute [local instance] Classical.propDecidable | |
| open scoped BigOperators | |
| open Finset EditDistortion EditWindow EditCutModel | |
| noncomputable def growth (b N : β) : β := 1024*(1+(N : β)*Real.log (b : β))^2 | |
| lemma growth_ge {b N : β} (hb : 1 β€ b) : 1 β€ growth b N := by | |
| have hlog : 0 β€ Real.log (b : β) := Real.log_nonneg (by exact_mod_cast hb) | |
| have hn := Nat.cast_nonneg (Ξ± := β) N | |
| dsimp [growth] | |
| nlinarith [mul_nonneg hn hlog] | |
| theorem exists_level (b N : β) (hb : 1 β€ b) (k : β) (hk : k β€ N) | |
| (A : Type u) [Fintype A] : | |
| β M : Model (List A), | |
| (β x y : List A, x.length β€ b^k β y.length β€ b^k β (indel x y : β) β€ M.dist x y) β§ | |
| (β x y : List A, M.dist x y β€ ((b : β)+2)*(growth b N)^k*(indel x y : β)) := by | |
| induction k generalizing A with | |
| | zero => | |
| refine β¨base,?_,?_β© | |
| Β· intro x y hx hy | |
| exact base_lower x y (by simpa using hx) (by simpa using hy) | |
| Β· intro x y | |
| have hh := base_upper x y | |
| have hi := Nat.cast_nonneg (Ξ± := β) (indel x y) | |
| simp only [pow_zero,mul_one] | |
| nlinarith [Nat.cast_nonneg (Ξ± := β) b] | |
| | succ k ih => | |
| obtain β¨M,hlo,hupβ© := ih (by omega) (Option A) | |
| let D := ((b : β)+2)*(growth b N)^k | |
| have hP := growth_ge (N := N) hb | |
| have hD : 0 β€ D := by dsimp [D]; positivity | |
| have hpow : 1 β€ (growth b N)^k := one_le_powβ hP | |
| have hbD : (b : β) β€ D := by | |
| dsimp [D] | |
| have hb0 := Nat.cast_nonneg (Ξ± := β) b | |
| nlinarith | |
| have hl : 0 < b^k := pow_pos (by omega) _ | |
| have hkN : (k : β) β€ N := by exact_mod_cast (show k β€ N by omega) | |
| have hlog : 0 β€ Real.log (b : β) := Real.log_nonneg (by exact_mod_cast hb) | |
| have hT : 1+Real.log ((b^k : β) : β) β€ 1+(N : β)*Real.log (b : β) := by | |
| rw [Nat.cast_pow,Real.log_pow] | |
| nlinarith | |
| have hTnn : 0 β€ 1+Real.log ((b^k : β) : β) := by | |
| have hh : 0 β€ Real.log ((b^k : β) : β) := Real.log_nonneg (by exact_mod_cast (Nat.one_le_pow k b (by omega))) | |
| linarith | |
| have hconst : 512*(1+Real.log ((b^k : β) : β))^2*((b : β)+D) β€ | |
| ((b : β)+2)*(growth b N)^(k+1) := by | |
| calc | |
| _ β€ 512*(1+(N : β)*Real.log (b : β))^2*(2*D) := by | |
| apply mul_le_mul | |
| Β· gcongr | |
| Β· linarith | |
| Β· positivity | |
| Β· positivity | |
| _ = _ := by dsimp [D,growth]; rw [pow_succ]; ring | |
| refine β¨lift M b (b^k),?_,?_β© | |
| Β· intro x y hx hy | |
| apply lift_lower M b (b^k) hl hlo x y | |
| Β· simpa only [pow_succ,Nat.mul_comm] using hx | |
| Β· simpa only [pow_succ,Nat.mul_comm] using hy | |
| Β· apply model_indel_lipschitz | |
| intro p q a | |
| exact (lift_insert_raw M hD hup p q a b (b^k) hl).trans | |
| ((EditUpperParameters.step_constant_bound hl hD).trans hconst) | |
| end EditUpper | |
| end OAI | |