Documentation

CslibFrontier.Foundations.Data.BitString.List.Rows

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 #

theorem Cslib.BitString.listRows_take (count width : ℕ) (word : List Bool) :
listRows count width (List.take (count * width) word) = listRows count width word

Reading count rows of width width does not see bits beyond the first count * width.

theorem Cslib.BitString.flatten_listRows_of_length {count width : ℕ} {w : List Bool} (hw : w.length = count * width) :
(listRows count width w).flatten = w

Splitting a list of length count * width into count rows of width width and flattening the rows recovers the original list.

theorem Cslib.BitString.listRows_append_aligned {width : ℕ} (hwidth : 0 < width) {left right : List Bool} (hleft : width ∣ left.length) (hright : width ∣ right.length) :
listRows ((left ++ right).length / width) width (left ++ right) = listRows (left.length / width) width left ++ listRows (right.length / width) width right

Splitting a concatenation of aligned bit lists into rows splits each list separately.

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.

@[simp]
theorem Cslib.BitString.length_replaceRow {width count j : ℕ} {x : List Bool} (hx : x.length = width) (word : List Bool) :
(replaceRow width count j x word).length = count * width

Replacing one fixed-width row with a width-bit word produces a count * width-bit list.