math / data /lean /OAI /Combinatorics /BinaryEdit /FiniteVectorDetection.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
4.44 kB
import OAI.Combinatorics.BinaryEdit.FiniteVectors
import OAI.Combinatorics.BinaryEdit.SparseCharacterPeriod
import OAI.Combinatorics.BinaryEdit.FiniteActivityBridge
namespace OAI
/-!
# Actual sparse-node character tests
Short-period detection holds for the finite-tree vectors in both the
function-indexed and list-indexed presentations.
-/
noncomputable section
open scoped BigOperators
open Classical
namespace TreeEdit.BinaryLower.FiniteVectors
/-- The actual finite-tree cheap vector detects any active distinguished
vector whose children have support smaller than `k`. Exact orders and
primality are unnecessary here: the proved annihilating periods suffice. -/
theorem sparse_node_detection {m k : β„•}
(p : Fin k β†’ Fin m β†’ β„•) (hk : 1 ≀ k)
(hppos : βˆ€ q i, 0 < p q i) (hp : βˆ€ q i, p q i ≀ k ^ 5)
(j : β„•) (hj : j < k) (a : Leaf m k) (Ο‡ : AddChar (State p) β„‚)
(hactive : Ο‡ (w p j a) β‰  1)
(hsparse : (Finset.univ.filter fun i : Fin m =>
Ο‡ (w p (j + 1) (Function.update a ⟨j, hj⟩ i)) β‰  1).card < k) :
((4 * k ^ (10 * k) : β„•) : ℝ) ≀
βˆ‘ s : Fin (4 * k ^ (10 * k)), β€–1 - Ο‡ ((s.val + 1) β€’ u p j a)β€– ^ 2 := by
let : Finite (State p) := state_finite p hppos
let child : Fin m β†’ State p := fun i => w p (j + 1) (Function.update a ⟨j, hj⟩ i)
let S : Finset (Fin m) := Finset.univ.filter fun i => Ο‡ (child i) β‰  1
have hsum : u p j a = βˆ‘ i, child i := u_eq_sum_child_w p j hj a
have hroot : Ο‡ (levelProduct p ⟨j, hj⟩ β€’ βˆ‘ i, child i) β‰  1 := by
rw [← hsum, ← w_eq_level_nsmul_u p j hj a]
exact hactive
have hchild : βˆ€ i ∈ S, (prefixPeriod p j a * p ⟨j, hj⟩ i) β€’ child i = 0 := by
intro i _
dsimp [child]
rw [← prefixPeriod_child p j hj a i]
exact prefixPeriod_nsmul_w p (j + 1) (Function.update a ⟨j, hj⟩ i)
have houtside : βˆ€ i, i βˆ‰ S β†’ Ο‡ (child i) = 1 := by
intro i hi
simpa only [S, Finset.mem_filter, Finset.mem_univ, true_and, not_not] using hi
have havg := FinitePeriod.sparse_character_detection Ο‡ S child (p ⟨j, hj⟩)
hk hj hsparse (prefixPeriod_pos p hppos j a) (prefixPeriod_le p hp j hj.le a)
(fun i _ => hppos _ i) (fun i _ => hp _ i) houtside hchild hroot
have hJ : (0 : ℝ) < ((4 * k ^ (10 * k) : β„•) : ℝ) := by positivity
have hraw := (le_div_iffβ‚€ hJ).mp havg
rw [Fin.sum_univ_eq_sum_range (fun s : β„• => β€–1 - Ο‡ ((s + 1) β€’ u p j a)β€– ^ 2)]
simpa only [one_mul, ← hsum] using hraw
end TreeEdit.BinaryLower.FiniteVectors
namespace TreeEdit.BinaryLower.FiniteActivity
/-- The exact unnormalized finite-sample detector required by
`finite_tree_spectral_bound`, with the sparse predicate and child list
indices unchanged. All hypotheses are local vector/period identities. -/
theorem characterSparse_detection {Ξ± A : Type*}
[Fintype Ξ±] [AddCommGroup A] [Finite A] {k : β„•}
(w : List Ξ± β†’ A) (v : InternalNode Ξ± k) (u : A)
(Q R : β„•) (p : Ξ± β†’ β„•) (hk : 1 ≀ k)
(hQpos : 0 < Q) (hQ : Q ≀ 2 * k ^ (5 * v.1.val))
(hppos : βˆ€ i, 0 < p i) (hp : βˆ€ i, p i ≀ k ^ 5)
(hroot : w (List.ofFn v.2) = R β€’ u)
(hsum : u = βˆ‘ i, w (List.ofFn v.2 ++ [i]))
(hchild : βˆ€ i, (Q * p i) β€’ w (List.ofFn v.2 ++ [i]) = 0)
(Ο‡ : AddChar A β„‚) (hsparse : characterSparse w k v Ο‡) :
((4 * k ^ (10 * k) : β„•) : ℝ) ≀
βˆ‘ s : Fin (4 * k ^ (10 * k)), β€–1 - Ο‡ ((s.val + 1) β€’ u)β€– ^ 2 := by
let S : Finset Ξ± := Finset.univ.filter fun i => Ο‡ (w (List.ofFn v.2 ++ [i])) β‰  1
have hcard : S.card < k := by
simpa only [S, Branching.activeChildCount] using hsparse.2
have hactive : Ο‡ (R β€’ βˆ‘ i, w (List.ofFn v.2 ++ [i])) β‰  1 := by
rw [← hsum, ← hroot]
exact hsparse.1
have houtside : βˆ€ i, i βˆ‰ S β†’ Ο‡ (w (List.ofFn v.2 ++ [i])) = 1 := by
intro i hi
simpa only [S, Finset.mem_filter, Finset.mem_univ, true_and, not_not] using hi
have havg := FinitePeriod.sparse_character_detection Ο‡ S
(fun i => w (List.ofFn v.2 ++ [i])) p hk v.1.isLt hcard hQpos hQ
(fun i _ => hppos i) (fun i _ => hp i) houtside (fun i _ => hchild i) hactive
have hJ : (0 : ℝ) < ((4 * k ^ (10 * k) : β„•) : ℝ) := by positivity
have hraw := (le_div_iffβ‚€ hJ).mp havg
rw [Fin.sum_univ_eq_sum_range (fun s : β„• => β€–1 - Ο‡ ((s + 1) β€’ u)β€– ^ 2)]
simpa only [one_mul, ← hsum] using hraw
end TreeEdit.BinaryLower.FiniteActivity
end
end OAI