Documentation

CslibFrontier.DataStructure.HashFamily.Spec

Multi-Epoch Hash-Family Oblivious-Sequence Specifications #

This file defines oblivious-sequence specifications (Cslib.DataStructure.ObliviousSequenceSpec) for resamplable hash families over a key universe Fin U and codomain Fin m with operations Op.resample (starting a new resampling epoch with an independently sampled seed) and Op.eval u (evaluating the active hash function at u : Fin U):

Main definitions #

Main results #

References #

Operations of a resamplable hash-family data structure over universe Fin U:

  • resample: draw a fresh hash function from the family (starting a new resampling epoch);
  • eval u: evaluate the current hash function at key u : Fin U.
@[instance_reducible]
def Cslib.DataStructure.HashFamily.instDecidableEqOp.decEq {U✝ : ℕ} (x✝ x✝¹ : Op U✝) :
Decidable (x✝ = x✝¹)
@[reducible, inline]

Observation type returned by each Op U for codomain Fin m: PUnit for .resample and Fin m for .eval u.

@[reducible, inline]

Input-output label pairing an Op U operation with its Result m observation.

The finite set of distinct keys queried in the current epoch of ops (before the first .resample operation).

The suffix of ops following the first .resample operation, or none if ops contains no .resample.

When afterCurrentEpoch ops = some rest, rest is strictly shorter than ops.

Number of .resample operations in ops.

Total number of resampling epochs in ops (the initial epoch plus one for each .resample).

@[irreducible]

Admissibility predicate asserting that every resampling epoch of ops queries at most k distinct keys.

Deterministic transcript of the current epoch of ops (before the first .resample), determined by the restriction g : currentEpochKeys ops → Fin m of the hash function to the keys queried in that epoch.

@[irreducible]
noncomputable def Cslib.DataStructure.HashFamily.idealTranscriptPMF {U : ℕ} (m : ℕ) [NeZero m] (ops : List (Op U)) :
PMF (List (Label U m))

Ideal multi-epoch transcript distribution of a k-wise independent hash family with codomain Fin m: in each epoch, the values on currentEpochKeys ops are drawn uniformly from currentEpochKeys ops → Fin m, independently of all subsequent epochs.

noncomputable def Cslib.DataStructure.HashFamily.evalOpsFromSeed {Seed : Type u} {U m : ℕ} (seedLaw : PMF Seed) (eval : Seed → Fin U → Fin m) (θ : Seed) :
List (Op U) → PMF (List (Label U m))

Step-by-step evaluation of ops : List (Op U) starting from an active seed θ : Seed: .eval u deterministically returns eval θ u without changing θ, while .resample draws a fresh seed θ' ← seedLaw and continues with θ'.

noncomputable def Cslib.DataStructure.HashFamily.evalOps {Seed : Type u} {U m : ℕ} (seedLaw : PMF Seed) (eval : Seed → Fin U → Fin m) (ops : List (Op U)) :
PMF (List (Label U m))

Multi-epoch transcript distribution induced by drawing an initial seed θ₀ ← seedLaw and executing ops : List (Op U) via evalOpsFromSeed.

@[reducible, inline]

Exact k-wise independent hash-family specification over universe Fin U and codomain Fin m: on any oblivious operation sequence ops querying at most k distinct keys per resampling epoch (BoundedEpochKeys k ops), the output transcript distribution equals idealTranscriptPMF m ops.

@[reducible, inline]

High-probability k-wise independent hash-family specification with per-epoch failure bound δ : ℝ≥0∞: on any oblivious operation sequence ops querying at most k distinct keys per resampling epoch (BoundedEpochKeys k ops), every supported transcript matches ops and the transcript distribution μ is coupled within (epochCount ops : ℝ≥0∞) * δ of idealTranscriptPMF m ops.

theorem Cslib.DataStructure.HashFamily.transcriptMatches_of_mem_support_evalOpsFromSeed {Seed : Type u} {U m : ℕ} (seedLaw : PMF Seed) (eval : Seed → Fin U → Fin m) (θ : Seed) (ops : List (Op U)) (out : List (Label U m)) :
out ∈ (evalOpsFromSeed seedLaw eval θ ops).support → TranscriptMatches ops out

Every transcript in the support of evalOpsFromSeed matches ops.

theorem Cslib.DataStructure.HashFamily.transcriptMatches_of_mem_support_evalOps {Seed : Type u} {U m : ℕ} (seedLaw : PMF Seed) (eval : Seed → Fin U → Fin m) (ops : List (Op U)) (out : List (Label U m)) :
out ∈ (evalOps seedLaw eval ops).support → TranscriptMatches ops out

Every transcript in the support of evalOps matches ops.

theorem Cslib.DataStructure.HashFamily.evalOpsFromSeed_eq_of_afterCurrentEpoch_eq_none {Seed : Type u} {U m : ℕ} (seedLaw : PMF Seed) (eval : Seed → Fin U → Fin m) (θ : Seed) {ops : List (Op U)} (hafter : afterCurrentEpoch ops = none) :
evalOpsFromSeed seedLaw eval θ ops = PMF.pure (currentEpochPrefixTranscript m ops ((currentEpochKeys ops).restrict (eval θ)))

On a single-epoch sequence (afterCurrentEpoch ops = none), evalOpsFromSeed reduces to a point mass on currentEpochPrefixTranscript applied to the restricted hash function (currentEpochKeys ops).restrict (eval θ).

theorem Cslib.DataStructure.HashFamily.evalOpsFromSeed_eq_of_afterCurrentEpoch_eq_some {Seed : Type u} {U m : ℕ} (seedLaw : PMF Seed) (eval : Seed → Fin U → Fin m) (θ : Seed) {ops rest : List (Op U)} (hafter : afterCurrentEpoch ops = some rest) :
evalOpsFromSeed seedLaw eval θ ops = PMF.map (fun (tailOut : List (Label U m)) => currentEpochPrefixTranscript m ops ((currentEpochKeys ops).restrict (eval θ)) ++ ⟨Op.resample, PUnit.unit⟩ :: tailOut) (evalOps seedLaw eval rest)

When afterCurrentEpoch ops = some rest, evalOpsFromSeed decomposes into the deterministic current-epoch prefix currentEpochPrefixTranscript followed by .resample and an independent draw from evalOps seedLaw eval rest.

theorem Cslib.DataStructure.HashFamily.evalOps_eq_of_afterCurrentEpoch_eq_none {Seed : Type u} {U m : ℕ} (seedLaw : PMF Seed) (eval : Seed → Fin U → Fin m) {ops : List (Op U)} (hafter : afterCurrentEpoch ops = none) :
evalOps seedLaw eval ops = PMF.map (currentEpochPrefixTranscript m ops) (PMF.map (fun (θ : Seed) => (currentEpochKeys ops).restrict (eval θ)) seedLaw)

On a single-epoch sequence (afterCurrentEpoch ops = none), evalOps is the pushforward of the restricted seed distribution seedLaw.map (fun θ => (currentEpochKeys ops).restrict (eval θ)) under currentEpochPrefixTranscript m ops.

theorem Cslib.DataStructure.HashFamily.evalOps_eq_of_afterCurrentEpoch_eq_some {Seed : Type u} {U m : ℕ} (seedLaw : PMF Seed) (eval : Seed → Fin U → Fin m) {ops rest : List (Op U)} (hafter : afterCurrentEpoch ops = some rest) :
evalOps seedLaw eval ops = (PMF.map (currentEpochPrefixTranscript m ops) (PMF.map (fun (θ : Seed) => (currentEpochKeys ops).restrict (eval θ)) seedLaw)).bind fun (pref : List (Label U m)) => PMF.map (fun (tailOut : List (Label U m)) => pref ++ ⟨Op.resample, PUnit.unit⟩ :: tailOut) (evalOps seedLaw eval rest)

When afterCurrentEpoch ops = some rest, evalOps decomposes into the current-epoch prefix distribution bound to an independent tail draw evalOps seedLaw eval rest.

theorem Cslib.DataStructure.HashFamily.kWiseSpec_contract_evalOps {Seed : Type u} {k U m : ℕ} [Fintype Seed] [Nonempty Seed] [NeZero m] {eval : Seed → Fin U → Fin m} (hk : Probability.IsKWiseIndependentHash k eval) {ops : List (Op U)} (hv : BoundedEpochKeys k ops) :

Fundamental bridge theorem for exact k-wise independent hash families: if eval : Seed → Fin U → Fin m satisfies IsKWiseIndependentHash k eval, then on any oblivious operation sequence ops querying at most k distinct keys per epoch (BoundedEpochKeys k ops), evalOps (PMF.uniformOfFintype Seed) eval ops equals idealTranscriptPMF m ops and therefore satisfies (kWiseSpec k U m).Contract ops.

theorem Cslib.DataStructure.HashFamily.whpKWiseSpec_contract_of_kWiseSpec {k U m : ℕ} [NeZero m] (δ : ENNReal) {ops : List (Op U)} {μ : PMF (List (Label U m))} (hmatch : ∀ out ∈ μ.support, TranscriptMatches ops out) (hk : (kWiseSpec k U m).Contract ops μ) :
(whpKWiseSpec k U m δ).Contract ops μ

Every distribution whose supported transcripts match ops (TranscriptMatches ops) and which satisfies (kWiseSpec k U m).Contract ops also satisfies (whpKWiseSpec k U m δ).Contract ops for any δ : ℝ≥0∞.

theorem Cslib.DataStructure.HashFamily.whpKWiseSpec_contract_evalOps_prod {TopSeed : Type u} {BotSeed : Type v} {k U m : ℕ} [Fintype TopSeed] [Nonempty TopSeed] [DecidableEq TopSeed] [Fintype BotSeed] [Nonempty BotSeed] [NeZero m] (eval : TopSeed → BotSeed → Fin U → Fin m) (GoodTop : Finset TopSeed) (hgood : ∀ α ∈ GoodTop, Probability.IsKWiseIndependentHash k (eval α)) {ops : List (Op U)} (hv : BoundedEpochKeys k ops) :
(whpKWiseSpec k U m (↑(Finset.univ \ GoodTop).card / ↑(Fintype.card TopSeed))).Contract ops (evalOps (Probability.PMF.uniformOfFintype (TopSeed × BotSeed)) (fun (p : TopSeed × BotSeed) => eval p.1 p.2) ops)

Fundamental bridge theorem for two-level high-probability k-wise hash families: if eval : TopSeed → BotSeed → Fin U → Fin m is k-wise independent on every good top seed α ∈ GoodTop, then under uniform resampling on TopSeed × BotSeed, any oblivious sequence ops querying at most k distinct keys per epoch (BoundedEpochKeys k ops) satisfies (whpKWiseSpec k U m δ).Contract ops with bad-seed measure δ = (#(Finset.univ \ GoodTop) : ℝ≥0∞) / Fintype.card TopSeed.

theorem Cslib.DataStructure.HashFamily.evalOpsFromSeed_map_equiv {Seed₁ : Type u} {Seed₂ : Type v} {U m : ℕ} (seedLaw : PMF Seed₁) (eval : Seed₁ → Fin U → Fin m) (e : Seed₁ ≃ Seed₂) (θ : Seed₁) (ops : List (Op U)) :
evalOpsFromSeed seedLaw eval θ ops = evalOpsFromSeed (PMF.map (⇑e) seedLaw) (fun (s : Seed₂) => eval (e.symm s)) (e θ) ops

Relabelling the seed type along an equivalence e : Seed₁ ≃ Seed₂ transports evalOpsFromSeed by pushing forward seedLaw along e and pulling back eval along e.symm.

theorem Cslib.DataStructure.HashFamily.whpKWiseSpec_contract_evalOps_equiv {Seed : Type w} {TopSeed : Type u} {BotSeed : Type v} {k U m : ℕ} [Fintype Seed] [Nonempty Seed] [Fintype TopSeed] [Nonempty TopSeed] [DecidableEq TopSeed] [Fintype BotSeed] [Nonempty BotSeed] [NeZero m] (eval : Seed → Fin U → Fin m) (e : Seed ≃ TopSeed × BotSeed) (GoodTop : Finset TopSeed) (hgood : ∀ α ∈ GoodTop, Probability.IsKWiseIndependentHash k fun (β : BotSeed) => eval (e.symm (α, β))) {ops : List (Op U)} (hv : BoundedEpochKeys k ops) :
(whpKWiseSpec k U m (↑(Finset.univ \ GoodTop).card / ↑(Fintype.card TopSeed))).Contract ops (evalOps (Probability.PMF.uniformOfFintype Seed) eval ops)

Transport whpKWiseSpec_contract_evalOps_prod along a seed equivalence e : Seed ≃ (TopSeed × BotSeed).