Documentation

CslibFrontier.Computability.Streaming.MultiPass

Multi-pass streaming algorithms give protocols #

A deterministic multi-pass streaming algorithm (Cslib.Streaming.MultiPass σ α β) reads the stream s several times from left to right. It is a one-pass algorithm (Cslib.Streaming.Algorithm) whose memory state is kept from one pass to the next, with endPass applied at the end of each pass, so that it can for instance count its passes; after p passes it reports the output of its state (Cslib.Streaming.MultiPass.run). Its memory is measured as for one pass: A.SpaceLE p m b says that the states it holds between items during p passes over streams of at most m items have an injective b-bit encoding. The state after endPass of the last pass is not counted: it is only used for the answer. A one-pass algorithm is the case p = 1 (Cslib.Streaming.Algorithm.run_toMultiPass, Cslib.Streaming.Algorithm.spaceLE_toMultiPass_iff).

Simulation. For $p \ge 1$ passes, with the stream split as u x ++ v y, Alice runs each pass on u x and sends the b-bit encoding of the memory state to Bob, who continues the pass on v y and, except after the last pass, sends the encoding of the resulting state back (Cslib.Streaming.MultiPass.toProtocol). This takes p messages from Alice and $p-1$ from Bob, so if the answer on u x ++ v y determines f x y, then f has a deterministic protocol with $(2p-1)b+1$ bits (Cslib.Streaming.MultiPass.ecomplexityFun_le_of_spaceLE), and, for randomized multi-pass algorithms with public randomness, a public-coin protocol with the same error (Cslib.Streaming.MultiPass.Randomized.ecomplexityFun_le_of_spaceLE). This extends the one-pass reduction of Alon, Matias and Szegedy [AlonMatiasSzegedy1999, Section 3] (CslibFrontier.Computability.Streaming.Communication) to p passes. The p-pass simulation itself is standard: Bar-Yossef, Jayram, Kumar and Sivakumar carry it out for several players [BarYossefJayramKumarSivakumar2004, proof of Theorem 3.1], Chang and Kannan describe it with $2p-1$ messages of at most $b$ bits each [ChangKannan2006, proof of Theorem 5.1], and Abboud, Censor-Hillel, Khoury and Paz state it as a theorem, with the asymptotic bound $pb = \Omega(\mathrm{CC}(f))$ [AbboudCensorHillelKhouryPaz2021, Theorem 14]. The exact constants here are proved directly. Since later passes depend on the whole stream, the whole stream u x ++ v y must have at most m items, whereas one pass only needs this of u x; so for p = 1 the one-pass theorem is slightly stronger.

Main definitions #

Main results #

References #

structure Cslib.Streaming.MultiPass (σ : Type u_1) (α : Type u_2) (β : Type u_3) extends Cslib.Streaming.Algorithm σ α β :
Type (max (max u_1 u_2) u_3)

A deterministic multi-pass streaming algorithm: a one-pass algorithm whose memory state is kept from one pass over the stream to the next, with endPass applied at the end of each pass.

  • init : σ
  • update : σ → α → σ
  • output : σ → β
  • endPass : σ → σ

    The memory state at the start of the next pass, given the state at the end of a pass.

def Cslib.Streaming.MultiPass.pass {σ : Type u_1} {α : Type u_2} {β : Type u_3} (A : MultiPass σ α β) (s : List α) (q : σ) :
σ

The memory state after one pass over s from q, including endPass.

def Cslib.Streaming.MultiPass.passes {σ : Type u_1} {α : Type u_2} {β : Type u_3} (A : MultiPass σ α β) (s : List α) (k : ℕ) :
σ

The memory state after k passes over s.

def Cslib.Streaming.MultiPass.run {σ : Type u_1} {α : Type u_2} {β : Type u_3} (A : MultiPass σ α β) (p : ℕ) (s : List α) :
β

The answer after p passes over s.

@[simp]
theorem Cslib.Streaming.MultiPass.passes_zero {σ : Type u_1} {α : Type u_2} {β : Type u_3} (A : MultiPass σ α β) (s : List α) :
A.passes s 0 = A.init
theorem Cslib.Streaming.MultiPass.passes_succ {σ : Type u_1} {α : Type u_2} {β : Type u_3} (A : MultiPass σ α β) (s : List α) (k : ℕ) :
A.passes s (k + 1) = A.pass s (A.passes s k)
theorem Cslib.Streaming.MultiPass.pass_append {σ : Type u_1} {α : Type u_2} {β : Type u_3} (A : MultiPass σ α β) (s t : List α) (q : σ) :
A.pass (s ++ t) q = A.endPass (A.stateFrom (A.stateFrom q s) t)

A pass over s ++ t is a pass over s continued on t.

def Cslib.Streaming.MultiPass.reachable {σ : Type u_1} {α : Type u_2} {β : Type u_3} (A : MultiPass σ α β) (p m : ℕ) :
Set σ

The memory states reachable during p passes over streams of length at most m: the states held between items during each pass, from its start to its end (before endPass).

def Cslib.Streaming.MultiPass.SpaceLE {σ : Type u_1} {α : Type u_2} {β : Type u_3} (A : MultiPass σ α β) (p m b : ℕ) :

A uses at most b bits of memory during p passes over streams of length at most m: the memory states it reaches have an injective encoding by b-bit strings.

theorem Cslib.Streaming.MultiPass.stateFrom_mem_reachable {σ : Type u_1} {α : Type u_2} {β : Type u_3} (A : MultiPass σ α β) {p m k : ℕ} {s t : List α} (hs : s.length ≤ m) (hk : k < p) (ht : t <+: s) :
A.stateFrom (A.passes s k) t ∈ A.reachable p m
theorem Cslib.Streaming.MultiPass.passes_mem_reachable {σ : Type u_1} {α : Type u_2} {β : Type u_3} (A : MultiPass σ α β) {p m k : ℕ} {s : List α} (hs : s.length ≤ m) (hk : k < p) :
A.passes s k ∈ A.reachable p m
theorem Cslib.Streaming.MultiPass.reachable_mono {σ : Type u_1} {α : Type u_2} {β : Type u_3} (A : MultiPass σ α β) {p p' m m' : ℕ} (hp : p ≤ p') (hm : m ≤ m') :
A.reachable p m ⊆ A.reachable p' m'
theorem Cslib.Streaming.MultiPass.SpaceLE.mono {σ : Type u_1} {α : Type u_2} {β : Type u_3} {A : MultiPass σ α β} {p p' m m' b : ℕ} (h : A.SpaceLE p' m' b) (hp : p ≤ p') (hm : m ≤ m') :
A.SpaceLE p m b

Memory bounds for longer streams and more passes give memory bounds for shorter streams and fewer passes.

def Cslib.Streaming.Algorithm.toMultiPass {σ : Type u_1} {α : Type u_2} {β : Type u_3} (A : Algorithm σ α β) :
MultiPass σ α β

A one-pass algorithm as a multi-pass algorithm that does nothing at the end of a pass.

@[simp]
theorem Cslib.Streaming.Algorithm.run_toMultiPass {σ : Type u_1} {α : Type u_2} {β : Type u_3} (A : Algorithm σ α β) (s : List α) :
A.toMultiPass.run 1 s = A.run s

One pass of A.toMultiPass is a run of A.

theorem Cslib.Streaming.Algorithm.reachable_toMultiPass {σ : Type u_1} {α : Type u_2} {β : Type u_3} (A : Algorithm σ α β) (m : ℕ) :

In one pass, A.toMultiPass reaches the states that A reaches.

theorem Cslib.Streaming.Algorithm.spaceLE_toMultiPass_iff {σ : Type u_1} {α : Type u_2} {β : Type u_3} (A : Algorithm σ α β) {m b : ℕ} :

A.toMultiPass uses b bits of memory in one pass exactly when A does.

noncomputable def Cslib.Streaming.MultiPass.decode {σ : Type u_1} {α : Type u_2} {β : Type u_3} (A : MultiPass σ α β) (p m b : ℕ) (enc : σ → BitString b) (w : BitString b) :
σ

Decoding a b-bit message: the state reachable during p passes over streams of length at most m that enc maps to it, if any.

theorem Cslib.Streaming.MultiPass.decode_enc {σ : Type u_1} {α : Type u_2} {β : Type u_3} (A : MultiPass σ α β) {p m b : ℕ} {enc : σ → BitString b} (henc : Set.InjOn enc (A.reachable p m)) {q : σ} (hq : q ∈ A.reachable p m) :
A.decode p m b enc (enc q) = q
noncomputable def Cslib.Streaming.MultiPass.simFrom {σ : Type u_1} {α : Type u_2} {β : Type u_3} {X : Type u_4} {Y : Type u_5} (A : MultiPass σ α β) (p m b : ℕ) (enc : σ → BitString b) (u : X → List α) (v : Y → List α) (d : β → Bool) :

The protocol simulating the last n + 1 passes, starting from the state q that both players know. Alice continues the pass from q on u x and sends the encoded state; Bob decodes it and finishes the pass on v y. After the last pass Bob announces d of the answer; otherwise he sends the encoded state, and the simulation continues from its decoding.

noncomputable def Cslib.Streaming.MultiPass.toProtocol {σ : Type u_1} {α : Type u_2} {β : Type u_3} {X : Type u_4} {Y : Type u_5} (A : MultiPass σ α β) (p m b : ℕ) (enc : σ → BitString b) (u : X → List α) (v : Y → List α) (d : β → Bool) :

The protocol in which Alice and Bob simulate p passes of A over u x ++ v y, exchanging the b-bit encoding of the memory state, and Bob announces d of the answer. This is meant for $p \ge 1$, which Cslib.Streaming.MultiPass.run_toProtocol and Cslib.Streaming.MultiPass.depth_toProtocol_le assume: for p = 0 the truncated subtraction p - 1 = 0 makes it the protocol for one pass, so it does not simulate A.run 0.

theorem Cslib.Streaming.MultiPass.depth_simFrom_le {σ : Type u_1} {α : Type u_2} {β : Type u_3} {X : Type u_4} {Y : Type u_5} (A : MultiPass σ α β) (p m b : ℕ) (enc : σ → BitString b) (u : X → List α) (v : Y → List α) (d : β → Bool) (n : ℕ) (q : σ) :
(A.simFrom p m b enc u v d n q).depth ≤ (2 * n + 1) * b + 1
theorem Cslib.Streaming.MultiPass.depth_toProtocol_le {σ : Type u_1} {α : Type u_2} {β : Type u_3} {X : Type u_4} {Y : Type u_5} (A : MultiPass σ α β) {p : ℕ} (hp : 0 < p) (m b : ℕ) (enc : σ → BitString b) (u : X → List α) (v : Y → List α) (d : β → Bool) :
(A.toProtocol p m b enc u v d).depth ≤ (2 * p - 1) * b + 1

The simulation of p passes sends $(2p-1)b+1$ bits.

theorem Cslib.Streaming.MultiPass.run_simFrom {σ : Type u_1} {α : Type u_2} {β : Type u_3} {X : Type u_4} {Y : Type u_5} (A : MultiPass σ α β) {p m b : ℕ} {enc : σ → BitString b} (henc : Set.InjOn enc (A.reachable p m)) (u : X → List α) (v : Y → List α) (d : β → Bool) {x : X} {y : Y} (hm : (u x ++ v y).length ≤ m) (n k : ℕ) (hnk : k + n + 1 ≤ p) :
(A.simFrom p m b enc u v d n (A.passes (u x ++ v y) k)).run x y = d (A.output (A.passes (u x ++ v y) (k + n + 1)))
theorem Cslib.Streaming.MultiPass.run_toProtocol {σ : Type u_1} {α : Type u_2} {β : Type u_3} {X : Type u_4} {Y : Type u_5} (A : MultiPass σ α β) {p m b : ℕ} (hp : 0 < p) {enc : σ → BitString b} (henc : Set.InjOn enc (A.reachable p m)) (u : X → List α) (v : Y → List α) (d : β → Bool) {x : X} {y : Y} (hm : (u x ++ v y).length ≤ m) :
(A.toProtocol p m b enc u v d).run x y = d (A.run p (u x ++ v y))

When enc is injective on the states reachable during p passes over streams of length at most m, and the stream u x ++ v y has length at most m, the simulation answers as the algorithm.

theorem Cslib.Streaming.MultiPass.ecomplexityFun_le_of_spaceLE {σ : Type u_1} {α : Type u_2} {β : Type u_3} {X : Type u_4} {Y : Type u_5} (A : MultiPass σ α β) {p m b : ℕ} (hp : 0 < p) (hA : A.SpaceLE p m b) (u : X → List α) (v : Y → List α) (hm : ∀ (x : X) (y : Y), (u x ++ v y).length ≤ m) (d : β → Bool) (f : X → Y → Bool) (hf : ∀ (x : X) (y : Y), d (A.run p (u x ++ v y)) = f x y) :

Multi-pass streaming space bounds communication (deterministic): if, for $p \ge 1$, a p-pass streaming algorithm with b bits of memory on streams of length at most m decides f x y from its answer on the stream u x ++ v y, which has length at most m, then f has a deterministic protocol with $(2p-1)b+1$ bits.

Randomized multi-pass algorithms #

@[reducible, inline]
abbrev Cslib.Streaming.MultiPass.Randomized (σ : Type u_6) (α : Type u_7) (β : Type u_8) :
Type (max (max u_8 u_7) u_6)

A randomized multi-pass streaming algorithm with public randomness: a distribution over deterministic ones. As for one pass (Cslib.Streaming.Randomized), the random choices are not charged to the memory.

def Cslib.Streaming.MultiPass.Randomized.SpaceLE {σ : Type u_1} {α : Type u_2} {β : Type u_3} (μ : Randomized σ α β) (p m b : ℕ) :

Every algorithm that μ can draw uses at most b bits of memory during p passes over streams of length at most m.

theorem Cslib.Streaming.MultiPass.Randomized.ecomplexityFun_le_of_spaceLE {σ : Type u_1} {α : Type u_2} {β : Type u_3} {X : Type u_4} {Y : Type u_5} (μ : Randomized σ α β) {p m b : ℕ} (hp : 0 < p) (hμ : μ.SpaceLE p m b) (u : X → List α) (v : Y → List α) (hm : ∀ (x : X) (y : Y), (u x ++ v y).length ≤ m) (d : β → Bool) (f : X → Y → Bool) {ε : ℝ} (hf : ∀ (x : X) (y : Y), ((PMF.toOuterMeasure μ) {A : MultiPass σ α β | d (A.run p (u x ++ v y)) ≠ f x y}).toReal ≤ ε) :

Multi-pass streaming space bounds communication (public coins): if, for $p \ge 1$, a randomized p-pass streaming algorithm μ whose algorithms use at most b bits of memory on streams of length at most m decides f x y with error ε from its answer on u x ++ v y, which has length at most m, then f has a public-coin protocol with error ε and $(2p-1)b+1$ bits.