Documentation

MIPRE.Foundations.Cost.BinaryArithmetic

Canonical binary arithmetic #

The parameter algorithms use binary integers, even when their values are much larger than the available work space. These programs manipulate binary digits directly. In particular, converting a bit string to a natural number normalizes its encoding without expanding its value to unary.

Prepend a digit, suppressing the noncanonical representation of zero.

Equations
  • One or more equations did not get rendered due to their size.
Instances For

    Read and normalize an arbitrary little-endian bit string.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      Binary borrow, used on the nonzero canonical representation.

      Equations
      Instances For
        theorem MIPRE.Cost.split_bits_of_ne_zero (n : ℕ) (hn : n ≠ 0) :
        ∃ (j : ℕ) (rest : List Bool), n.bits = List.replicate j false ++ true :: rest

        The existing borrow machine, with its missing zero case supplied. Its output need not be canonical; bitsValue subsequently normalizes it.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          theorem MIPRE.Cost.fold_addUnary (u : Unary) (n : ℕ) :
          List.foldl (fun (k : ℕ) (x : Unit) => k + 1) n u = n + List.length u

          Add a unary offset to a binary integer.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            theorem MIPRE.Cost.fold_subUnary (u : Unary) (n : ℕ) :
            List.foldl (fun (k : ℕ) (x : Unit) => k - 1) n u = n - List.length u

            Subtract a unary offset from a binary integer, saturating at zero. The intermediate values are bounded by the initial integer, in binary size.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For