Problem

Let v⃗=(v1,...,vd)∈Rd\vec v = (v_1, ..., v_d) \in \mathbb{R}^d be a vector, such that ∃\exists some positive integer MM, ∀i∈[d],vi∈[M]\forall i \in [d], v_i \in [M]. Assume that dd is very large and v⃗\vec v is sparse, so it is represented by a set of pairs that record the non-zero positions and values of v⃗:\vec v:

S(v⃗)≐{(i,vi):vi≠0,∀i∈[d]}. S(\vec v ) \doteq \{ (i, v_i ) : v_i \neq 0, \forall i \in [d] \}.

A fingerprint h(v⃗)∈Rh( \vec v) \in \mathbb{R} is a succinct summary of v⃗\vec v, which can be used to test whether two vectors v⃗,u⃗∈Rd\vec{v}, \vec{u} \in \mathbb{R}^d are equal.

Goal: For a given δ∈(0,1)\delta \in (0, 1), find an h:Rd→Rh: \mathbb{R}^d \rightarrow \mathbb{R}, such that, ∀v⃗,u⃗∈Rd\forall \vec v, \vec u \in \mathbb{R}^d, if v⃗≠u⃗\vec v \neq \vec u, then

Pr⁡[h(v⃗)=h(u⃗)]≤δ. \Pr [ h( \vec v) = h ( \vec u) ] \le \delta.

Solution

Theorem. Let p≥max⁡{d/δ,M}p \ge \max\{ d / \delta, M \} be a prime number and let aa be an integer generated from 11 to p−1p - 1 uniformly at random. Then

h(v⃗)≐∑i∈[d]vi⋅ai h( \vec v ) \doteq \sum_{i \in [d] } v_i \cdot a^i

satisfies the goal.

Remark. It is easy to see that fingerprint is a linear summary:

h(v⃗)=[a,a2,…,ad][v1,v2,⋮vd]. h(\vec{v}) = \begin{bmatrix} a, a^2, \ldots, a^d \end{bmatrix} \begin{bmatrix} v_1, \\ v_2, \\ \vdots \\ v_d \end{bmatrix}.

Proof. ∀v⃗,u⃗∈Rd\forall \vec v, \vec u \in \mathbb{R}^d, if v⃗≠u⃗\vec v \neq \vec u, if h(v⃗)=h(u⃗)h( \vec v) = h ( \vec u), then

∑i∈[d](vi−ui)⋅ai=0. \sum_{i \in [d] } (v_i - u_i) \cdot a^i = 0.

However, the polynomial p(x)≐∑i∈[d](vi−ui)⋅xip(x) \doteq \sum_{i \in [d] } (v_i - u_i) \cdot x^i has at most dd distinct roots. As p(0)=0p(0) = 0, it has at most d−1d - 1 distinct non-zero root. The probability that a≠0a \neq 0 being one of them is bounded by

Pr⁡[a is a root of p(x)]=d−1p−1≤dp=δ. \Pr \left[ a \text{ is a root of } p(x) \right] = \frac{d - 1 }{ p - 1} \le \frac{ d } { p } = \delta.

□\square

h(v⃗)h (\vec v) can be computed by the following pseudo-codes:

  1. h←0h \leftarrow 0.
  2. For (i,vi)∈S(v⃗):(i, v_i) \in S( \vec v):
  3. \qquad h←h+vi⋅aih \leftarrow h + v_i \cdot a^i.
  4. Return hh.

Reference

[1] G. Cormode and K. Yi, Small Summaries for Big Data, 1st ed. Cambridge University Press, 2020.