Documentation

Complexity.Computability.WordRAM.Multiword.Workspace

Shared workspace for multiword operations #

Register zero stores an arithmetic total, register one a carry, register two the half-word radix, and register three a preserved zero. All operand digits lie outside this workspace. Multiplication, transfers, bitwise operations and shifts share this layout.

Main definitions #

Main results #

@[reducible, inline]

Arithmetic total and partial-sum workspace.

Instances For
    @[reducible, inline]

    Carry workspace.

    Instances For
      @[reducible, inline]

      Half-word radix.

      Instances For
        @[reducible, inline]

        A preserved zero, used for padding and shifts.

        Instances For

          Registers outside the four reserved workspace registers.

          Instances For

            Digit registers are disjoint from the four reserved workspace registers.

            def Cslib.WordRAM.Multiword.Workspace.Frame {r : ℕ} (x y : Data (r + 4)) (ds : List (Fin (r + 4))) :

            A routine changes only its destination digits and the total and carry workspace.

            Instances For
              theorem Cslib.WordRAM.Multiword.Workspace.frame_mono {r : ℕ} {x y : Data (r + 4)} {ds es : List (Fin (r + 4))} (h : Frame x y ds) (hsub : ds ⊆ es) :
              Frame x y es

              Enlarging the destination set weakens the preservation requirement.

              theorem Cslib.WordRAM.Multiword.Workspace.frame_trans {r : ℕ} {x y z : Data (r + 4)} {ds : List (Fin (r + 4))} (h : Frame x y ds) (h' : Frame y z ds) :
              Frame x z ds

              Two routines with the same frame compose.

              Compute the half-word radix and a preserved zero in six standard instructions.

              Instances For
                def Cslib.WordRAM.Multiword.Workspace.setupResult {r : ℕ} (w : ℕ) (x : Data (r + 4)) :
                Data (r + 4)

                Exact workspace contents after initialization.

                Instances For
                  theorem Cslib.WordRAM.Multiword.Workspace.exec_setup {r w : ℕ} (hw : 2 ≤ w) (x : Data (r + 4)) :
                  Exec w setup x (setupResult w x) 6

                  Initialization executes in exactly six instructions for every width at least two.

                  theorem Cslib.WordRAM.Multiword.Workspace.setup_digit {r : ℕ} (w : ℕ) (x : Data (r + 4)) {i : Fin (r + 4)} (hi : IsDigit i) :
                  (setupResult w x).regs i = x.regs i

                  Initialization preserves every register outside the reserved workspace.