Documentation

Complexity.Computability.WordRAM.Copy

Copying disjoint arrays on the word RAM #

The seven-register copy routine charges every address calculation, load, store, increment, and loop test. Its source precedes its destination, as in a bump-allocated growing array. It is a fixed program: neither the length nor either address is baked into the code.

Main definitions #

Main results #

References #

def Cslib.WordRAM.ArrayCopy.copyPrefix (mem : ℕ → ℕ) (src dst k : ℕ) :
ℕ → ℕ

The memory after copying a prefix into a disjoint destination block.

Instances For
    @[simp]
    theorem Cslib.WordRAM.ArrayCopy.copyPrefix_zero (mem : ℕ → ℕ) (src dst : ℕ) :
    copyPrefix mem src dst 0 = mem
    theorem Cslib.WordRAM.ArrayCopy.copyPrefix_read {mem : ℕ → ℕ} {src dst k j : ℕ} (hj : j < k) :
    copyPrefix mem src dst k (dst + j) = mem (src + j)
    theorem Cslib.WordRAM.ArrayCopy.copyPrefix_outside {mem : ℕ → ℕ} {src dst k a : ℕ} (ha : ¬(dst ≤ a ∧ a < dst + k)) :
    copyPrefix mem src dst k a = mem a
    theorem Cslib.WordRAM.ArrayCopy.copyPrefix_succ (mem : ℕ → ℕ) (src dst k : ℕ) :
    copyPrefix mem src dst (k + 1) = Function.update (copyPrefix mem src dst k) (dst + k) (mem (src + k))
    @[reducible, inline]

    Source base, destination base, length, index, temporary address, value, and one.

    Instances For
      @[reducible, inline]

      Destination base.

      Instances For
        @[reducible, inline]

        Number of words.

        Instances For
          @[reducible, inline]

          Loop index.

          Instances For
            @[reducible, inline]

            Temporary address.

            Instances For
              @[reducible, inline]

              Temporary value.

              Instances For
                @[reducible, inline]

                Constant one.

                Instances For

                  Five data instructions per copied word.

                  Instances For

                    A fixed copying program with all three parameters in registers.

                    Instances For
                      theorem Cslib.WordRAM.ArrayCopy.exec {w : ℕ} (x : Data 7) (h1 : Fits w 1) (hs : Fits w (x.regs src + x.regs len)) (hd : Fits w (x.regs dst + x.regs len)) (hdisj : x.regs src + x.regs len ≤ x.regs dst) :
                      ∃ (y : Data 7), ExecWithin w program x y (7 * x.regs len + 4) ∧ y.mem = copyPrefix x.mem (x.regs src) (x.regs dst) (x.regs len) ∧ y.regs src = x.regs src ∧ y.regs dst = x.regs dst ∧ y.regs len = x.regs len

                      Low-level structured copying charges register setup and all loop instructions, excluding the final halt. The one-past-end addresses must fit a word. Boundedness of the input memory and registers is a separate premise when using ExecWithin.bounded to obtain bounded-word execution.