Treesets: Efficient Finite Sets with Unique Representations
arXiv:2612.05743 · doi:10.4204/EPTCS.459.6
Abstract
Unique representations allow ACL2 users to reason about data structures with ordinary equality rather than weaker equivalence relations. The osets library uses totally ordered lists to uniquely model finite sets, but this representation results in linear time for core primitives like membership, insertion, and deletion. We present the new treeset library, an alternative representation of ordered finite sets based on hash-ordered treaps. Like osets, the data structure is purely functional with a unique representation, while achieving expected logarithmic time for the basic search and update primitives. The core operations are functionally verified and an isomorphism is established with osets. Performance is supported empirically through benchmarking. Finally, we implement and verify a bidirectional iterator over treesets based on zippers.
arXiv commentIn Proceedings ACL2-2026, arXiv:2612.03645