The distinct-parsing bound #
A distinct parsing of a word x is a list of phrases ws with ws.flatten = x and
ws.Nodup. Because there are at most k ^ i words of length i over an alphabet of size k,
a word of length n cannot be cut into many distinct phrases: the number of phrases c is
O(n / log n). This is the combinatorial core of the analysis of Lempel–Ziv incremental parsing
(LZ78) in [ZL78] and [CT06], Ch. 13.
The basic finite inequality is m * c ≤ n + 2 * k ^ m for every m (mul_length_le_of_nodup):
each phrase of length less than m has a deficit m - |w|, and the total deficit of distinct
words is at most ∑_{i < m} (m - i) k ^ i ≤ 2 k ^ m. Choosing m gives the two standard forms:
c * log_k c ≤ n + 2 cwithm = ⌊log_k c⌋(length_mul_log_le_of_nodup);c * (log_k n - log_k log_k n - 4) ≤ n(length_mul_logb_sub_le_of_nodup). Fork = 2this is the boundc ≤ n / ((1 - ε_n) log₂ n)withε_n = min(1, (log₂ log₂ n + 4) / log₂ n)of [CT06], §13.5 (length_le_div_of_nodup,tendsto_epsilon). Here it is proved for every alphabet sizek ≥ 2with logarithms to basek.
The arithmetic steps from the first inequality to the other two are stated separately
(mul_log_le_of_forall_mul_le, mul_logb_sub_le_of_forall_mul_le), because LZ78's parse is
only distinct up to its last phrase and satisfies the first inequality by a variant argument
(mul_length_le_of_nodup_dropLast).
Main definitions #
Cslib.Algorithms.Lean.LempelZiv.DistinctParsing.epsilon: the vanishing slackε_nof the distinct-parsing lemma of [CT06], §13.5, to basek; its formula isCslib.Algorithms.Lean.LempelZiv.DistinctParsing.epsilon_def.
Main results #
Cslib.Algorithms.Lean.LempelZiv.DistinctParsing.sum_tsub_length_le_of_nodup: the total deficit bound.Cslib.Algorithms.Lean.LempelZiv.DistinctParsing.mul_length_le_of_nodup,Cslib.Algorithms.Lean.LempelZiv.DistinctParsing.mul_length_le_of_nodup_dropLast:m * c ≤ n + 2 * k ^ m, also when only the phrases before the last are distinct (and all phrases are nonempty).Cslib.Algorithms.Lean.LempelZiv.DistinctParsing.mul_log_le_of_forall_mul_le,Cslib.Algorithms.Lean.LempelZiv.DistinctParsing.mul_logb_sub_le_of_forall_mul_le,Cslib.Algorithms.Lean.LempelZiv.DistinctParsing.le_div_of_forall_mul_le: the arithmetic inversions.Cslib.Algorithms.Lean.LempelZiv.DistinctParsing.length_mul_log_le_of_nodup,Cslib.Algorithms.Lean.LempelZiv.DistinctParsing.length_mul_logb_sub_le_of_nodup,Cslib.Algorithms.Lean.LempelZiv.DistinctParsing.length_le_div_of_nodup: the distinct-parsing bound.Cslib.Algorithms.Lean.LempelZiv.DistinctParsing.tendsto_epsilon:ε_n → 0.
References #
The finite inequality m * c ≤ n + 2 * k ^ m #
Total deficit of distinct words. For pairwise distinct words over an alphabet of size
k, the deficits m - |w| sum to at most ∑_{i < m} (m - i) k ^ i.
Distinct-parsing inequality. If ws consists of c pairwise distinct words of total
length n over an alphabet of size k ≥ 2, then m * c ≤ n + 2 * k ^ m for every m.
The distinct-parsing inequality m * c ≤ n + 2 * k ^ m also holds when the phrases are
nonempty and only the phrases before the last are pairwise distinct, as in LZ78's parse, whose
last phrase may repeat an earlier one.
Arithmetic inversions #
Logarithmic form. If m * c ≤ n + 2 * k ^ m for every m (when k ≥ 2), then
c * ⌊log_k c⌋ ≤ n + 2 * c. For k ≤ 1 the floor logarithm is 0 and the bound is trivial.
Cover–Thomas form. If m * c ≤ n + 2 * k ^ m for every m, with k ≥ 2, then
c * (log_k n - log_k log_k n - 4) ≤ n. The proof takes m = ⌊log_k n - log_k log_k n⌋ - 2, so
that 4 (log_k n) k ^ m ≤ n, following [CT06], §13.5.
The slack ε_n = min(1, (log_k log_k n + 4) / log_k n) of [CT06], §13.5
(there with k = 2). It tends to 0 (tendsto_epsilon).
Cover–Thomas distinct-parsing bound, arithmetic form. If m * c ≤ n + 2 * k ^ m for
every m and ε_n < 1, then c ≤ n / ((1 - ε_n) log_k n).
The slack ε_n tends to 0.
The distinct-parsing bound #
Distinct-parsing bound, logarithmic form. A list of c pairwise distinct words of total
length n over an alphabet of size k satisfies c * ⌊log_k c⌋ ≤ n + 2 * c.
Distinct-parsing bound, Cover–Thomas form ([CT06], §13.5, for any
alphabet size k ≥ 2). A list of c pairwise distinct words of total length n satisfies
c * (log_k n - log_k log_k n - 4) ≤ n.
Distinct-parsing bound ([CT06], §13.5, for any alphabet size k ≥ 2).
A distinct parsing of a word of length n ≥ 2 into c phrases has
c ≤ n / ((1 - ε_n) log_k n), where ε_n → 0 (tendsto_epsilon).