Documentation

UniversalHashing.Toeplitz

This module defines a universal-2 hash by vector matrix multiplication with Toeplitz matrices.

Toeplitz matrices are defined in ToeplitzGeneral.lean.

Main results:

theorem toeplitzModp_mulVec_deltaUniversal2 (m n p : ) [NeZero m] [NeZero n] [hp : Fact (Nat.Prime p)] :
HashFamily.deltaUniversal2 fun (M : ToeplitzMatrix m n (ZMod p)) (v : Fin nZMod p) => (↑M).mulVec v

Multiplication (mod p) by a random Toeplitz matrix is a perfectly Δ-universal hash family: for distinct inputs x ≠ y, every difference value b is attained with probability exactly 1 / p^m.

By linearity the difference collapses to a single product, M x − M y = M (x − y), and for d ≠ 0 the map MM d is a surjective linear map, so all its fibers are translates of each other and have equal size.

theorem toeplitzModp_mulVec_isUniversal2 (m n p : ) [NeZero m] [NeZero n] [Fact (Nat.Prime p)] :
HashFamily.universal2 fun (M : ToeplitzMatrix m n (ZMod p)) (v : Fin nZMod p) => (↑M).mulVec v

Multiplication (mod p) by a random Toeplitz matrix is a universal-2 hash family. Follows from perfect Δ-universality (toeplitzModp_mulVec_deltaUniversal2), of which universal-2 is the b = 0 special case.

def toeplitzHash (m n : ) :
HashFamily (Fin (m + n - 1)ZMod 2) (Fin nZMod 2) (Fin mZMod 2)

Toeplitz hash, expressed using only bit vectors.

Equations
Instances For

    toeplitzHash is perfectly Δ-universal (XOR-universal): for distinct inputs, every difference value is attained with probability exactly 1 / 2^m. Transported from toeplitzModp_mulVec_deltaUniversal2 along the seed bijection ToeplitzMatrix.equiv_params.

    toeplitzHash is (1 / 2^m)-almost-Δ-universal — with the optimal parameter, since toeplitzHash.deltaUniversal2 attains the bound with equality.

    toeplitzHash is universal-2: the b = 0 special case of toeplitzHash.deltaUniversal2.

    theorem Nat.ne_rat_ge1_of_lt1 (n : ) (q : ) (nne0 : n > 0) (qlt1 : q < 1) :
    n q