Documentation

Complexity.Computability.Machines.Turing.MultiTape.Encodings.Nat.Bits

Binary natural encoding and digit algorithms #

The encoding and the carry, borrow and normalization word folds are independent of resource certificates. Their original definitions and arithmetic correctness proofs are retained here.

Natural numbers encoded by their binary digits, least significant first.

Instances For

    Adds the carry c to the binary digits l, least significant first.

    Instances For

      One round: add the carry to the digit b, append the resulting digit and keep the carry.

      Instances For

        Appends the final carry digit.

        Instances For
          @[reducible, inline]

          The encoding of the accumulator: the carry and the digits so far.

          Instances For

            Subtracts a borrow from the binary digits l, least significant first, keeping a leading zero.

            Instances For

              Drops a leading zero, the last digit.

              Instances For
                theorem Turing.MultiTapeTM.NatPred.norm_cons {l : List Bool} (hl : l ≠ []) (b : Bool) :
                norm (b :: l) = b :: norm l

                One round of the decrement: subtract the borrow from the digit b, append the result and keep the borrow.

                Instances For

                  One round of dropping a leading zero: append the pending digit and keep the new one.

                  Instances For

                    Appends the pending digit unless it is a zero.

                    Instances For