Documentation

Complexity.Algorithms.WordRAM.FusionTree.Compress

Checked mask-and-multiply compression #

The multiplier is supplied as three precomputed half-word digits. The query arrives as one physical word: masking and conversion to digits are part of the charged execution. The retained window fits inside the third product digit, including at odd physical widths.

Main definitions #

Main results #

Node preprocessing and loading the constants are separate from query execution.

References #

Embed the multiplication workspace in the first sixteen registers.

Instances For
    @[reducible, inline]

    Query word, preserved.

    Instances For
      @[reducible, inline]

      Input position mask, preserved.

      Instances For
        @[reducible, inline]

        Retained output mask, preserved.

        Instances For
          @[reducible, inline]

          Offset w - 2 * (w / 2), supplied by the caller and preserved.

          Instances For
            @[reducible, inline]

            Conversion scratch and final compressed result.

            Instances For
              @[reducible, inline]

              Half-word radix workspace.

              Instances For
                @[reducible, inline]

                Lowest query digit.

                Instances For
                  @[reducible, inline]

                  Middle query digit.

                  Instances For
                    @[reducible, inline]

                    Highest query digit.

                    Instances For
                      @[reducible, inline]

                      Third product digit, containing the retained window.

                      Instances For

                        Mask the query and split it using division and remainder by the half-word radix. No squared radix is ever installed in a physical register.

                        Instances For

                          The exact data after query conversion, with an already initialized radix.

                          Instances For
                            theorem Cslib.Algorithms.WordRAM.FusionTree.CompressProgram.window_eq {w L p D : ℕ} (hL : L + (w - 2 * (w / 2)) ≤ w / 2) (hD : D < 2 ^ L) :

                            A masked window inside the third half-word digit depends only on that digit.

                            theorem Cslib.Algorithms.WordRAM.FusionTree.CompressProgram.exists_multiplier_digits {w L M : ℕ} (hL : L + (w - 2 * (w / 2)) ≤ w / 2) (hM : M < 2 ^ (w + L)) :
                            ∃ (digits : Fin 3 → ℕ), (∀ (i : Fin 3), digits i < WordRAM.Multiword.radix w) ∧ Nat.ofDigits (WordRAM.Multiword.radix w) (List.ofFn digits) = M

                            A multiplier of at most w + L bits has three bounded half-word digits whenever the retained window fits. This is a preprocessing representation theorem; loading is separate.

                            Initialize the radix, convert the query, multiply three digits by three digits, and extract the retained window. Registers 7--9 contain the precomputed multiplier digits.

                            Instances For
                              theorem Cslib.Algorithms.WordRAM.FusionTree.CompressProgram.exec {w L M : ℕ} (hw : 2 ≤ w) (x : WordRAM.Data 21) (hx : WordRAM.Fits w (x.regs query)) (hb : WordRAM.Multiword.Bounded (WordRAM.Multiword.radix w) (WordRAM.Data.comap embed x) (WordRAM.Multiword.Schoolbook.rightRegs 3 3)) (hM : WordRAM.Multiword.value (WordRAM.Multiword.radix w) (WordRAM.Data.comap embed x) (WordRAM.Multiword.Schoolbook.rightRegs 3 3) = M) (ho : x.regs offset = w - 2 * (w / 2)) (hD : x.regs retained < 2 ^ L) (hL : L + (w - 2 * (w / 2)) ≤ w / 2) :
                              ∃ (y : WordRAM.Data 21), WordRAM.Exec w code x y 94 ∧ y.regs out = ((x.regs query &&& x.regs positions) * M) >>> w &&& x.regs retained ∧ y.mem = x.mem ∧ ∀ (i : Fin 21), 7 ≤ ↑i ∧ ↑i < 10 ∨ 16 ≤ ↑i ∧ ↑i < 20 → y.regs i = x.regs i

                              In 94 checked standard instructions, compute the masked product window. The query and all node parameters are preserved, as is memory. Only registers 0--6, 10--15 and 20 may change. Multiplier digits in registers 7--9 must be preloaded; conversion of the physical query word is charged. The retained mask occupies L bits and satisfies the stated half-word window condition.

                              Specialize the actual execution to the arithmetic approximate sketch. The collision-free parameter construction and comparison theorem are independent of this execution theorem. The caller supplies the position and retained masks and three multiplier digits.