Documentation

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

The existing binary long-division word algorithm #

The public step, quotient/remainder laws and prefix encoding bound are moved unchanged from the higher division facade, independently of any higher computability calculus.

One shift-and-subtract step of binary long division with divisor b, state (q, r), and next most-significant dividend bit bit. When b = 0, the quotient remains 0 and the remainder accumulates the binary value of the dividend.

Instances For
    theorem Turing.MultiTapeTM.BinaryDiv.divModStep_div_mod (v b : ℕ) (bit : Bool) :
    divModStep b (v / b, v % b) bit = ((2 * v + bit.toNat) / b, (2 * v + bit.toNat) % b)

    Folding divModStep over any most-significant-first bit word computes the quotient and remainder of Cslib.BitString.binaryValue word by b.

    Folding divModStep over the reversed binary digits of p.1 computes (p.1 / p.2, p.1 % p.2).

    The encoded state after folding word has length at most 3 * word.length + 1.