Bit strings represented by lists #
Fixed-width views of ordinary lists pad missing bits with false. A flat list can also be read
as a specified number of fixed-width rows. The representation uses the existing blocksEquiv;
row extraction is ordinary dropping, padding and taking, including on short or empty lists.
Main definitions #
Cslib.BitString.ofList: a fixed-width view of a list.Cslib.BitString.listRow,Cslib.BitString.listRows: fixed-width rows of a flat list.Cslib.BitString.replaceRow: replace one fixed-width row of a flat list.
Main results #
Cslib.BitString.ofList_ofFn,Cslib.BitString.ofFn_ofList: representation round trips.Cslib.BitString.ofList_append_of_le,Cslib.BitString.ofList_ofFn_append: fixed-width views ignore bits beyond their width.Cslib.BitString.exists_take_ofFn_iff,Cslib.BitString.forall_take_ofFn_iff: quantifying over longer strings through their prefixes.Cslib.BitString.ofFn_ofList_eq_take: the fixed-width view pads withfalseor truncates.Cslib.BitString.getElem_listRow,Cslib.BitString.getD_listRow: row indexing, including false padding on short words.Cslib.BitString.listRow_flatMap_append,Cslib.BitString.listRow_flatten: recover equal-width rows from concatenated words.Cslib.BitString.listRow_replaceRow: reading rows after replacing one row.Cslib.BitString.listRows_eq_ofFn,Cslib.BitString.listRows_ofFn: agreement with the finite block representation.Cslib.BitString.listRows_succ_append: the rows of a word whose first row is given.
Packing fixed-width rows is list concatenation by Cslib.BitString.ofFn_blocksEquiv_symm, in
CslibFrontier.Foundations.Data.BitString.Block.
References #
Adapted from Probability/WordBits.lean on the cslib crypto branch at
5ff69ca93402e7c947208dc56396d6d86203ccd8, reusing the shared bit-string block equivalence.
Below the row width, defaulted indexing reads the corresponding word bit, even when the
word is too short and the row is padded with false.
Reading an existing row from concatenated equal-width words recovers that row, regardless of the appended suffix. Width zero is allowed.