Documentation

Complexity.Foundations.Data.BitString.Binary

Bridges between BitString.equivFin and binary numeral views #

Cslib.BitString.equivFin n numbers n-bit strings Fin n → Bool with 0 as the least significant coordinate. This module connects equivFin n to the list-based numeral views Cslib.BitString.lsbValue (least significant bit first) and Cslib.BitString.binaryValue (most significant bit first), as well as Nat.ofBits and Nat.testBit, without adding a BitString.Basic dependency to the list-level modules BitString.Counter or BitString.List.Binary.

Main results #

equivFin agrees with Nat.ofBits on n-bit words.

@[simp]
theorem Cslib.BitString.equivFin_symm_apply {n : ℕ} (k : Fin (2 ^ n)) (i : Fin n) :
(equivFin n).symm k i = (↑k).testBit ↑i

The i-th bit of (equivFin n).symm k is the i-th binary digit of k.

Reading the bits of an n-bit word in order gives its number in equivFin n.

Reading the bits of an input, least significant first, gives its number in the order of BitString.equivFin.