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.
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.ofFn_eq_append: a string is its prefix followed by its suffix.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.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.Cslib.BitString.ofFn_blocksEquiv_symm: packing fixed-width rows is list concatenation.
References #
Adapted from Probability/WordBits.lean on the cslib crypto branch at
5ff69ca93402e7c947208dc56396d6d86203ccd8, reusing the shared bit-string block equivalence.
A string of k + j bits is its first k bits followed by its last j bits.
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.