Documentation

CslibFrontier.Computability.Streaming.MomentLowerBound

Linear memory for deterministic approximation and randomized exact computation of F_k #

Alon, Matias and Szegedy showed that for every k ≠ 1 both randomness and approximation are needed to compute the frequency moment F_k (Cslib.Streaming.freqMoment) in sublinear memory [AlonMatiasSzegedy1999, §3.3–3.4]. Both bounds compare F_k on two concatenated graph streams (Cslib.Streaming.graphStream).

Deterministic approximation [AlonMatiasSzegedy1999, Proposition 3.7]. There is a code of length L over 16 letters with 2 ^ L words, any two differing in at least half of the positions (Cslib.Code.exists_two_pow_le_card_and_le_two_mul_hammingDist, by the Gilbert–Varshamov bound). The graphs of its words are sets of size L in a universe of size 16 L, any two meeting in at most L / 2 items; this is the family of the source, which uses sets of size n / 4 meeting in at most n / 8 items in a universe of size n. With fewer than L bits of memory, two different words x ≠ y lead to the same memory state, so the algorithm answers alike on the graph streams of x x and y x. But F₀ is L on the first and at least 3 L / 2 on the second, and for k ≥ 2 F_k is 2 ^ k L on the first and at most (2 ^ k + 2) L / 2 on the second, so no answer is within η F_k of both when 7 η < 1, which covers the source's η = 0.1 (Cslib.Streaming.Algorithm.le_of_approx_freqMoment). Embedding the items into Fin N gives N / 16 ≤ b for streams of at most 2 ⌊N / 16⌋ ≤ N / 8 items (Cslib.Streaming.Algorithm.div_le_of_approx_freqMoment); the source states the bound for streams of n / 2 items.

Randomized exact computation [AlonMatiasSzegedy1999, Proposition 3.8]. Alice streams (i, 1) for her ones and (i, 0) for her zeros, Bob (i, 1) for his ones and (i, 2) for his zeros. The graphs agree exactly at the common ones, so for k ≠ 1 the moment F_k of the concatenated stream is 2 n exactly when the supports are disjoint (Cslib.Streaming.disjointness_eq_decide_freqMoment_eq). An algorithm computing F_k with error ε thus gives a one-way protocol for disjointness through Cslib.Streaming.Randomized.ecomplexityFun_le_of_spaceLE, and the Ω(n) lower bound for disjointness KalyanasundaramSchnitger1992 bounds its memory. The source applies the reduction of its Proposition 3.1 instead, which streams the positions of the ones of both players. Then F_k decides disjointness only by comparing it with the number of ones |x| + |y|, which depends on both inputs, whereas the answer map of Cslib.Streaming.Randomized.ecomplexityFun_le_of_spaceLE is fixed (Alice could send |x| in O(log n) more bits). The graph streams make the threshold 2 n independent of the inputs, at the price of the universe Fin n × Fin 3 of size 3 n.

In all bounds b bounds the memory on the first half of the stream only, which is all the proofs use.

Main results #

References #

Deterministic approximation #

theorem Cslib.Streaming.Algorithm.le_of_approx_freqMoment {σ : Type u_1} {L b k : ℕ} {η : ℝ} (hk : k ≠ 1) (hη : 7 * η < 1) (A : Algorithm σ (Fin L × Fin 16) ℝ) (hA : ∀ (s : List (Fin L × Fin 16)), s.length ≤ 2 * L → |A.run s - ↑(freqMoment k s)| ≤ η * ↑(freqMoment k s)) (hspace : A.SpaceLE L b) :
L ≤ b

Approximating F_k deterministically needs Ω(n) bits of memory for k ≠ 1 [AlonMatiasSzegedy1999, Proposition 3.7]: a deterministic streaming algorithm whose answer on every stream of at most 2 L items of Fin L × Fin 16 is within η F_k of F_k, for some η < 1 / 7, and which uses at most b bits of memory on streams of at most L items, has L ≤ b.

theorem Cslib.Streaming.Algorithm.div_le_of_approx_freqMoment {σ : Type u_1} {N b k : ℕ} {η : ℝ} (hk : k ≠ 1) (hη : 7 * η < 1) (A : Algorithm σ (Fin N) ℝ) (hA : ∀ (s : List (Fin N)), s.length ≤ 2 * (N / 16) → |A.run s - ↑(freqMoment k s)| ≤ η * ↑(freqMoment k s)) (hspace : A.SpaceLE (N / 16) b) :
N / 16 ≤ b

Approximating F_k deterministically needs Ω(n) bits of memory for k ≠ 1, over the universe Fin N [AlonMatiasSzegedy1999, Proposition 3.7]: a deterministic streaming algorithm whose answer on every stream of at most 2 ⌊N / 16⌋ items of Fin N is within η F_k of F_k, for some η < 1 / 7, and which uses at most b bits of memory on streams of at most N / 16 items, has N / 16 ≤ b.

Exact computation #

theorem Cslib.Streaming.disjointness_eq_decide_freqMoment_eq {n k : ℕ} (hk : k ≠ 1) (x y : BitString n) :
Communication.disjointness x y = decide (freqMoment k ((graphStream fun (i : Fin n) => if x i = true then 1 else 0) ++ graphStream fun (i : Fin n) => if y i = true then 1 else 2) = 2 * n)

Alice's graph (i, 1) for x i and (i, 0) otherwise, and Bob's (i, 1) for y i and (i, 2) otherwise, agree exactly at the common ones: for k ≠ 1, F_k of the concatenated stream is 2 n exactly when x and y have disjoint supports.

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

Computing F_k exactly needs Ω(n) bits of memory, even with randomness, for k ≠ 1 [AlonMatiasSzegedy1999, Proposition 3.8]: a randomized streaming algorithm that computes F_k with error at most ε ≤ 1 / 2 on streams of at most 2 n items of Fin n × Fin 3, 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_freqMoment_one_third {σ : Type u_1} {n b k : ℕ} (hk : k ≠ 1) (μ : Randomized σ (Fin n × Fin 3) ℕ) (hμ : μ.Solves (1 / 3) (fun (s : List (Fin n × Fin 3)) (c : ℕ) => c = freqMoment k s) (2 * n)) (hspace : μ.SpaceLE n b) :
n ≤ 36864 * (b + 1) + 2 ^ 12

Computing F_k exactly needs Ω(n) bits of memory, even with randomness [AlonMatiasSzegedy1999, Proposition 3.8], for error 1 / 3: n ≤ 36864 (b + 1) + 2 ^ 12.

theorem Cslib.Streaming.div_le_of_solves_freqMoment {σ : Type u_1} {N b r k : ℕ} {ε : ℝ} (hk : k ≠ 1) (hε : ε ≤ 1 / 2) (hr : (4 * ε * (1 - ε)) ^ r ≤ 1 / 64) (μ : Randomized σ (Fin N) ℕ) (hμ : μ.Solves ε (fun (s : List (Fin N)) (c : ℕ) => c = freqMoment k s) (2 * (N / 3))) (hspace : μ.SpaceLE (N / 3) b) :
N / 3 ≤ 2 ^ 10 * r * (b + 1) + 2 ^ 12

Computing F_k exactly needs Ω(n) bits of memory, even with randomness, for k ≠ 1, over the universe Fin N [AlonMatiasSzegedy1999, Proposition 3.8]: with error at most ε ≤ 1 / 2 on streams of at most 2 ⌊N / 3⌋ items and at most b bits of memory on streams of at most N / 3 items, N / 3 ≤ 2 ^ 10 r (b + 1) + 2 ^ 12 for every r with (4 ε (1 - ε)) ^ r ≤ 1 / 64.

theorem Cslib.Streaming.Algorithm.le_of_run_eq_freqMoment {σ : Type u_1} {n b k : ℕ} (hk : k ≠ 1) (A : Algorithm σ (Fin n × Fin 3) ℕ) (hA : ∀ (s : List (Fin n × Fin 3)), s.length ≤ 2 * n → A.run s = freqMoment k s) (hspace : A.SpaceLE n b) :
n ≤ b

Computing F_k exactly and deterministically needs n bits of memory, for k ≠ 1: a deterministic streaming algorithm computing F_k on every stream of at most 2 n items of Fin n × Fin 3, with at most b bits of memory on streams of at most n items, has n ≤ b.

theorem Cslib.Streaming.Algorithm.div_le_of_run_eq_freqMoment {σ : Type u_1} {N b k : ℕ} (hk : k ≠ 1) (A : Algorithm σ (Fin N) ℕ) (hA : ∀ (s : List (Fin N)), s.length ≤ 2 * (N / 3) → A.run s = freqMoment k s) (hspace : A.SpaceLE (N / 3) b) :
N / 3 ≤ b

Computing F_k exactly and deterministically needs Ω(n) bits of memory, for k ≠ 1, over the universe Fin N: with at most b bits of memory on streams of at most N / 3 items, a deterministic algorithm computing F_k on streams of at most 2 ⌊N / 3⌋ items has N / 3 ≤ b.