Download data/lean/OAI/Combinatorics/BinaryEdit/FiniteSeparation.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 8.64 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/BinaryEdit/FiniteSeparation.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/BinaryEdit/FiniteSeparation.lean
-
curl -L -o FiniteSeparation.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/BinaryEdit/FiniteSeparation.lean
8.64 kB
| import OAI.Combinatorics.BinaryEdit.FiniteTreeInstantiation | |
| import OAI.Combinatorics.BinaryEdit.FiniteWordPrimeSeparation | |
| import OAI.Combinatorics.BinaryEdit.FiniteTreeTags | |
| import OAI.Combinatorics.BinaryEdit.FiniteSeparationArithmetic | |
| import OAI.Combinatorics.BinaryEdit.TaggedArrays | |
| namespace OAI | |
| /-! | |
| # Geometric separation for the concrete finite tree | |
| The prime construction supplies the half-child condition in the | |
| geometric induction. | |
| -/ | |
| noncomputable section | |
| namespace TreeEdit.BinaryLower.FiniteTree | |
| open scoped BigOperators | |
| /-- Literal row/block array of a concrete node word. -/ | |
| def finiteBlocks {m k : β} (primes : Fin k β Fin m β β) (iβ : Fin m) | |
| (T h : β) (p : List (Fin m)) (x : State (wordPeriods primes)) : | |
| Fin T β Fin m β Word (Symbol (wordPeriods primes)) ((m * T) ^ h) := | |
| fun a i => β¨finiteWord primes iβ T h (p ++ [i]) (x + a.val β’ wordU primes iβ p), | |
| finiteWord_length primes iβ T h _ _β© | |
| theorem finiteWord_succ_eq_rows {m k : β} (primes : Fin k β Fin m β β) | |
| (iβ : Fin m) (T h : β) (p : List (Fin m)) (x : State (wordPeriods primes)) : | |
| finiteWord primes iβ T (h + 1) p x = | |
| TaggedExtraction.rows (finiteBlocks primes iβ T h p x) := by | |
| have hrange : (List.finRange T).map Fin.val = List.range T := by | |
| apply List.ext_getElem | |
| Β· simp | |
| Β· intro j hj hj' | |
| simp | |
| unfold finiteWord nodeWord | |
| rw [β hrange, List.flatMap_map] | |
| rfl | |
| /-- The relative coefficient comparing two rows in a child. -/ | |
| def finiteRowShift {m k T : β} (primes : Fin k β Fin m β β) | |
| (p : List (Fin m)) (hp : p.length < k) (a b : Fin T) (t : β€) : β€ := | |
| (b.val : β€) - (a.val : β€) + t * | |
| (FiniteVectors.levelProduct primes β¨p.length, hpβ© : β€) | |
| /-- Children whose prescribed period does not divide the relative coefficient. -/ | |
| def separatedChildren {m k T : β} (primes : Fin k β Fin m β β) | |
| (iβ : Fin m) (p : List (Fin m)) (hp : p.length < k) (a b : Fin T) (t : β€) : | |
| Finset (Fin m) := | |
| Finset.univ.filter fun i => Β¬ (wordPeriod primes iβ (p ++ [i]) : β€) β£ | |
| finiteRowShift primes p hp a b t | |
| /-- Ordered-tag alignment and half-child nondivisibility imply separation | |
| for arbitrary common-subsequence matchings. -/ | |
| theorem finiteWord_separation_of_half_children {m k T : β} | |
| (primes : Fin k β Fin m β β) (iβ : Fin m) (hm : 2 β€ m) (hT : 0 < T) | |
| (hhalf : β p (hp : p.length < k) (a b : Fin T) (t : β€), | |
| Β¬ (wordPeriod primes iβ p : β€) β£ t β | |
| m β€ 2 * (separatedChildren primes iβ p hp a b t).card) | |
| (h : β) (p : List (Fin m)) (hlen : p.length + h = k) | |
| (x : State (wordPeriods primes)) (t : β€) | |
| (ht : Β¬ (wordPeriod primes iβ p : β€) β£ t) : | |
| (((m * T) ^ h : β) : β) / (4 : β) ^ h β€ | |
| (deficit ((m * T) ^ h) (finiteWord primes iβ T h p x) | |
| (finiteWord primes iβ T h p (x + t β’ wordW primes iβ p)) : β) := by | |
| classical | |
| induction h generalizing p x t with | |
| | zero => | |
| have hp : p.length = k := by simpa using hlen | |
| simpa using (finiteWord_leaf_deficit primes iβ T p hp x t ht).symm.le | |
| | succ h ih => | |
| have hp : p.length < k := by omega | |
| let B : β := (m * T) ^ h | |
| let q : β := (B : β) / (4 : β) ^ h | |
| let d : β := (m : β) * q / 2 | |
| let X := finiteBlocks primes iβ T h p x | |
| let Y := finiteBlocks primes iβ T h p (x + t β’ wordW primes iβ p) | |
| have hB : 0 < B := by dsimp [B]; exact pow_pos (Nat.mul_pos (by omega) hT) _ | |
| have hq : 0 β€ q := by dsimp [q]; positivity | |
| have hd : 0 β€ d := by dsimp [d]; positivity | |
| have hlocal (a b : Fin T) : d β€ β i, (deficit B (X a i).val (Y b i).val : β) := by | |
| apply row_deficit_charge (separatedChildren primes iβ p hp a b t) _ q hq | |
| (fun i => Nat.cast_nonneg _) _ (hhalf p hp a b t ht) | |
| intro i hi | |
| have hnot : Β¬ (wordPeriod primes iβ (p ++ [i]) : β€) β£ | |
| finiteRowShift primes p hp a b t := (Finset.mem_filter.mp hi).2 | |
| change q β€ (deficit B | |
| (finiteWord primes iβ T h (p ++ [i]) (x + a.val β’ wordU primes iβ p)) | |
| (finiteWord primes iβ T h (p ++ [i]) | |
| (x + t β’ wordW primes iβ p + b.val β’ wordU primes iβ p)) : β) | |
| rw [finiteWord_child_relative primes iβ i T h p hlen x t a.val b.val] | |
| exact ih (p ++ [i]) (by simp; omega) _ _ hnot | |
| have hX : β (a : Fin T) (i : Fin m) (s : Symbol (wordPeriods primes)), | |
| s β (X a i).val β s β subtreeAlphabet (wordPeriods primes) (p ++ [i]) := by | |
| intro a i s hs | |
| exact mem_subtreeAlphabet_of_mem (wordPeriods primes) | |
| β¨List.replicate k iβ, by simpβ© (wordU primes iβ) h (p ++ [i]) | |
| (by simp; omega) _ s hs | |
| have hY : β (a : Fin T) (i : Fin m) (s : Symbol (wordPeriods primes)), | |
| s β (Y a i).val β s β subtreeAlphabet (wordPeriods primes) (p ++ [i]) := by | |
| intro a i s hs | |
| exact mem_subtreeAlphabet_of_mem (wordPeriods primes) | |
| β¨List.replicate k iβ, by simpβ© (wordU primes iβ) h (p ++ [i]) | |
| (by simp; omega) _ s hs | |
| have hdg : d β€ (((m - 1) * B : β) : β) := by | |
| have hh := finite_charge_le_gap m h hm (B : β) (Nat.cast_nonneg _) | |
| simpa [d, q, Nat.cast_mul, Nat.cast_sub (show 1 β€ m by omega)] using hh | |
| have hsep := (Tagged.rows_with_ordered_tags hT hm hB | |
| (fun i => subtreeAlphabet (wordPeriods primes) (p ++ [i])) | |
| (subtreeAlphabet_children_pairwise_disjoint (wordPeriods primes) p) | |
| X Y hX hY d hd hlocal).2.2 hdg | |
| have hN : T * m * B = (m * T) ^ (h + 1) := by dsimp [B]; rw [pow_succ]; ring | |
| have hcharge : (T : β) * d / 2 = (((m * T) ^ (h + 1) : β) : β) / (4 : β) ^ (h + 1) := by | |
| dsimp [d, q, B] | |
| push_cast | |
| rw [pow_succ, pow_succ] | |
| ring | |
| rw [hcharge, hN] at hsep | |
| simpa only [X, Y, β finiteWord_succ_eq_rows] using hsep | |
| /-- Uniform separation of the root half-period shift. -/ | |
| theorem finiteWord_root_deficit_of_half_children {m k T : β} | |
| (primes : Fin k β Fin m β β) (iβ : Fin m) (hm : 2 β€ m) (hT : 0 < T) | |
| (hhalf : β p (hp : p.length < k) (a b : Fin T) (t : β€), | |
| Β¬ (wordPeriod primes iβ p : β€) β£ t β | |
| m β€ 2 * (separatedChildren primes iβ p hp a b t).card) | |
| (x : State (wordPeriods primes)) : | |
| (((m * T) ^ k : β) : β) / (4 : β) ^ k β€ | |
| (deficit ((m * T) ^ k) (finiteWord primes iβ T k [] x) | |
| (finiteWord primes iβ T k [] (x + wordW primes iβ [])) : β) := by | |
| have h := finiteWord_separation_of_half_children primes iβ hm hT hhalf | |
| k [] (by simp) x 1 (by simp) | |
| simpa using h | |
| /-- Source finite-tree separation for the actual prime periods and words. -/ | |
| theorem finiteWord_separation {k : β} (hk : 2 β€ k) | |
| (primes : Fin k β Fin (20 * k) β β) (iβ : Fin (20 * k)) | |
| (hinj : Function.Injective | |
| (fun z : Fin k Γ Fin (20 * k) => primes z.1 z.2)) | |
| (hprime : β q i, Nat.Prime (primes q i)) | |
| (hlarge : β q i, k ^ 4 β€ primes q i) | |
| (h : β) (p : List (Fin (20 * k))) (hlen : p.length + h = k) | |
| (x : State (wordPeriods primes)) (t : β€) | |
| (ht : Β¬ (wordPeriod primes iβ p : β€) β£ t) : | |
| (((20 * k * k ^ (20 * k)) ^ h : β) : β) / (4 : β) ^ h β€ | |
| (deficit ((20 * k * k ^ (20 * k)) ^ h) | |
| (finiteWord primes iβ (k ^ (20 * k)) h p x) | |
| (finiteWord primes iβ (k ^ (20 * k)) h p | |
| (x + t β’ wordW primes iβ p)) : β) := by | |
| apply finiteWord_separation_of_half_children primes iβ (by omega) | |
| (pow_pos (by omega) _) _ h p hlen x t ht | |
| intro p hp a b t ht | |
| exact finiteWord_half_children hk primes iβ p hp hinj hprime hlarge a b t ht | |
| /-- Distinct large primes give the uniform root deficit for the | |
| prescribed half-period shift. -/ | |
| theorem finiteWord_root_deficit {k : β} (hk : 2 β€ k) | |
| (primes : Fin k β Fin (20 * k) β β) (iβ : Fin (20 * k)) | |
| (hinj : Function.Injective | |
| (fun z : Fin k Γ Fin (20 * k) => primes z.1 z.2)) | |
| (hprime : β q i, Nat.Prime (primes q i)) | |
| (hlarge : β q i, k ^ 4 β€ primes q i) | |
| (x : State (wordPeriods primes)) : | |
| (((20 * k * k ^ (20 * k)) ^ k : β) : β) / (4 : β) ^ k β€ | |
| (deficit ((20 * k * k ^ (20 * k)) ^ k) | |
| (finiteWord primes iβ (k ^ (20 * k)) k [] x) | |
| (finiteWord primes iβ (k ^ (20 * k)) k [] | |
| (x + wordW primes iβ [])) : β) := by | |
| have h := finiteWord_separation hk primes iβ hinj hprime hlarge k [] | |
| (by simp) x 1 (by simp) | |
| simpa using h | |
| end TreeEdit.BinaryLower.FiniteTree | |
| end | |
| end OAI | |