Documentation

CslibFrontier.DataStructure.ApproximateMembership.Spec

Dynamic Approximate-Membership Filter Specification #

This file defines an algorithm-independent oblivious-sequence specification (Cslib.DataStructure.ApproximateMembership.spec) for a dynamic approximate-membership filter (supporting insertions, deletions of present keys, and membership queries) over a finite universe Fin U with capacity n and per-query false-positive probability bound ε : ℝ≥0∞.

Semantic design and duplicate-insertion convention #

At any point in an operation sequence ops : List (Op U), the filter represents a dynamic set S : Finset (Fin U) of at most n keys, starting from ∅:

Excluding duplicate insertions of an already-present key (u ∉ S) at the specification level is essential for achieving $O(1)$ per-operation expected time in fingerprint-based filters such as the quotient filter Pagh, Pagh and Rao; Bender et al.: if an operation sequence could insert the same key u n times, all n copies would share the same quotient and remainder on every random branch, forming a deterministic run of length n and forcing $\Omega(n)$ probe time. Internally, the quotient filter still maintains the multiset of fingerprints S.val.map fp so that when two distinct present keys x ≠ y in S collide in both quotient and remainder, deleting x removes only one copy of their shared fingerprint and preserves zero false negatives for y.

Main definitions #

Main results #

References #

Operations on a dynamic approximate-membership filter over universe Fin U.

  • insert {U : ℕ} (u : Fin U) : Op U

    Insert key u into the represented set.

  • delete {U : ℕ} (u : Fin U) : Op U

    Delete key u from the represented set (valid when u is currently present).

  • query {U : ℕ} (u : Fin U) : Op U

    Query whether key u is currently in the represented set.

Instances For
    @[instance_reducible]
    @[reducible, inline]

    Return type of each filter operation: PUnit for insert and delete, Bool for query.

    @[reducible, inline]

    Transcript entry pairing a filter operation with its observation.

    Single-step update of the currently present key set S : Finset (Fin U).

    The set of keys present after executing ops starting from S.

    @[simp]
    theorem Cslib.DataStructure.ApproximateMembership.activeSetFrom_append {U : ℕ} (S : Finset (Fin U)) (ops₁ ops₂ : List (Op U)) :
    activeSetFrom S (ops₁ ++ ops₂) = activeSetFrom (activeSetFrom S ops₁) ops₂

    The set of keys present after executing ops starting from the empty set ∅.

    The set of keys present immediately before step idx in ops.

    Single-step admissibility of operation o from current key set S under capacity n:

    • insert u is valid when u ∉ S and #S < n;
    • delete u is valid when u ∈ S;
    • query u is always valid.

    Multi-step admissibility of ops : List (Op U) starting from key set S under capacity n.

    @[simp]
    theorem Cslib.DataStructure.ApproximateMembership.validOpSeqFrom_cons {U : ℕ} (n : ℕ) (S : Finset (Fin U)) (o : Op U) (rest : List (Op U)) :
    ValidOpSeqFrom n S (o :: rest) ↔ ValidOp n S o ∧ ValidOpSeqFrom n (stepSet S o) rest

    Multi-step admissibility of ops : List (Op U) starting from ∅ under capacity n.

    theorem Cslib.DataStructure.ApproximateMembership.card_stepSet_le {U n : ℕ} {S : Finset (Fin U)} {o : Op U} (hS : S.card ≤ n) (ho : ValidOp n S o) :
    (stepSet S o).card ≤ n
    theorem Cslib.DataStructure.ApproximateMembership.card_activeSetFrom_le {U n : ℕ} {S : Finset (Fin U)} {ops : List (Op U)} (hS : S.card ≤ n) (hv : ValidOpSeqFrom n S ops) :
    theorem Cslib.DataStructure.ApproximateMembership.validOpSeqFrom_take {U n : ℕ} {S : Finset (Fin U)} {ops : List (Op U)} (hv : ValidOpSeqFrom n S ops) (idx : ℕ) :

    Pathwise zero-false-negative invariant: whenever u ∈ activeSetBefore ops idx and step idx is .query u, the transcript entry at idx is ⟨.query u, true⟩.

    Event that transcript tr outputs true at step idx for query u.

    @[reducible, inline]

    Oblivious-sequence specification of a dynamic approximate-membership filter over universe Fin U with capacity n and per-query false-positive probability bound ε : ℝ≥0∞:

    1. Every transcript in μ.support matches ops and has zero false negatives on every query of a currently present key (u ∈ activeSetBefore ops idx).
    2. At every query of a currently absent key (ops[idx]? = some (.query u) with u ∉ activeSetBefore ops idx), the probability of returning true is at most ε.
    theorem Cslib.DataStructure.ApproximateMembership.spec_weaken {U n : ℕ} {ε₁ ε₂ : ENNReal} (hε : ε₁ ≤ ε₂) {ops : List (Op U)} {μ : PMF (List (Label U))} (h : (spec U n ε₁).Contract ops μ) :
    (spec U n ε₂).Contract ops μ

    Monotonicity of spec in the false-positive bound ε₁ ≤ ε₂.