Ordered folds over fixed-width bitstrings #
The first count strings are enumerated by their little-endian numeric value.
The complete fold visits all 2 ^ width strings, including the single empty
string when width = 0. The update need not be associative or commutative.
def
Complexity.bitstringFoldPrefix
(update : List Bool → List Bool → List Bool)
(seed : List Bool)
(width : ℕ)
:
Fold over the first count fixed-width bitstrings in little-endian numeric
order. Prefixes past 2 ^ width repeat candidates; the space theorem only
bounds and uses prefixes up to that endpoint.
Equations
- Complexity.bitstringFoldPrefix update seed width 0 = seed
- Complexity.bitstringFoldPrefix update seed width count.succ = update (width.toBitsLE count) (Complexity.bitstringFoldPrefix update seed width count)
Instances For
def
Complexity.bitstringFold
(update : List Bool → List Bool → List Bool)
(seed : List Bool)
(width : ℕ)
:
Fold over every string of exactly width bits, in little-endian numeric order.
Equations
- Complexity.bitstringFold update seed width = Complexity.bitstringFoldPrefix update seed width (2 ^ width)