Documentation

CslibFrontier.Computability.Streaming.Distinctness

Streaming lower bounds for distinctness and the largest frequency #

Splitting the stream into the positions of Alice's ones followed by the positions of Bob's ones (Cslib.BitString.positions), the items are distinct exactly when the two bit strings have disjoint supports (Cslib.Streaming.nodup_positions_append). A streaming algorithm deciding whether the items of a stream are distinct thus gives a one-way protocol for disjointness (Cslib.Streaming.Randomized.ecomplexityFun_le_of_spaceLE), and the Ω(n) lower bound for disjointness KalyanasundaramSchnitger1992 becomes an Ω(n) lower bound on the memory.

Main results #

References #

Detecting a repeated item #

The positions of the ones of x followed by those of y are distinct exactly when x and y have disjoint supports.

theorem Cslib.Streaming.le_of_solves_nodup {σ : Type u_1} {n b r : ℕ} {ε : ℝ} (hε : ε ≤ 1 / 2) (hr : (4 * ε * (1 - ε)) ^ r ≤ 1 / 64) (μ : Randomized σ (Fin n) Bool) (hμ : μ.Solves ε (fun (s : List (Fin n)) (c : Bool) => c = decide s.Nodup) (2 * n)) (hspace : μ.SpaceLE n b) :
n ≤ 2 ^ 10 * r * (b + 1) + 2 ^ 12

Detecting a repeated item needs Ω(n) bits of memory: a randomized streaming algorithm that decides, with error at most ε ≤ 1 / 2 on streams of at most 2 n items of Fin n, whether all items are distinct, and whose algorithms use at most b bits of memory on streams of at most n items, has n ≤ 2 ^ 10 r (b + 1) + 2 ^ 12 for every r with (4 ε (1 - ε)) ^ r ≤ 1 / 64. For ε < 1 / 2 such an r exists.

theorem Cslib.Streaming.le_of_solves_nodup_one_third {σ : Type u_1} {n b : ℕ} (μ : Randomized σ (Fin n) Bool) (hμ : μ.Solves (1 / 3) (fun (s : List (Fin n)) (c : Bool) => c = decide s.Nodup) (2 * n)) (hspace : μ.SpaceLE n b) :
n ≤ 36864 * (b + 1) + 2 ^ 12

Detecting a repeated item needs Ω(n) bits of memory, for error 1 / 3: n ≤ 36864 (b + 1) + 2 ^ 12.

theorem Cslib.Streaming.Algorithm.le_of_run_eq_decide_nodup {σ : Type u_1} {n b : ℕ} (A : Algorithm σ (Fin n) Bool) (hA : ∀ (s : List (Fin n)), s.length ≤ 2 * n → A.run s = decide s.Nodup) (hspace : A.SpaceLE n b) :
n ≤ b

Deterministic detection of a repeated item needs n bits of memory: a deterministic streaming algorithm deciding whether at most 2 n items of Fin n are distinct, with at most b bits of memory on streams of at most n items, has n ≤ b.

The largest frequency #

theorem Cslib.Streaming.decide_lt_four_thirds_eq {α : Type u_1} [DecidableEq α] {s : List α} (hs : s ≠ []) {Y : ℝ} (hY : |Y - ↑(maxFreq s)| < ↑(maxFreq s) / 3) :
decide (Y < 4 / 3) = decide s.Nodup

On a nonempty stream, an estimate within less than a third of F∞ decides whether the items are distinct by comparing it with 4 / 3.

theorem Cslib.Streaming.le_of_solves_maxFreq {σ : Type u_1} {n b r : ℕ} {ε : ℝ} (hε : ε ≤ 1 / 2) (hr : (4 * ε * (1 - ε)) ^ r ≤ 1 / 64) (μ : Randomized σ (Fin (n + 1)) ℝ) (hμ : μ.Solves ε (fun (s : List (Fin (n + 1))) (Y : ℝ) => s ≠ [] → |Y - ↑(maxFreq s)| < ↑(maxFreq s) / 3) (2 * n + 1)) (hspace : μ.SpaceLE (n + 1) b) :
n ≤ 2 ^ 10 * r * (b + 1) + 2 ^ 12

Approximating F∞ needs Ω(n) bits of memory [AlonMatiasSzegedy1999, Proposition 3.1]: a randomized streaming algorithm that estimates the largest frequency of a nonempty stream of at most 2 n + 1 items of Fin (n + 1) within less than a third of it, except with probability at most ε ≤ 1 / 2, and whose algorithms use at most b bits of memory on streams of at most n + 1 items, has n ≤ 2 ^ 10 r (b + 1) + 2 ^ 12 for every r with (4 ε (1 - ε)) ^ r ≤ 1 / 64. An estimate within λ F∞ for a fixed λ < 1 / 3 is in particular within less than a third.

theorem Cslib.Streaming.le_of_solves_maxFreq_one_third {σ : Type u_1} {n b : ℕ} (μ : Randomized σ (Fin (n + 1)) ℝ) (hμ : μ.Solves (1 / 3) (fun (s : List (Fin (n + 1))) (Y : ℝ) => s ≠ [] → |Y - ↑(maxFreq s)| < ↑(maxFreq s) / 3) (2 * n + 1)) (hspace : μ.SpaceLE (n + 1) b) :
n ≤ 36864 * (b + 1) + 2 ^ 12

Approximating F∞ needs Ω(n) bits of memory [AlonMatiasSzegedy1999, Proposition 3.1], for error 1 / 3: n ≤ 36864 (b + 1) + 2 ^ 12.

theorem Cslib.Streaming.Algorithm.le_of_run_eq_maxFreq {σ : Type u_1} {n b : ℕ} (A : Algorithm σ (Fin n) ℕ) (hA : ∀ (s : List (Fin n)), s.length ≤ 2 * n → A.run s = maxFreq s) (hspace : A.SpaceLE n b) :
n ≤ b

Computing F∞ exactly needs n bits of memory deterministically: a deterministic streaming algorithm computing the largest frequency of every stream of at most 2 n items of Fin n, with at most b bits of memory on streams of at most n items, has n ≤ b.