Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Encodings.Nat

The successor, predecessor and zero test in binary #

encNat, reexported from Encodings.Nat.Bits, encodes a natural number by its binary digits, least significant first (Nat.bits). Each of the three counter operations is computed by one streaming transducer that reads its input once and uses no work tape:

Main results #

@[reducible, inline]

The framed binary encoding of triples of natural numbers.

Instances For
    theorem Turing.MultiTapeTM.computableInTimeAndSpace_succ :
    ComputableInTimeAndSpace (fun (x : ℕ) => x + 1) encNat encNat (fun (n : ℕ) => 2 * (encNat n).length + 3) fun (x : ℕ) => 0

    Binary successor in linear time and zero work space. One streaming transducer computes n + 1 from encNat n within 2 * (encNat n).length + 3 steps without work tapes.

    Binary successor in linear time and work space, from computableInTimeAndSpace_succ.

    theorem Turing.MultiTapeTM.computableInTimeAndSpace_pred :
    ComputableInTimeAndSpace (fun (x : ℕ) => x - 1) encNat encNat (fun (n : ℕ) => 2 * (encNat n).length + 3) fun (x : ℕ) => 0

    Binary predecessor in linear time and zero work space. One streaming transducer computes n - 1 (so 0 ↦ 0) from encNat n within 2 * (encNat n).length + 3 steps without work tapes.

    Binary predecessor in linear time and work space, from computableInTimeAndSpace_pred.

    theorem Turing.MultiTapeTM.computableInTimeAndSpace_isZero :
    ComputableInTimeAndSpace (fun (n : ℕ) => decide (n = 0)) encNat encBool (fun (n : ℕ) => 2 * (encNat n).length + 3) fun (x : ℕ) => 0

    Binary zero test in linear time and zero work space. One streaming transducer decides n = 0 from encNat n within 2 * (encNat n).length + 3 steps without work tapes.

    Binary zero test in linear time and work space, from computableInTimeAndSpace_isZero.