Bit strings as BitVec words #
Both Cslib.BitString w (Fin w → Bool, numbered via Cslib.BitString.equivFin w) and Lean's
BitVec w index bits from the least significant position 0. The computable equivalence
Cslib.BitString.equivBitVec identifies the two representations (getLsbD_equivBitVec,
getElem_equivBitVec, equivBitVec_symm_apply, equivBitVec_getLsbD), preserves unsigned natural
values (toNat_equivBitVec_eq_equivFin), and relates the BooleanRing zero and complement on
BitString w to 0#w and bitwise complement ~~~ (equivBitVec_zero, equivBitVec_symm_zero,
equivBitVec_compl).
Main definitions #
Cslib.BitString.equivBitVec: computable equivalenceBitString w ≃ BitVec wpreserving little-endian bit coordinates.
Main results #
Cslib.BitString.toNat_equivBitVec_eq_equivFin:(equivBitVec x).toNatagrees with the unsigned value(equivFin w x : ℕ).
Bit i (least significant first) of equivBitVec x is x i.
Indexing equivBitVec x at i < w returns x ⟨i, hi⟩.
Rebuilding a BitVec w from the bits v.getLsbD i.val via equivBitVec recovers v.
equivBitVec and equivFin assign the same unsigned natural value to every w-bit string.
equivBitVec maps the zero bit string (all false) to 0#w.
equivBitVec.symm maps 0#w to the zero bit string.
equivBitVec maps Boolean complement xᶜ to BitVec bitwise complement ~~~.