Documentation

CslibFrontier.DataStructure.PrefixSums.CellProbe.LowerBound

Fredman–Saks lower bound for dynamic prefix parity #

Dynamic prefix parity maintains an array A : Fin n → ZMod 2, initially zero, under the operations update i b (set A i to b) and query i (return A 0 + ⋯ + A i). This is the partial-sums problem of [PD06], §2.1, over ZMod 2. Section 3.1 (p. 5) of that paper credits Fredman and Saks [FS89] with the first dynamic cell-probe lower bounds for this problem, via the chronogram method, including the trade-off t_q = Ω(lg n / (lg b + lg t_u)) for word size b, update time t_u and query time t_q.

This file proves that trade-off for deterministic step-indexed cell-probe schemes D : Cslib.CellProbe.IndexedScheme (Op n) Result S w, with worst-case depth bounds t_u on updates and t_q on queries. If S ≤ 2 ^ w, then log_β n ≤ 128 t_q + 1 for β = max 4 (8 t_u (2 w + 1)), i.e. t_q = Ω(log n / log (t_u (w + 1))).

Proof outline #

The hard instance has L epochs. Epoch j < L writes β ^ (L - j) bits X j k at positions k β ^ j L + j, and query q < β ^ L at position q L + L - 1 then answers Σ_j (X j 0 + ⋯ + X j (q / β ^ j)) (prefixParity_hardUpdates). Fix every epoch except j.

Scope #

Main definitions #

Main results #

References #

Dynamic prefix parity #

Operations of dynamic prefix parity on an array of n bits: update i b sets bit i to b, and query i asks for the parity of bits 0, …, i.

@[reducible, inline]

update returns nothing and query returns a bit.

def Cslib.DataStructure.PrefixSums.CellProbe.applyOp {n : ℕ} (A : Fin n → ZMod 2) :
Op n → Fin n → ZMod 2

The effect of one operation on the array.

The array after the operations ops, starting from the all-zero array.

The prefix parity A 0 + ⋯ + A i.

theorem Cslib.DataStructure.PrefixSums.CellProbe.prefixParity_eq_sum_range {n : ℕ} (A : Fin n → ZMod 2) (i : Fin n) :
prefixParity A i = ∑ k ∈ Finset.range (↑i + 1), if h : k < n then A ⟨k, h⟩ else 0

The prefix parity as a sum over the natural numbers k ≤ i.

A bit vector is determined by its prefix parities.

A cell-probe scheme answers prefix-parity queries correctly: after any operation sequence ops, a query at i returns the prefix parity of the current array.

theorem Cslib.DataStructure.PrefixSums.CellProbe.foldl_applyOp_apply {n : ℕ} (ops : List (Op n)) (A : Fin n → ZMod 2) (i : Fin n) (v : ZMod 2) (hv : ∀ (b : ZMod 2), Op.update i b ∈ ops → b = v) :
List.foldl applyOp A ops i = if ∃ (b : ZMod 2), Op.update i b ∈ ops then v else A i

If every update of ops to bit i writes v, then after ops bit i is v if some update wrote it, and unchanged otherwise.

The hard instance #

Epoch j < L writes β ^ (L - j) bits X j k at positions hardPos β L j k = k β ^ j L + j, and the query q < β ^ L asks for the prefix parity up to hardQueryPos L q = q L + (L - 1). Bit k of epoch j lies in the prefix of query q iff k β ^ j ≤ q, so the answer of query q is the sum over epochs of the prefix parities of X j up to q / β ^ j.

Position of bit k of epoch j.

theorem Cslib.DataStructure.PrefixSums.CellProbe.hardPos_lt {β L n j k : ℕ} (hn : L * β ^ L ≤ n) (hj : j < L) (hk : k < β ^ (L - j)) :
hardPos β L j k < n

Every bit of the hard instance lies inside the array.

theorem Cslib.DataStructure.PrefixSums.CellProbe.hardQueryPos_lt {β L n q : ℕ} (hn : L * β ^ L ≤ n) (hL : 0 < L) (hq : q < β ^ L) :

Every query of the hard instance lies inside the array.

Bit k of epoch j lies in the prefix of query q iff k β ^ j ≤ q.

theorem Cslib.DataStructure.PrefixSums.CellProbe.hardPos_inj {β L j j' k k' : ℕ} (hβ : 0 < β) (hj : j < L) (hj' : j' < L) (h : hardPos β L j k = hardPos β L j' k') :
j = j' ∧ k = k'

Distinct bits of the hard instance sit at distinct positions.

@[reducible, inline]

Inputs of the hard instance: epoch j < L carries β ^ (L - j) bits.

Arithmetic #

def Cslib.DataStructure.PrefixSums.CellProbe.hardSeg {β L n : ℕ} (hn : L * β ^ L ≤ n) (X : HardInput β L) (j : ℕ) :
List (Op n)

Epoch j of the hard update sequence: write X j k at hardPos β L j k for all k < β ^ (L - j); empty for j ≥ L.

def Cslib.DataStructure.PrefixSums.CellProbe.hardUpdates {β L n : ℕ} (hn : L * β ^ L ≤ n) (X : HardInput β L) :
List (Op n)

The hard update sequence: epochs 0, …, L - 1 in order.

def Cslib.DataStructure.PrefixSums.CellProbe.hardQueryIdx {β L n : ℕ} (hn : L * β ^ L ≤ n) (hL : 0 < L) (q : Fin (β ^ L)) :
Fin n

The position asked by query q < β ^ L.

The number of updates of the hard sequence.

theorem Cslib.DataStructure.PrefixSums.CellProbe.hardBlock_lt {β L q j : ℕ} (hj : j < L) (hq : q < β ^ L) :
q / β ^ j < β ^ (L - j)

Query q < β ^ L falls in block q / β ^ j < β ^ (L - j) of epoch j.

The answer of query q on the hard input X: the sum over epochs j of the prefix parity of X j up to q / β ^ j.

theorem Cslib.DataStructure.PrefixSums.CellProbe.mem_hardSeg {β L n : ℕ} (hn : L * β ^ L ≤ n) {X : HardInput β L} {j : ℕ} {o : Op n} (ho : o ∈ hardSeg hn X j) :
∃ (i : Fin n) (b : ZMod 2), o = Op.update i b

The hard update sequence consists of updates only.

theorem Cslib.DataStructure.PrefixSums.CellProbe.length_hardSeg {β L n : ℕ} (hn : L * β ^ L ≤ n) (X : HardInput β L) (j : ℕ) :
(hardSeg hn X j).length = if j < L then β ^ (L - j) else 0
theorem Cslib.DataStructure.PrefixSums.CellProbe.update_mem_hardUpdates {β L n : ℕ} (hn : L * β ^ L ≤ n) {X : HardInput β L} {i : Fin n} {b : ZMod 2} (h : Op.update i b ∈ hardUpdates hn X) :
∃ (j : Fin L) (k : Fin (β ^ (L - ↑j))), ↑i = hardPos β L ↑j ↑k ∧ b = X j k

Every update of the hard sequence writes X j k at hardPos β L j k.

theorem Cslib.DataStructure.PrefixSums.CellProbe.hardPos_mem_hardUpdates {β L n : ℕ} (hn : L * β ^ L ≤ n) (X : HardInput β L) (j : Fin L) (k : Fin (β ^ (L - ↑j))) :
Op.update ⟨hardPos β L ↑j ↑k, ⋯⟩ (X j k) ∈ hardUpdates hn X
theorem Cslib.DataStructure.PrefixSums.CellProbe.arrayOf_hardUpdates_hardPos {β L n : ℕ} (hn : L * β ^ L ≤ n) (hβ : 0 < β) (X : HardInput β L) (j : Fin L) (k : Fin (β ^ (L - ↑j))) :
arrayOf (hardUpdates hn X) ⟨hardPos β L ↑j ↑k, ⋯⟩ = X j k

After the hard updates, bit k of epoch j holds X j k.

theorem Cslib.DataStructure.PrefixSums.CellProbe.arrayOf_hardUpdates_eq_zero {β L n : ℕ} (hn : L * β ^ L ≤ n) (X : HardInput β L) {i : Fin n} (hi : ∀ (j : Fin L) (k : Fin (β ^ (L - ↑j))), ↑i ≠ hardPos β L ↑j ↑k) :
arrayOf (hardUpdates hn X) i = 0

After the hard updates, the positions not written by any epoch hold 0.

theorem Cslib.DataStructure.PrefixSums.CellProbe.prefixParity_hardUpdates {β L n : ℕ} (hn : L * β ^ L ≤ n) (hβ : 0 < β) (hL : 0 < L) (X : HardInput β L) (q : Fin (β ^ L)) :

Answer formula: the correct answer to query q after the hard updates of X.

theorem Cslib.DataStructure.PrefixSums.CellProbe.length_flatMap_hardSeg {β L n : ℕ} (hn : L * β ^ L ≤ n) (X : HardInput β L) (L' : ℕ) :
(List.flatMap (hardSeg hn X) (List.range L')).length = ∑ k ∈ Finset.range L', (hardSeg hn X k).length

The first L' epochs together have Σ_{k < L'} |hardSeg k| operations.

theorem Cslib.DataStructure.PrefixSums.CellProbe.length_hardUpdates {β L n : ℕ} (hn : L * β ^ L ≤ n) (X : HardInput β L) :

The hard update sequence has hardTime β L operations, whatever the input.

theorem Cslib.DataStructure.PrefixSums.CellProbe.hardSeg_update_of_ne {β L n : ℕ} (hn : L * β ^ L ≤ n) (X : HardInput β L) {j : Fin L} (x : Fin (β ^ (L - ↑j)) → ZMod 2) {k : ℕ} (hk : k ≠ ↑j) :
hardSeg hn (Function.update X j x) k = hardSeg hn X k

Changing the bits of epoch j leaves the other epochs unchanged.

theorem Cslib.DataStructure.PrefixSums.CellProbe.hardAnswer_update {β L : ℕ} (X : HardInput β L) (j : Fin L) (x : Fin (β ^ (L - ↑j)) → ZMod 2) (q : Fin (β ^ L)) :
hardAnswer (Function.update X j x) q = prefixParity x ⟨↑q / β ^ ↑j, ⋯⟩ + ∑ k ∈ Finset.univ.erase j, prefixParity (X k) ⟨↑q / β ^ ↑k, ⋯⟩

Changing the bits of epoch j changes only the j-th summand of the answer.

The encoding argument #

The lower bound #

theorem Cslib.DataStructure.PrefixSums.CellProbe.card_mul_le_sum_probes {n S w β L : ℕ} (hn : L * β ^ L ≤ n) (hL : 0 < L) (D : CellProbe.IndexedScheme (Op n) Result S w) (hD : AnswersQueries D) (hβ : 4 ≤ β) {tu : ℕ} (htu : ∀ (t : ℕ) (i : Fin n) (b : ZMod 2), (D.step t (Op.update i b)).depth ≤ tu) (hH : (S * 2 ^ w + 1) ^ (8 * tu) ≤ 2 ^ β) :
Fintype.card (HardInput β L) * β ^ L * L ≤ 64 * ∑ X : HardInput β L, ∑ q : Fin (β ^ L), (D.step (hardUpdates hn X).length (Op.query (hardQueryIdx hn hL q))).probes (D.runSeq (hardUpdates hn X)).2

Fredman–Saks lower bound, average form. Let D be a deterministic step-indexed cell-probe scheme for dynamic prefix parity on n bits with S cells of w bits, every update of which has depth at most tu. If L β ^ L ≤ n, β ≥ 4 and (S 2 ^ w + 1) ^ (8 tu) ≤ 2 ^ β, then over a uniformly random input X of the hard instance and a uniformly random query q < β ^ L, the query after the hard update sequence of X makes at least L / 64 probes on average.

theorem Cslib.DataStructure.PrefixSums.CellProbe.exists_le_mul_probes {n S w β L : ℕ} (hn : L * β ^ L ≤ n) (hL : 0 < L) (D : CellProbe.IndexedScheme (Op n) Result S w) (hD : AnswersQueries D) (hβ : 4 ≤ β) {tu : ℕ} (htu : ∀ (t : ℕ) (i : Fin n) (b : ZMod 2), (D.step t (Op.update i b)).depth ≤ tu) (hH : (S * 2 ^ w + 1) ^ (8 * tu) ≤ 2 ^ β) :
∃ (X : HardInput β L) (q : Fin (β ^ L)), L ≤ 64 * (D.step (hardUpdates hn X).length (Op.query (hardQueryIdx hn hL q))).probes (D.runSeq (hardUpdates hn X)).2

Fredman–Saks lower bound, hard-instance form. Under the hypotheses of card_mul_le_sum_probes, for some input X of the hard instance and some query q, the query after the hard update sequence of X makes at least L / 64 probes.

theorem Cslib.DataStructure.PrefixSums.CellProbe.le_mul_of_answersQueries {n S w β L : ℕ} (hn : L * β ^ L ≤ n) (D : CellProbe.IndexedScheme (Op n) Result S w) (hD : AnswersQueries D) (hβ : 4 ≤ β) {tu tq : ℕ} (htu : ∀ (t : ℕ) (i : Fin n) (b : ZMod 2), (D.step t (Op.update i b)).depth ≤ tu) (htq : ∀ (t : ℕ) (i : Fin n), (D.step t (Op.query i)).depth ≤ tq) (hH : (S * 2 ^ w + 1) ^ (8 * tu) ≤ 2 ^ β) :
L ≤ 64 * tq

Fredman–Saks lower bound, depth form. Under the hypotheses of exists_le_mul_probes, if every query has depth at most tq then L ≤ 64 tq.

theorem Cslib.DataStructure.PrefixSums.CellProbe.log_le_of_answersQueries {n S w : ℕ} (D : CellProbe.IndexedScheme (Op n) Result S w) (hD : AnswersQueries D) (hS : S ≤ 2 ^ w) {tu tq : ℕ} (htu : ∀ (t : ℕ) (i : Fin n) (b : ZMod 2), (D.step t (Op.update i b)).depth ≤ tu) (htq : ∀ (t : ℕ) (i : Fin n), (D.step t (Op.query i)).depth ≤ tq) :
Nat.log (max 4 (8 * tu * (2 * w + 1))) n ≤ 128 * tq + 1

Fredman–Saks lower bound [FS89] for dynamic prefix parity, in the form t_q = Ω(log n / log (t_u (w + 1))): a deterministic step-indexed cell-probe scheme with S ≤ 2 ^ w cells of w bits whose updates have depth at most t_u and whose queries have depth at most t_q satisfies log_β n ≤ 128 t_q + 1 for β = max 4 (8 t_u (2 w + 1)).