Documentation

Complexity.Algorithms.WordRAM.ThreeSum.ChanHe.CountPlace

A complete native counting and placement call #

This routine actually computes the residues and histogram before extracting a heavy array and placing the corresponding packed column. The histogram is not a premise of the execution contract. It also writes the compact output count to its caller-supplied descriptor cell.

Main definitions #

References #

This native composition is original and reuses the existing Chan–He mathematical definitions.

@[reducible, inline]

Input length (the selected third argument of the existing counting call).

Instances For
    @[reducible, inline]

    Signed input base.

    Instances For
      @[reducible, inline]

      Unsigned residue workspace base.

      Instances For
        @[reducible, inline]

        Histogram workspace base.

        Instances For
          @[reducible, inline]

          Compact heavy output base.

          Instances For
            @[reducible, inline]

            Packed node array base.

            Instances For
              @[reducible, inline]

              Positive modulus, decoded unsigned.

              Instances For
                @[reducible, inline]

                Encoded positive tag.

                Instances For
                  @[reducible, inline]

                  Packed column.

                  Instances For
                    @[reducible, inline]

                    Distance between the two stores.

                    Instances For
                      @[reducible, inline]

                      Zero for X/Y, one for Z.

                      Instances For
                        @[reducible, inline]

                        Cell in which the exact heavy count is stored.

                        Instances For

                          Fixed embedding of the placement workspace below all caller parameters.

                          Instances For
                            @[reducible, inline]

                            Input array base.

                            Instances For
                              @[reducible, inline]

                              Unsigned residue array base.

                              Instances For
                                @[reducible, inline]

                                Input length.

                                Instances For
                                  @[reducible, inline]

                                  Histogram base.

                                  Instances For
                                    @[reducible, inline]

                                    Compact heavy output base.

                                    Instances For
                                      @[reducible, inline]

                                      Packed node output base.

                                      Instances For
                                        @[reducible, inline]

                                        Positive modulus, decoded unsigned.

                                        Instances For
                                          @[reducible, inline]

                                          Twice the positive tag added to a light integer.

                                          Instances For
                                            @[reducible, inline]

                                            Column in a four-cell group.

                                            Instances For
                                              @[reducible, inline]

                                              Distance to the second write: zero for X/Y, 4M for Z.

                                              Instances For
                                                @[reducible, inline]

                                                Zero for X/Y, one for Z.

                                                Instances For
                                                  @[reducible, inline]

                                                  Number of heavy integers already written.

                                                  Instances For

                                                    All eleven runtime argument copies are real instructions.

                                                    Instances For

                                                      Complete fixed native routine: no host histogram, heavy filter or output constructor.

                                                      Instances For

                                                        Only the counting/placement workspace, the encoded modulus, and the discarded collision counter can change. All caller registers at least 46 are included in this frame.

                                                        Polynomial envelope for addresses, counters, encoded magnitudes and every scan intermediate.

                                                        Instances For
                                                          def Cslib.Algorithms.WordRAM.ThreeSum.ChanHe.CountPlace.memory (mem : ℕ → ℕ) (values : ℕ → ℤ) (n M out dst col dist t scratch hist descriptor : ℕ) (neg : Bool) :
                                                          ℕ → ℕ

                                                          Exact memory, including actual residue/histogram construction and the descriptor write.

                                                          Instances For
                                                            theorem Cslib.Algorithms.WordRAM.ThreeSum.ChanHe.CountPlace.exec {w M N U t : ℕ} (x : WordRAM.Data 64) (values : ℕ → ℤ) (neg : Bool) (hM : 0 < M) (hmod : GenericRAM.Signed.Fits w ↑M) (hmreg : x.regs modulus = M) (hN : 2 * M ≤ N) (ht : U ≤ t) (htag : x.regs tag = 2 * t) (hneg : x.regs negative = if neg = true then 1 else 0) (hc : x.regs column < 4) (hd : x.regs distance ≤ 4 * M) (hbdd : ∀ i < x.regs len, (values i).natAbs ≤ U) (hsigned : ∀ i < x.regs len, GenericRAM.Signed.Fits w (values i)) (hfit : WordRAM.Fits (w + 2) (budget x M N U t)) (hsh : x.regs src + x.regs len ≤ x.regs heavy) (hhp : x.regs heavy + x.regs len ≤ x.regs packed) (hpk : x.regs packed + 4 * N ≤ x.regs scratch) (hkh : x.regs scratch + x.regs len ≤ x.regs hist) (hinput : ∀ i < x.regs len, x.mem (x.regs src + i) = WordRAM.Signed.encode (values i)) (hinj : Set.InjOn values ↑(Finset.range (x.regs len))) :
                                                            ∃ (y : WordRAM.Data 64), WordRAM.ExecWithin (w + 2) program x y (66 * x.regs len + 5 * M + 45) ∧ y.mem = memory x.mem values (x.regs len) M (x.regs heavy) (x.regs packed) (x.regs column) (x.regs distance) t (x.regs scratch) (x.regs hist) (x.regs descriptor) neg ∧ ∀ (i : Fin 64), 32 ≤ ↑i → i ≠ CountCall.modulus → i ≠ CountCall.result 2 → y.regs i = x.regs i

                                                            Complete native count/extract/place execution, charging modulus encoding, all subroutine argument/result copies and the final count write. The caller supplies actual signed input words; no histogram or light/heavy-output contract is assumed.