Download data/lean/OAI/Combinatorics/BinaryEdit/FiniteWordDetection.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 6.55 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/BinaryEdit/FiniteWordDetection.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/BinaryEdit/FiniteWordDetection.lean
-
curl -L -o FiniteWordDetection.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/BinaryEdit/FiniteWordDetection.lean
6.55 kB
| import OAI.Combinatorics.BinaryEdit.FiniteTreeInstantiation | |
| import OAI.Combinatorics.BinaryEdit.FiniteVectorDetection | |
| import OAI.Combinatorics.BinaryEdit.WordFinite | |
| import OAI.Combinatorics.BinaryEdit.FiniteCoordinates | |
| namespace OAI | |
| /-! | |
| # Sparse detection for the concrete recursive word model | |
| The list-prefix vectors used by `finiteWord` satisfy the same exact recursion | |
| and period bounds as the function-prefix vectors. This closes the algebraic | |
| inputs of the finite spectral detector in the actual word-state presentation. | |
| -/ | |
| noncomputable section | |
| open scoped BigOperators | |
| open Classical | |
| namespace TreeEdit.BinaryLower.FiniteTree | |
| variable {m k : β} | |
| theorem wordState_finite (primes : Fin k β Fin m β β) | |
| (hp : β q i, 0 < primes q i) : Finite (State (wordPeriods primes)) := by | |
| let : β l : Leaf m k, NeZero (wordPeriods primes l) := fun l => | |
| β¨ne_of_gt (FiniteVectors.leafPeriod_pos primes hp (leafEquiv m k l))β© | |
| infer_instance | |
| /-- Relabeling the product factors is additive, not merely a map of sets. -/ | |
| def pullStateHom (Q : (Fin k β Fin m) β β) : | |
| (β l, ZMod (Q l)) β+ State (fun l => Q (leafEquiv m k l)) where | |
| toFun := pullState Q | |
| map_zero' := rfl | |
| map_add' _ _ := rfl | |
| /-- The actual word-state cyclic coordinate, indexed by the same function | |
| leaves as the spectral tree's finite leaf set. -/ | |
| def wordLeafCoordinate (primes : Fin k β Fin m β β) (f : Fin k β Fin m) : | |
| ZMod (FiniteVectors.leafPeriod primes f) β+ State (wordPeriods primes) := | |
| (pullStateHom (FiniteVectors.leafPeriod primes)).comp | |
| (FiniteVectors.leafCoordinate primes f) | |
| @[simp] theorem extendPrefix_ofFn (iβ : Fin m) (f : Fin k β Fin m) : | |
| extendPrefix iβ (List.ofFn f) = f := by | |
| funext q | |
| simp [extendPrefix, q.isLt] | |
| /-- This is precisely the generator identity of the spectral tree theorem. -/ | |
| @[simp] theorem wordLeafCoordinate_one (primes : Fin k β Fin m β β) | |
| (iβ : Fin m) (f : Fin k β Fin m) : | |
| wordLeafCoordinate primes f 1 = wordW primes iβ (List.ofFn f) := by | |
| change pullState (FiniteVectors.leafPeriod primes) | |
| (FiniteVectors.leafCoordinate primes f 1) = _ | |
| rw [FiniteVectors.leafCoordinate_one] | |
| simp only [wordW, List.length_ofFn, extendPrefix_ofFn] | |
| /-- Whole-coordinate averaging uses only integer multiples of the actual | |
| word leaf vector, as in the pointwise inexpensive-leaf-translation lemma. -/ | |
| theorem wordLeafCoordinate_eq_val_zsmul (primes : Fin k β Fin m β β) | |
| (iβ : Fin m) (f : Fin k β Fin m) | |
| [NeZero (FiniteVectors.leafPeriod primes f)] | |
| (z : ZMod (FiniteVectors.leafPeriod primes f)) : | |
| wordLeafCoordinate primes f z = (z.val : β€) β’ wordW primes iβ (List.ofFn f) := by | |
| have hz : (z.val : β€) β’ (1 : ZMod (FiniteVectors.leafPeriod primes f)) = z := by | |
| simp | |
| calc | |
| wordLeafCoordinate primes f z = wordLeafCoordinate primes f ((z.val : β€) β’ 1) := | |
| congrArg _ hz.symm | |
| _ = (z.val : β€) β’ wordLeafCoordinate primes f 1 := map_zsmul _ _ _ | |
| _ = (z.val : β€) β’ wordW primes iβ (List.ofFn f) := by rw [wordLeafCoordinate_one primes iβ] | |
| theorem wordPeriod_pos (primes : Fin k β Fin m β β) | |
| (hp : β q i, 0 < primes q i) (iβ : Fin m) (p : List (Fin m)) : | |
| 0 < wordPeriod primes iβ p := | |
| FiniteVectors.prefixPeriod_pos primes hp p.length (extendPrefix iβ p) | |
| theorem wordPeriod_le (primes : Fin k β Fin m β β) | |
| (hp : β q i, primes q i β€ k ^ 5) (iβ : Fin m) (p : List (Fin m)) | |
| (hlen : p.length β€ k) : wordPeriod primes iβ p β€ 2 * k ^ (5 * p.length) := | |
| FiniteVectors.prefixPeriod_le primes hp p.length hlen (extendPrefix iβ p) | |
| theorem wordPeriod_child (primes : Fin k β Fin m β β) | |
| (iβ i : Fin m) (p : List (Fin m)) (hp : p.length < k) : | |
| wordPeriod primes iβ (p ++ [i]) = | |
| wordPeriod primes iβ p * primes β¨p.length, hpβ© i := by | |
| simp only [wordPeriod, List.length_append, List.length_singleton, | |
| extendPrefix_append iβ i p hp] | |
| exact FiniteVectors.prefixPeriod_child primes p.length hp (extendPrefix iβ p) i | |
| /-- The distinguished word-state vector is the level product times the | |
| actual cheap word-state vector. -/ | |
| theorem wordW_eq_level_nsmul_wordU (primes : Fin k β Fin m β β) | |
| (iβ : Fin m) (p : List (Fin m)) (hp : p.length < k) : | |
| wordW primes iβ p = FiniteVectors.levelProduct primes β¨p.length, hpβ© β’ | |
| wordU primes iβ p := by | |
| unfold wordW wordU | |
| rw [FiniteVectors.w_eq_level_nsmul_u primes p.length hp (extendPrefix iβ p)] | |
| rfl | |
| /-- The cheap word-state vector is exactly the sum of the children's | |
| distinguished vectors, with the same list indices used for branching. -/ | |
| theorem wordU_eq_sum_child_wordW (primes : Fin k β Fin m β β) | |
| (iβ : Fin m) (p : List (Fin m)) (hp : p.length < k) : | |
| wordU primes iβ p = β i : Fin m, wordW primes iβ (p ++ [i]) := by | |
| unfold wordU wordW wordPeriods | |
| simp only [List.length_append, List.length_singleton, extendPrefix_append iβ _ p hp] | |
| rw [FiniteVectors.u_eq_sum_child_w primes p.length hp (extendPrefix iβ p)] | |
| funext l | |
| simp only [pullState, Finset.sum_apply] | |
| /-- A sparse active node is detected by short averages of cheap shifts | |
| in the canonical word-state group. -/ | |
| theorem word_sparse_detection (primes : Fin k β Fin m β β) (iβ : Fin m) | |
| (hk : 1 β€ k) (hppos : β q i, 0 < primes q i) | |
| (hp : β q i, primes q i β€ k ^ 5) | |
| (v : FiniteActivity.InternalNode (Fin m) k) | |
| (Ο : AddChar (State (wordPeriods primes)) β) | |
| (hsparse : FiniteActivity.characterSparse (wordW primes iβ) k v Ο) : | |
| ((4 * k ^ (10 * k) : β) : β) β€ | |
| β s : Fin (4 * k ^ (10 * k)), | |
| β1 - Ο ((s.val + 1) β’ wordU primes iβ (List.ofFn v.2))β ^ 2 := by | |
| let : Finite (State (wordPeriods primes)) := wordState_finite primes hppos | |
| let p := List.ofFn v.2 | |
| have hlen : p.length < k := by simp [p] | |
| apply FiniteActivity.characterSparse_detection (wordW primes iβ) v | |
| (wordU primes iβ p) (wordPeriod primes iβ p) | |
| (FiniteVectors.levelProduct primes β¨p.length, hlenβ©) | |
| (primes β¨p.length, hlenβ©) hk | |
| Β· exact wordPeriod_pos primes hppos iβ p | |
| Β· simpa [p] using wordPeriod_le primes hp iβ p hlen.le | |
| Β· exact hppos _ | |
| Β· exact hp _ | |
| Β· exact wordW_eq_level_nsmul_wordU primes iβ p hlen | |
| Β· exact wordU_eq_sum_child_wordW primes iβ p hlen | |
| Β· intro i | |
| rw [β wordPeriod_child primes iβ i p hlen] | |
| exact wordPeriod_nsmul_wordW primes iβ (p ++ [i]) | |
| Β· exact hsparse | |
| end TreeEdit.BinaryLower.FiniteTree | |
| end | |
| end OAI | |