Documentation

CslibFrontier.DataStructure.NearNeighbor.Angular

Probabilistic SimHash query-failure step in angular distance #

This module formalizes the SimHash LSH exponent bound ρ ≤ 1 / c and probabilistic candidate-collision / query-failure step on unbucketed point-set filtering in angular distance (after [Cha02] and [IM98]; not a bucketed sublinear approximate near-neighbour data structure, tracked in #3361).

SimHash is (θ, c θ, 1 - θ / π, 1 - c θ / π)-sensitive for angular distance on nonzero vectors (Cslib.Probability.isLocalitySensitive_simHash_subtype). Concavity of log yields ρ ≤ 1 / c (Cslib.DataStructure.NearNeighbor.rho_simHash_le), table count L < n ^ (1 / c) / (1 - θ / π) + 1 (numTables_simHash_lt), and unbucketed query failure at most e⁻¹ + 1 / 3 (measureReal_query_simHash_eq_none_le). Word-RAM hash buckets, Gaussian seed storage, and sublinear O(n ^ (1 / c)) query running time remain open in #3361.

Main results #

References #

theorem Cslib.DataStructure.NearNeighbor.rho_simHash_le {θ c : ℝ} (hθ : 0 < θ) (hc : 1 < c) (hcθ : c * θ < Real.pi) :
rho (1 - θ / Real.pi) (1 - c * θ / Real.pi) ≤ 1 / c

SimHash parameter-exponent step (after [Cha02] and [IM98]; #3361): for 0 < θ, 1 < c, and c θ < π, log (1 / (1 - θ / π)) / log (1 / (1 - c θ / π)) ≤ 1 / c.

theorem Cslib.DataStructure.NearNeighbor.measureReal_query_simHash_eq_none_le {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] {θ c : ℝ} (hθ : 0 < θ) (hc : 1 < c) (hcθ : c * θ < Real.pi) {P : List { x : E // x ≠ 0 }} {q x₀ : { x : E // x ≠ 0 }} (hx₀ : x₀ ∈ P) (hnear : InnerProductGeometry.angle ↑x₀ ↑q ≤ θ) :
(MeasureTheory.Measure.pi fun (x : Fin (numTables P.length (1 - θ / Real.pi) (1 - c * θ / Real.pi))) => MeasureTheory.Measure.pi fun (x : Fin (numHashes P.length (1 - c * θ / Real.pi))) => ProbabilityTheory.stdGaussian E).real {s : Fin (numTables P.length (1 - θ / Real.pi) (1 - c * θ / Real.pi)) → Fin (numHashes P.length (1 - c * θ / Real.pi)) → E | query (Probability.andHash (fun (r : E) (u : { x : E // x ≠ 0 }) => Probability.simHash r ↑u) (numHashes P.length (1 - c * θ / Real.pi))) (fun (x y : { x : E // x ≠ 0 }) => c * θ ≤ InnerProductGeometry.angle ↑x ↑y) s (3 * numTables P.length (1 - θ / Real.pi) (1 - c * θ / Real.pi)) P q = none} ≤ Real.exp (-1) + 1 / 3

Probabilistic query-failure step for SimHash on unbucketed point-set filtering in angular distance (after [Cha02] and [IM98]; not a bucketed sublinear near-neighbour data structure, #3361). On nonzero vectors of E with 0 < θ, 1 < c, c θ < π, p₁ = 1 - θ / π, p₂ = 1 - c θ / π, k = numHashes n p₂, L = numTables n p₁ p₂, and T = 3 L, if some x₀ ∈ P makes angle at most θ with q, query returns none with probability at most e⁻¹ + 1 / 3; any returned vector has angle below c θ with q (query_eq_some).

theorem Cslib.DataStructure.NearNeighbor.numTables_simHash_lt {n : ℕ} (hn : 0 < n) {θ c : ℝ} (hθ : 0 < θ) (hc : 1 < c) (hcθ : c * θ < Real.pi) :
↑(numTables n (1 - θ / Real.pi) (1 - c * θ / Real.pi)) < ↑n ^ (1 / c) / (1 - θ / Real.pi) + 1

Parameter table-count step for SimHash (#3361): L < n ^ (1 / c) / (1 - θ / π) + 1.