A linearly packed tree of bit sums #
A balanced addition tree counts a block of bits. Its level j contains counts of blocks of
2^j bits, and each such count fits in j+1 bits. The bit planes of every level fit together
in fewer than four times the number of leaves. Their addresses use only shifts and additions.
Main definitions #
Cslib.BitString.sumTree: the sum at a node of the balanced tree.Cslib.BitString.sumTreeAddress: a bit-plane address within the packed tree.Cslib.BitString.sumTreeBits: the packed bit planes of the tree, read by address.Cslib.BitString.sumTreeWords: the packed bit planes stored in eight words ofhbits.
Main results #
Cslib.BitString.sumTree_eq_sum: the tree counts its specified block.Cslib.BitString.sumTree_testBit: the root counts the set bits of a natural number.Cslib.BitString.sumTreeAddress_injective: distinct valid node bits have distinct addresses.
References #
- N. Immerman, Descriptive Complexity, Lemma 1.18 (Bit Sum Lemma). This balanced-tree packing is a variant of the packed running-sum construction there.
Counting all the bit positions containing a numeral gives its number of set bits.
Bit b of node q at level j in a tree with 2^m leaves.
Instances For
theorem Cslib.BitString.sumTreeAddress_injective {m j b q j' b' q' : ℕ} (hj : j ≤ m) (hb : b ≤ j) (hq : q < 2 ^ (m - j)) (hj' : j' ≤ m) (hb' : b' ≤ j') (hq' : q' < 2 ^ (m - j')) (he : sumTreeAddress m j b q = sumTreeAddress m j' b' q') :
Valid bits at different levels, nodes or bit positions never share an address.
Every packed witness is strictly less than 2^h, independently of the tree contents.