math / data /lean /OAI /Combinatorics /BinaryEdit /FiniteWordDetection.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
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