Documentation

Complexitylib.Models.TuringMachine.UTM.Internal.Bits

Fixed-width binary roundtrips #

Nat.fromBits_toBits (in Encoding.lean) inverts one way; here we prove the other direction — Nat.toBits recovers any bit list of the right width from its value — and the resulting injectivity of Nat.fromBits on fixed-width lists. The universal machine compares state fields symbol-wise while the abstract table lookup compares their decoded numbers; these lemmas make the two agree.

theorem Complexity.Nat.toBits_add_pow_mul (w val c : ) :
w.toBits (val + c * 2 ^ w) = w.toBits val

Adding multiples of 2^w does not change the low w bits.

Nat.toBits is a left inverse of Nat.fromBits at the list's width.

Nat.fromBits is injective on lists of equal width.