Count-Min sketches for weighted insertion streams #
An update (x, c) adds the natural-number weight c to one bucket in each hash row. The
counter table is a vector of vectors, so updates materialize a finite table instead of retaining
a chain of functional updates. A point query takes the minimum of the counters addressed by
the queried item. It never underestimates the true frequency.
The exact bucket invariant identifies this executable update-and-fold algorithm with sums of stream weights. Tables built with the same hashes merge by entrywise addition. Every counter is bounded by the total inserted weight. These are semantic and numerical guarantees; this module does not assign machine running times to Lean operations or certify their heap consumption.
Main definitions #
Cslib.CountMin.frequency,Cslib.CountMin.mass: weighted frequency and total stream mass.Cslib.CountMin.bucket,Cslib.CountMin.noise: exact bucket and collision sums.Cslib.CountMin.Table,Cslib.CountMin.update,Cslib.CountMin.run: stored counters and the executable streaming algorithm.Cslib.CountMin.estimate: the minimum of a nonempty collection of hash rows.Cslib.CountMin.merge: entrywise addition of tables using the same hashes.
Main results #
Cslib.CountMin.bucket_hash_eq_frequency_add_noise: a queried counter is frequency plus noise.Cslib.CountMin.run_get: every stored counter equals its bucket sum.Cslib.CountMin.frequency_le_estimate_run: no underestimation.Cslib.CountMin.run_get_le_mass: each counter is at most the total stream weight.Cslib.CountMin.run_append: concatenation of streams agrees with merging their tables.
References #
Total weight inserted at the queried item.
Instances For
Weight contributed by other items colliding with the query in one hash row.
Instances For
A frequency cannot exceed the total inserted weight.
A stored array of d rows of w natural-number counters.
Instances For
The initial table has every counter zero.
Instances For
Merge tables formed with the same hash bank by adding corresponding counters.