One-pass streaming algorithms #
A deterministic one-pass streaming algorithm (Cslib.Streaming.Algorithm σ α β) reads a stream
s : List α of items from left to right. It starts in a memory state init : σ, replaces its state
q by update q a on reading each item a, and finally reports output q : β. Updates are
arbitrary functions, so the model is non-uniform: it charges only the memory that survives between
items, which is the resource bounded by communication arguments [AlonMatiasSzegedy1999, Section 3].
Space. A.SpaceLE m b says that the memory states A reaches on streams of at most m items
(Cslib.Streaming.Algorithm.reachable) have an injective encoding by b-bit strings, that is,
there are at most 2 ^ b of them (Cslib.Streaming.Algorithm.spaceLE_of_subset_finset). The
space of an algorithm is thus log₂ of the number of its reachable states, rounded up; it does not
count states that no short stream reaches.
Randomness. A randomized streaming algorithm (Cslib.Streaming.Randomized σ α β) is a
distribution over deterministic ones: its random choices are drawn before the stream is read, as
for public-coin protocols (Cslib.Communication.PublicCoin). Its memory bound
(Cslib.Streaming.Randomized.SpaceLE) is checked separately for each algorithm in the support.
Since the update function of a drawn algorithm may depend on the random choices, the random bits
are free: they are not charged to the memory. This is the convention under which communication
lower bounds transfer. An algorithm that tosses fresh coins at each item becomes such a
distribution, for example after it counts the items it has read, which costs ⌈log₂ (m + 1)⌉
more bits on streams of at most m items; so lower bounds of order n still apply to it, up to
that additive term. μ.Solves ε R m says that on every stream of at most m items, the answer of
a random algorithm drawn from μ is related to the stream by R except with probability at most
ε.
Cslib.Streaming.Algorithm.reduce prefixes fixed items to the stream, translates the items and
post-processes the answer; it preserves memory bounds, which is how streaming lower bounds pass
between problems.
Main definitions #
Cslib.Streaming.Algorithm: deterministic one-pass streaming algorithms, withCslib.Streaming.Algorithm.stateandCslib.Streaming.Algorithm.run.Cslib.Streaming.Algorithm.SpaceLE: at mostbbits of memory on streams of at mostmitems.Cslib.Streaming.Algorithm.reduce: prefixing, translating items and post-processing answers.Cslib.Streaming.Randomized,Cslib.Streaming.Randomized.errorProb,Cslib.Streaming.Randomized.Solves,Cslib.Streaming.Randomized.SpaceLE: randomized streaming algorithms, their error and their memory.
Main results #
Cslib.Streaming.Algorithm.spaceLE_of_subset_finset,Cslib.Streaming.Algorithm.spaceLE_of_card_le: counting reachable states bounds the memory.Cslib.Streaming.Algorithm.SpaceLE.reduce,Cslib.Streaming.Randomized.SpaceLE.map_reduce,Cslib.Streaming.Randomized.errorProb_map_reduce_le: reductions keep memory and error.Cslib.Streaming.Randomized.solves_pure,Cslib.Streaming.Randomized.spaceLE_pure: deterministic algorithms as randomized ones.Cslib.Streaming.Randomized.errorProb_map_uniformOfFintype: the error of an algorithm drawn with a uniform seed is the fraction of bad seeds.
References #
A deterministic one-pass streaming algorithm over items of type α with outputs in β:
memory states σ, an initial state, an update reading one item, and an output function.
- init : σ
The initial memory state.
- update : σ → α → σ
The memory state after reading one more item.
- output : σ → β
The answer reported in a memory state.
Instances For
A uses at most b bits of memory on streams of length at most m: the memory states it
reaches on such streams have an injective encoding by b-bit strings, that is, there are at most
2 ^ b of them.
Instances For
An algorithm whose reachable states lie in a finite set of at most 2 ^ b states uses at most
b bits of memory.
The algorithm that first reads the items p, then reads each item a as g a, and answers
d of the answer of A.
Instances For
Reductions keep memory bounds, with the prefix counted in the stream length.
Randomized streaming algorithms #
The probability that the algorithm drawn from μ gives an answer on the stream s that is not
related to s by R.
Instances For
Every algorithm that μ can draw uses at most b bits of memory on streams of length at most
m.
Instances For
The error of an algorithm drawn with a uniformly random seed is the fraction of the seeds on which it errs.
Reducing every algorithm drawn from μ to R' by Algorithm.reduce keeps the error, when
the answer of A related to the reduced stream by R is mapped by d to an answer related to the
original stream by R'.
Reducing every algorithm drawn from μ keeps the memory bound, with the prefix counted in the
stream length.