Documentation

CslibFrontier.Foundations.Data.BitString.WeightedEnumeration

Bounded binary enumeration #

Fixed-width words enumerate each natural number below their range exactly once. The weighted sum identity generalizes the corresponding counting argument, and applies to both natural and signed summands. Values outside a requested interval contribute zero.

Main results #

theorem Cslib.BitString.sum_binaryValue_lt {M : Type u_1} [AddCommMonoid M] {n k : ℕ} (hk : k ≤ 2 ^ n) (f : ℕ → M) :
(∑ w : Fin n → Bool, if binaryValue (List.ofFn w) < k then f (binaryValue (List.ofFn w)) else 0) = ∑ i ∈ Finset.range k, f i

Fixed-width binary enumeration preserves a sum on an initial interval of its range.