Selecting and restoring positions of a bit list #
readPositions selects bits in a supplied order. restorePositions writes those selected bits
back into a full list, retaining a reference list at unselected positions. Both operations are
executable and total: out-of-range reads and missing selected bits are false, and restoring keeps
the reference list's length. A repeated position uses its first occurrence in the selected list.
Main definitions #
Cslib.BitString.readPositions: read a list of positions, in order.Cslib.BitString.restorePositions: restore selected bits into a reference list.
Main results #
Cslib.BitString.getD_readPositions_idxOf: a selected position reads its original bit.Cslib.BitString.getD_restorePositions: the bitwise restoration rule.Cslib.BitString.restorePositions_readPositions: selecting and restoring recovers any list that agrees with the reference outside the selected positions.
@[simp]
Reading positions returns one bit per position.
@[simp]
Restoring positions preserves the reference list's length.
theorem Cslib.BitString.restorePositions_readPositions (positions : List ℕ) (reference word : List Bool) (hlength : word.length = reference.length) (houtside : ∀ j < reference.length, j ∉ positions → word.getD j false = reference.getD j false) :
Reading and restoring selected positions recovers a list that agrees with the reference at all unselected positions. Repeated or out-of-range selected positions do not affect the identity.