Documentation

CodeLayer.BitStringPrimrec

Bit-strings as naturals, and their primitive recursiveness #

The bijection between bit-strings and natural numbers, and the computability of the layer built on it.

What this establishes #

What this does NOT establish (flagged) #

A bit-string / natural bijection #

Bit-strings as naturals, most-significant-bit first: the number whose binary digits are 1 :: p, less one. [] ↦ 0.

Equations
Instances For
    @[irreducible]

    The inverse of bitsToNat: the bits of n + 1, most-significant-bit first, with the leading 1 dropped. Well-founded recursion, peeling the low bit at each step.

    Equations
    Instances For

      natToBits, bitsToNat are primitive recursive #

      One step of peeling natToBits's low bit: idle once the state has bottomed out at 0, otherwise move to the smaller state and cons the peeled bit onto the accumulator.

      Equations
      Instances For

        natToBits by fuel: peel the low bit of m + 1 and cons it, fuel times, over the state (m, acc) starting at (n, []).

        Equations
        Instances For

          Prefix of one bit-string by another: p <+: q ↔ List.take p.length q = p.

          theorem PrefixMachine.primrec_mem_list :
          PrimrecRel fun (L : List ℕ) (n : ℕ) => n ∈ L

          List membership is a PrimrecRel.