Documentation

Complexity.Algorithms.WordRAM.ThreeSum.Frontend.Select

Native selection of canonical signed keys #

All arithmetic is unsigned. The sign bit and magnitude are decoded explicitly, the label is formed by addition or subtraction, and its two digits are computed with native shifts and remainders. The repeated-value case doubles the key and subtracts its original sign bit.

Main definitions #

@[reducible, inline]

Magnitude bound, followed by two bit positions, selected digit and scan mode.

Instances For
    @[reducible, inline]

    Magnitude bound, followed by two bit positions, selected digit and scan mode.

    Instances For
      @[reducible, inline]

      Magnitude bound, followed by two bit positions, selected digit and scan mode.

      Instances For
        @[reducible, inline]

        Magnitude bound, followed by two bit positions, selected digit and scan mode.

        Instances For
          @[reducible, inline]

          Magnitude bound, followed by two bit positions, selected digit and scan mode.

          Instances For
            @[reducible, inline]

            Input key; replaced by its selected output value.

            Instances For
              @[reducible, inline]

              Full input multiplicity, read without truncation.

              Instances For
                @[reducible, inline]

                Small constants installed by the scan.

                Instances For
                  @[reducible, inline]

                  Small constants installed by the scan.

                  Instances For
                    @[reducible, inline]

                    Small constants installed by the scan.

                    Instances For
                      @[reducible, inline]

                      Small constants installed by the scan.

                      Instances For
                        @[reducible, inline]

                        Small constants installed by the scan.

                        Instances For
                          @[reducible, inline]

                          Small constants installed by the scan.

                          Instances For
                            @[reducible, inline]

                            Scratch registers for decoding and label digits.

                            Instances For
                              @[reducible, inline]

                              Scratch registers for decoding and label digits.

                              Instances For
                                @[reducible, inline]

                                Scratch registers for decoding and label digits.

                                Instances For
                                  @[reducible, inline]

                                  Scratch registers for decoding and label digits.

                                  Instances For
                                    @[reducible, inline]

                                    Selection flag, either zero or one.

                                    Instances For
                                      @[reducible, inline]

                                      Magnitude temporary.

                                      Instances For

                                        Explicit native sign/magnitude decoding, shifted label and binary digit computation.

                                        Instances For

                                          A no-op used by unsuccessful selections.

                                          Instances For

                                            Select one of the six finite scan modes and perform the repeated-value transformation.

                                            Instances For

                                              Every decoding, arithmetic, branch and selection instruction is part of this code.

                                              Instances For

                                                This scalar program never reads the physical word width.

                                                Registers below the decoding scratch are preserved by label calculation.

                                                Selection preserves all caller parameters, constants and scan registers.

                                                Decoding and both binary digits cost at most eleven native instructions.

                                                theorem Cslib.Algorithms.WordRAM.ThreeSum.Frontend.Select.choose_exec {w : ℕ} (x : WordRAM.Data 48) (hz : x.regs zero = 0) (h1 : x.regs one = 1) (h2 : x.regs two = 2) (h3 : x.regs three = 3) (h4 : x.regs four = 4) (h5 : x.regs five = 5) (hs : x.regs sign = x.regs key % 2) (hfit : WordRAM.Fits w (2 * x.regs key)) (hsmall : WordRAM.Fits w 5) :

                                                Selection from already computed digits, with the full repeated-value count.

                                                theorem Cslib.Algorithms.WordRAM.ThreeSum.Frontend.Select.exec {w : ℕ} (x : WordRAM.Data 48) (hz : x.regs zero = 0) (h1 : x.regs one = 1) (h2 : x.regs two = 2) (h3 : x.regs three = 3) (h4 : x.regs four = 4) (h5 : x.regs five = 5) (hkey : WordRAM.Fits w (x.regs key)) (habs : x.regs key / 2 ≤ 2 * x.regs magnitude) (hfit : WordRAM.Fits w (4 * x.regs magnitude + 2)) (hdouble : WordRAM.Fits w (2 * x.regs key)) (hsmall : WordRAM.Fits w 5) :

                                                Complete native scalar selection. Its cost includes decoding, both label bits and doubling.