Documentation

CslibFrontier.Computability.Streaming.GraphStream

Graph streams #

The graph stream of a word a : Fin n → γ lists the pairs (i, a i) in order (Cslib.Streaming.graphStream); its items are distinct. In the concatenation of the graph streams of two words a and b, every position where a and b agree contributes one item seen twice and every other position two items seen once, so its k-th frequency moment is 2 ^ k · #{i | a i = b i} + 2 · d(a, b), where d is the Hamming distance (Cslib.Streaming.freqMoment_graphStream_append_eq). For k ≠ 1 it is 2 n exactly when a and b agree nowhere (Cslib.Streaming.freqMoment_graphStream_append_eq_two_mul_iff).

These streams are the hard instances of the Ω(n) lower bounds for the frequency moments of Alon, Matias and Szegedy [AlonMatiasSzegedy1999, Propositions 3.7 and 3.8] in CslibFrontier.Computability.Streaming.MomentLowerBound: for Proposition 3.7 the graphs of two codewords of a code of relative distance 1 / 2, for Proposition 3.8 graphs encoding two sets.

Main definitions #

Main results #

References #

def Cslib.Streaming.graphStream {n : ℕ} {γ : Type u_1} (a : Fin n → γ) :
List (Fin n × γ)

The graph stream (0, a 0), …, (n - 1, a (n - 1)) of a word a : Fin n → γ.

@[simp]
theorem Cslib.Streaming.length_graphStream {n : ℕ} {γ : Type u_1} (a : Fin n → γ) :
@[simp]
theorem Cslib.Streaming.mem_graphStream {n : ℕ} {γ : Type u_1} {a : Fin n → γ} {p : Fin n × γ} :
p ∈ graphStream a ↔ a p.1 = p.2
theorem Cslib.Streaming.nodup_graphStream {n : ℕ} {γ : Type u_1} (a : Fin n → γ) :
theorem Cslib.Streaming.count_graphStream {n : ℕ} {γ : Type u_1} [DecidableEq γ] (a : Fin n → γ) (p : Fin n × γ) :
List.count p (graphStream a) = if a p.1 = p.2 then 1 else 0
theorem Cslib.Streaming.freqMoment_graphStream_append {n : ℕ} {γ : Type u_1} [DecidableEq γ] (k : ℕ) (a b : Fin n → γ) :
freqMoment k (graphStream a ++ graphStream b) = ∑ i : Fin n, if a i = b i then 2 ^ k else 2

The frequency moments of two concatenated graph streams: each position where the words agree contributes an item seen twice, and each other position two items seen once.

theorem Cslib.Streaming.freqMoment_graphStream_append_eq {n : ℕ} {γ : Type u_1} [DecidableEq γ] (k : ℕ) (a b : Fin n → γ) :
freqMoment k (graphStream a ++ graphStream b) = 2 ^ k * {i : Fin n | a i = b i}.card + 2 * hammingDist a b

The frequency moments of two concatenated graph streams, through the number of positions where the words agree and their Hamming distance.

theorem Cslib.Streaming.freqMoment_graphStream_append_eq_two_mul_iff {n : ℕ} {γ : Type u_1} [DecidableEq γ] {k : ℕ} (hk : k ≠ 1) (a b : Fin n → γ) :
freqMoment k (graphStream a ++ graphStream b) = 2 * n ↔ ∀ (i : Fin n), a i ≠ b i

For k ≠ 1, the k-th frequency moment of two concatenated graph streams of length n is 2 n exactly when the words agree nowhere. For k = 1 it is always 2 n.