,
Seng Joe Watt
,
Derek Khu
,
Kuldeep S. Meel
,
Yong Kiam Tan
Creative Commons Attribution 4.0 International license
Estimating the number of distinct elements in a data stream is a classic problem with numerous applications in computer science. We formalize a recent, remarkably simple, randomized algorithm for this problem due to Chakraborty, Vinodchandran, and Meel (called the CVM algorithm). Their algorithm deviated considerably from the state of the art, due to its avoidance of intricate derandomization techniques, while still maintaining a close-to-optimal logarithmic space complexity. Central to our formalization is a new proof technique based on functional probabilistic invariants, which allows us to derive concentration bounds using the Cramér-Chernoff method without relying on independence. This simplifies the formal analysis considerably compared to the original proof by Chakraborty et al. Moreover, our technique opens up the possible algorithm design space; we demonstrate this by introducing and verifying a new variant of the CVM algorithm that is both total and unbiased - neither of which is a property of the original algorithm. In this paper, we introduce the proof technique, describe its use in mechanizing both versions of the CVM algorithm in Isabelle/HOL, and present a supporting formalized library on negatively associated random variables used to verify the latter variant.
@InProceedings{karayel_et_al:LIPIcs.ITP.2025.34,
author = {Karayel, Emin and Watt, Seng Joe and Khu, Derek and Meel, Kuldeep S. and Tan, Yong Kiam},
title = {{Verification of the CVM Algorithm with a Functional Probabilistic Invariant}},
booktitle = {16th International Conference on Interactive Theorem Proving (ITP 2025)},
pages = {34:1--34:20},
series = {Leibniz International Proceedings in Informatics (LIPIcs)},
ISBN = {978-3-95977-396-6},
ISSN = {1868-8969},
year = {2025},
volume = {352},
editor = {Forster, Yannick and Keller, Chantal},
publisher = {Schloss Dagstuhl -- Leibniz-Zentrum f{\"u}r Informatik},
address = {Dagstuhl, Germany},
URL = {https://drops.dagstuhl.de/entities/document/10.4230/LIPIcs.ITP.2025.34},
URN = {urn:nbn:de:0030-drops-246327},
doi = {10.4230/LIPIcs.ITP.2025.34},
annote = {Keywords: Verification, Isabelle/HOL, Randomized Algorithms, Distinct Elements}
}
archived version