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.
- For error
ε ≤ 1 / 2:n ≤ 2 ^ 10 r (b + 1) + 2 ^ 12whenever(4 ε (1 - ε)) ^ r ≤ 1 / 64(Cslib.Streaming.le_of_solves_freqMoment); for error1 / 3,n ≤ 36864 (b + 1) + 2 ^ 12(Cslib.Streaming.le_of_solves_freqMoment_one_third). - Deterministically:
n ≤ b(Cslib.Streaming.Algorithm.le_of_run_eq_freqMoment), from the exact deterministic complexityn + 1of disjointness. - Over the universe
Fin Nand streams of at most2 ⌊N / 3⌋items:Cslib.Streaming.div_le_of_solves_freqMoment,Cslib.Streaming.Algorithm.div_le_of_run_eq_freqMoment.
In all bounds b bounds the memory on the first half of the stream only, which is all the proofs
use.
Main results #
Cslib.Streaming.Algorithm.le_of_approx_freqMoment,Cslib.Streaming.Algorithm.div_le_of_approx_freqMoment: approximatingF_kdeterministically needsΩ(n)bits [AlonMatiasSzegedy1999, Proposition 3.7].Cslib.Streaming.le_of_solves_freqMoment,Cslib.Streaming.le_of_solves_freqMoment_one_third,Cslib.Streaming.div_le_of_solves_freqMoment: computingF_kexactly with bounded error needsΩ(n)bits [AlonMatiasSzegedy1999, Proposition 3.8].Cslib.Streaming.Algorithm.le_of_run_eq_freqMoment,Cslib.Streaming.Algorithm.div_le_of_run_eq_freqMoment: computingF_kexactly and deterministically needsnbits.
References #
Deterministic approximation #
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.
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 #
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.
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.
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.
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.
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.
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.