Optimized libraries for representing finite sets of natural numbers using bit masks, featuring a strong connection to the std/osets library.
The
Either representation provides a nice set-level abstraction that should shield you from reasoning about the underlying bitwise arithmetic operations; see reasoning.
To load everything (except for optimizations that require trust tags):
(include-book "std/bitsets/top" :dir :system)
Alternately, for just the plain bitset library:
(include-book "std/bitsets/bitsets" :dir :system)
Or for just the sparse bitsets library:
(include-book "std/bitsets/sbitsets" :dir :system)
You may be able to substantially speed up the bitset-members operation for large sets, perhaps especially on CCL, by loading an optimized, raw Lisp definition:
(include-book "std/bitsets/bitsets-opt" :dir :system)
See ttag-bitset-members and bignum-extract for details.