Documentation

CslibFrontier.Foundations.Data.BitString.List.BinaryOrder

Binary values, prefixes and the order of words #

Facts relating the most-significant-first value Cslib.BitString.binaryValue of a word to concatenation, prefixes and the lexicographic order of words of equal length.

Main definitions #

Main results #

The value of a concatenation: the first word is shifted by the length of the second.

The value of a word with a leading bit.

Padding a word with k ones: the value plus one is multiplied by 2 ^ k.

On words of equal length, the numeric order of binaryValue is the strict lexicographic order (with false < true).

On words of equal length, the numeric order of binaryValue is the lexicographic order (with false < true).

Prefix blocks. Among words of length at least |h|, the words with prefix h are those whose value lies in [v(h) 2^(N-|h|), (v(h) + 1) 2^(N-|h|)), for N their length.

The word of the same length as x whose value is one less (x itself when its value is 0).

@[simp]

An all-false binary word has value 0.

@[simp]

Re-encoding a word's binaryValue at its own width recovers the word.

@[simp]

Zero padded to width L is List.replicate L false.

Adding 1 to a big-endian word flips trailing false :: true^k to true :: false^k.

theorem Cslib.BitString.exists_carry_cut {w : List Bool} (h : binaryValue w + 1 < 2 ^ w.length) :
∃ (u : List Bool) (k : ℕ), w = u ++ false :: List.replicate k true

Every non-maximal big-endian word ends with false followed by trues.

theorem Cslib.BitString.carry_cut_unique {u u' : List Bool} {k k' : ℕ} (h : u ++ false :: List.replicate k true = u' ++ false :: List.replicate k' true) :
u = u' ∧ k = k'

Uniqueness of the decomposition u ++ false :: true^k before the rightmost false.