Construction 8.1 of Kempa–Kociumaka: synchronizing sets from an identifier of length- fragments
DefinitionDynLZ77_KK_SyncConstructionLet be a string and , and let
be the positions whose length- fragment has a period of at most . For an identifier that assigns a natural number to every string, Construction 8.1 of Kempa and Kociumaka is
where when (the minimum is over the empty set).
By Lemma 8.2 of the source, is a -synchronizing set of for every identifier, and by Fact 8.9 a suitable identifier makes it of size .
Formalization Note. InQ T τ j is , with the comparison taken over the reals. syncSet T τ id is , with the minimum written as "the fragment at (resp. ) is outside and its identifier is at most that of every fragment starting in ". The identifier is any function on strings applied to the fragments, so equal fragments get equal identifiers, as for the class identifiers of the paper. Strings, 1-based positions, sub and per are those of DynLZ77_Main_Strings and DynLZ77_Main_Structure.
import Mathlib.Data.Real.Basic
import Mathlib.Order.Interval.Finset.Nat
import Definitions.Def_DynLZ77_Main_Strings
import Definitions.Def_DynLZ77_Main_Structure
set_option autoImplicit false
/-!
# The Kempa–Kociumaka construction of synchronizing sets
D. Kempa, T. Kociumaka, *String Synchronizing Sets: Sublinear-Time BWT Construction and Optimal
LCE Data Structure*, STOC 2019, arXiv:1904.04228 (v2), Section 8, Construction 8.1.
**Formalization Note.** Strings, 1-based positions, `sub T i j = T[i..j]` and `per` (smallest
period) are those of `Def_DynLZ77_Main_Strings` / `Def_DynLZ77_Main_Structure`.
* `InQ T τ j`: `j ∈ Q`, i.e. `per(T[j..j+τ)) ≤ τ/3` (over the reals).
* `syncSet T τ id`: Construction 8.1 for an identifier `id` of length-`τ` fragments:
`i ∈ [1..n − 2τ + 1]` is in the set iff the minimum of `id` over the fragments starting in
`[i..i+τ] ∖ Q` is attained by the fragment at `i` or at `i + τ`. When `[i..i+τ] ⊆ Q` the
minimum is over the empty set and `i` is not in the set (the convention of the proof of
Lemma 8.2). In the paper `id` is a class identifier (`id(i) = id(j)` iff
`T[i..i+τ) = T[j..j+τ)`); here `id` is any function on strings, applied to the fragments, so
equal fragments automatically get equal identifiers.
-/
namespace DynLZ77.KK
open DynLZ77.Main
variable {α : Type}
/-- `j ∈ Q`: the length-`τ` fragment `T[j..j+τ)` has period at most `τ/3`. -/
def InQ (T : List α) (τ j : ℕ) : Prop :=
((per (sub T j (j + τ - 1)) : ℝ) ≤ (τ : ℝ) / 3)
open Classical in
/-- Construction 8.1 of [KK19] with identifier `id`: `i ∈ [1..n − 2τ + 1]` such that the minimum
identifier over the fragments starting in `[i..i+τ] ∖ Q` is that of `T[i..i+τ)` or of
`T[i+τ..i+2τ)`. -/
noncomputable def syncSet (T : List α) (τ : ℕ) (id : List α → ℕ) : Finset ℕ :=
(Finset.Icc 1 (T.length + 1 - 2 * τ)).filter fun i =>
(¬ InQ T τ i ∧ ∀ j ∈ Finset.Icc i (i + τ), ¬ InQ T τ j →
id (sub T i (i + τ - 1)) ≤ id (sub T j (j + τ - 1))) ∨
(¬ InQ T τ (i + τ) ∧ ∀ j ∈ Finset.Icc i (i + τ), ¬ InQ T τ j →
id (sub T (i + τ) (i + 2 * τ - 1)) ≤ id (sub T j (j + τ - 1)))
end DynLZ77.KK