Algebraic operations on lists of bits #
Finite bit strings and ordinary lists agree under pointwise XOR, Boolean dot products, basis vectors, subset sums and strict majority. List algorithms are total: an out-of-range basis index produces zeros, missing selectors are false, and pointwise XOR truncates to the shorter list. Collection XOR has a declared width and treats missing bits as false.
Main definitions #
Cslib.BitString.listStrictMajority: strict majority, returning false on a tie.Cslib.BitString.listNonpositiveMargin: compare correct votes with all votes.Cslib.BitString.listSingle,Cslib.BitString.listSingles: basis vectors in coordinate order.Cslib.BitString.listXorSelected: sum selected rows using an ordinary fold.Cslib.BitString.listXor: sum every row at a declared width, padding missing bits with false.
Main results #
Cslib.BitString.ofFn_add,Cslib.BitString.dotProduct_eq_foldl: algebraic representation laws.Cslib.BitString.listStrictMajority_map: a list with distinct voting indices agrees with finite-set strict majority.Cslib.BitString.listXorSelected_eq_ofFn_sum: the selector fold computes the finite mask sum.Cslib.BitString.listXor_eq_ofFn_sum: collection XOR computes the finite sum of padded views.
References #
Adapted from Probability/WordBits.lean and Crypto/Computational/GoldreichLevin/WordDecoder.lean
and Crypto/Computational/Pseudoentropy/Boosting/Vote.lean and
Crypto/Computational/GeneratorXor.lean
on the cslib crypto branch at 5ff69ca93402e7c947208dc56396d6d86203ccd8.
A Boolean dot product is a pointwise AND followed by a parity fold on words.
Strict majority of a word of votes, choosing false on a tie.
Instances For
The existing strict-majority operation is equivalently a comparison of vote counts.
Listing each voting index once gives exactly finite-set strict majority.
A coordinate mask, with all zeros when the index is outside the requested dimension.
Instances For
The coordinate-mask program agrees with the finite basis vector.
The coordinate masks list the finite basis vectors in increasing index order.
On finite masks, the selector fold is exactly the sum of the selected rows.