Documentation

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

The successor in binary #

encNat encodes a natural number by its binary digits, least significant first (Nat.bits). The successor is a left fold over the digits that keeps a carry and appends one digit per round, followed by a final carry digit. Its tidy computability is derived from that of the fold (Turing.MultiTapeTM.ComputableTidilyInTimeAndSpace.foldl) and of the parts of a round.

Main definitions #

Main results #

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

            A round is tidily computable in linear time and space.

            theorem Turing.MultiTapeTM.computableTidilyInTimeAndSpace_succ :
            ∃ (c : ℕ), ComputableTidilyInTimeAndSpace (fun (x : ℕ) => x + 1) encNat encNat (fun (n : ℕ) => c * ((encNat n).length + 1) ^ 2) fun (n : ℕ) => c * ((encNat n).length + 1)

            The successor is tidily computable in quadratic time and linear space, in the binary encoding encNat.