math / data /lean /OAI /Combinatorics /BinaryEdit /FiniteSourceFamily.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
4.16 kB
import OAI.Combinatorics.BinaryEdit.FiniteSeparation
import OAI.Combinatorics.BinaryEdit.FiniteWordL1Mean
import OAI.Combinatorics.BinaryEdit.ParameterImage
import OAI.Combinatorics.BinaryEdit.FiniteAlphabet
import OAI.Combinatorics.BinaryEdit.FiniteFamilyTransfer
import OAI.Combinatorics.BinaryEdit.PrimeSupply
import OAI.Combinatorics.BinaryEdit.EditDeficit
namespace OAI
noncomputable section
namespace TreeEdit.BinaryLower
open FiniteTree
open scoped BigOperators
/-- A finite-alphabet family with distortion constant `1/34`, constructed
from finite coordinate groups and their word images. -/
theorem exists_finite_source_family :
βˆƒ cβ‚€ : ℝ, 0 < cβ‚€ ∧ βˆƒ K : β„•, βˆ€ k : β„•, K ≀ k β†’
βˆƒ Ξ“ : Type, βˆƒ inst : Fintype Ξ“,
1 ≀ @Fintype.card Ξ“ inst ∧ @Fintype.card Ξ“ inst ≀ finiteSourceLength k ∧
βˆƒ W : Finset (Word Ξ“ (finiteSourceLength k)), 2 ≀ W.card ∧
cβ‚€ * ((k : ℝ) / 4) ^ k ≀
c1 {x : Word Ξ“ (finiteSourceLength k) // x ∈ W}
(fun x y => (ed x.val.val y.val.val : ℝ)) := by
classical
obtain ⟨K, hK⟩ := PrimeSupply.finite_tree_odd_prime_family
refine ⟨1 / 34, by norm_num, K, ?_⟩
intro k hk
obtain ⟨hk2, primes, hprimes⟩ := hK k hk
let p : Fin k β†’ Fin (20 * k) β†’ β„• := fun q i => primes (q, i)
have hpprime : βˆ€ q i, Nat.Prime (p q i) := fun q i => (hprimes (q, i)).1
have hppos : βˆ€ q i, 0 < p q i := fun q i => (hpprime q i).pos
have hplarge : βˆ€ q i, k ^ 4 ≀ p q i := fun q i => (hprimes (q, i)).2.2.1
have hpupper : βˆ€ q i, p q i ≀ k ^ 5 := fun q i => (hprimes (q, i)).2.2.2
have hpinj : Function.Injective (fun z : Fin k Γ— Fin (20 * k) => p z.1 z.2) :=
primes.injective
let iβ‚€ : Fin (20 * k) := ⟨0, by omega⟩
let Ξ“ := Symbol (wordPeriods p)
let A := State (wordPeriods p)
let : Finite Ξ“ := finite_wordSymbol p hppos
let : Fintype Ξ“ := Fintype.ofFinite Ξ“
let : Finite A := finite_wordState p hppos
let : Fintype A := Fintype.ofFinite A
have hΞ“ := FiniteAlphabet.prime_product_alphabet_bounds hk2 p hppos hpupper
change Finite Ξ“ ∧ 1 ≀ Nat.card Ξ“ ∧ Nat.card Ξ“ ≀ finiteSourceLength k at hΞ“
have hΞ“1 : 1 ≀ Fintype.card Ξ“ := by simpa only [Nat.card_eq_fintype_card] using hΞ“.2.1
have hΞ“M : Fintype.card Ξ“ ≀ finiteSourceLength k := by
simpa only [Nat.card_eq_fintype_card] using hΞ“.2.2
let G : A β†’ Word Ξ“ (finiteSourceLength k) := rootWord p iβ‚€ (k ^ (20 * k))
let z : A := wordW p iβ‚€ []
have hMnat : 0 < finiteSourceLength k := by
unfold finiteSourceLength
positivity
have hM : (0 : ℝ) < finiteSourceLength k := by exact_mod_cast hMnat
have hkpos : (0 : ℝ) < k := by exact_mod_cast (show 0 < k by omega)
have hsep : βˆ€ x : A, (finiteSourceLength k : ℝ) / (4 : ℝ) ^ k ≀
(ed (G x).val (G (x + z)).val : ℝ) := by
intro x
have hd := finiteWord_root_deficit hk2 p iβ‚€ hpinj hpprime hplarge x
have he := deficit_le_editDistance
(finiteWord_length p iβ‚€ (k ^ (20 * k)) k [] x)
(finiteWord_length p iβ‚€ (k ^ (20 * k)) k [] (x + z))
exact hd.trans (Nat.cast_le.mpr he)
have hmean : βˆ€ F : A β†’ RealL1,
(βˆ€ x y, β€–F x - F yβ€– ≀ (ed (G x).val (G y).val : ℝ)) β†’
(βˆ‘ x : A, β€–F (x + z) - F xβ€–) / Fintype.card A ≀
34 * (finiteSourceLength k : ℝ) / (k : ℝ) ^ k := by
intro F hF
have h := finiteWord_root_mean_bound34 p iβ‚€ hk2 hppos hpupper F hF
simpa only [Fintype.expect_eq_sum_div_card, finiteSourceLength, Nat.cast_pow] using h
obtain ⟨W, _, hW, hdist⟩ := ParameterImage.exists_word_image_lower_of_root_bound
G z ((finiteSourceLength k : ℝ) / (4 : ℝ) ^ k)
(34 * (finiteSourceLength k : ℝ) / (k : ℝ) ^ k)
(by positivity) (by positivity) hsep hmean
refine βŸ¨Ξ“, inferInstance, hΞ“1, hΞ“M, W, hW, ?_⟩
have hratio : (finiteSourceLength k : ℝ) / (4 : ℝ) ^ k /
(34 * (finiteSourceLength k : ℝ) / (k : ℝ) ^ k) =
(1 / 34 : ℝ) * ((k : ℝ) / 4) ^ k := by
rw [div_pow]
field_simp
rw [hratio] at hdist
exact hdist
end TreeEdit.BinaryLower
end
end OAI