Sparse binary words #
Sums of distinct powers of two have exactly their specified set bits. Thus an injective placement of Boolean coefficients cannot generate binary carries. The statements concern natural-number arithmetic, independently of a machine word width or execution cost.
Main results #
testBit_sum_two_pow: the set bits of a sum of distinct powers of two.testBit_sum_injective: injectively placed Boolean coefficients are recovered exactly.and_sum_two_pow: masking by sparse positions is their Boolean-weighted sum.
References #
These extend Mathlib's finite-set/binary-digit correspondence.
theorem Cslib.BitString.sum_strictMono_lt_iff {α : Type u_1} [Fintype α] [LinearOrder α] (f g : α → ℕ) (hf : StrictMono f) (hg : StrictMono g) (c d : α → Bool) :
Increasing placements of the same Boolean coefficients give the same comparisons. Gaps between bits do not affect numeric order.