Flattening and replacing fixed-width rows of bit lists #
Splitting a bit list of length count * width into count rows of width width via
Cslib.BitString.listRows and concatenating the rows recovers the original list, and replacing a
row via Cslib.BitString.replaceRow with a width-bit word produces a count * width-bit list.
Reading count rows of width width uses only the first count * width bits of the word.
Main results #
Cslib.BitString.listRows_take:listRows count width (word.take (count * width)) = listRows count width word.Cslib.BitString.flatten_listRows_of_length:(listRows count width w).flatten = wwhenw.length = count * width.Cslib.BitString.listRows_append_aligned: split a concatenation at a row boundary.Cslib.BitString.prefix_of_flatten_prefix: a prefix between flattened positive-width rows gives a prefix between their row lists.Cslib.BitString.length_replaceRow:(replaceRow width count j x word).length = count * widthwhenx.length = width.
theorem Cslib.BitString.prefix_of_flatten_prefix {width : ℕ} (hwidth : 0 < width) {us vs : List (List Bool)} (hu : ∀ row ∈ us, row.length = width) (hv : ∀ row ∈ vs, row.length = width) (h : us.flatten <+: vs.flatten) :
us <+: vs
For lists of rows of the same positive width, flattening reflects the prefix relation.