Documentation

Complexity.Algorithms.WordRAM.ExactTriangle.ChunkCatalogue

Native enumeration of all query chunks #

The controller reads the actual class-count table produced by Classes.program and calls the existing native chunk writer for each class. Descriptors are concatenated without padding; their query pointers refer to the original disjoint class arrays. No descriptor layout or prefix table is supplied by the caller.

This composes the class and chunk loops in the pinned Theorem 17 construction.

Main definitions #

Main results #

@[reducible, inline]

Class-count table pointer.

Instances For
    @[reducible, inline]

    Base of the class query blocks, each of capacity 2n² words.

    Instances For
      @[reducible, inline]

      Matrix side length.

      Instances For
        @[reducible, inline]

        Number of residue classes.

        Instances For
          @[reducible, inline]

          Beginning of the contiguous output descriptor array.

          Instances For
            @[reducible, inline]

            Positive maximum pairs per chunk.

            Instances For
              @[reducible, inline]

              Current class.

              Instances For
                @[reducible, inline]

                Total number of descriptors written so far.

                Instances For
                  @[reducible, inline]

                  First free descriptor address.

                  Instances For
                    @[reducible, inline]

                    Constant one.

                    Instances For
                      @[reducible, inline]

                      Number of words per descriptor.

                      Instances For
                        @[reducible, inline]

                        Current count-table address.

                        Instances For
                          @[reducible, inline]

                          Capacity of one class query block, in words.

                          Instances For
                            @[reducible, inline]

                            Descriptor-length temporary.

                            Instances For
                              @[reducible, inline]

                              Query pointer passed to the chunk writer.

                              Instances For
                                @[reducible, inline]

                                Output pointer passed to the chunk writer.

                                Instances For
                                  @[reducible, inline]

                                  Loaded class count passed to the chunk writer.

                                  Instances For
                                    @[reducible, inline]

                                    Chunk capacity passed to the chunk writer.

                                    Instances For
                                      @[reducible, inline]

                                      Residue passed to the chunk writer.

                                      Instances For
                                        @[reducible, inline]

                                        Number of descriptors returned by the chunk writer.

                                        Instances For

                                          Call the existing native chunk writer in the lower register bank.

                                          Instances For

                                            Read the current count and deliver its actual query pointer to the chunk writer.

                                            Instances For

                                              Advance the output heap by the number of descriptors actually written.

                                              Instances For

                                                Initialize the concatenation cursor and run every residue class.

                                                Instances For

                                                  The complete controller is fixed code and does not inspect physical width.

                                                  Number of actual chunk descriptors for all classes strictly below rho.

                                                  Instances For
                                                    theorem Cslib.Algorithms.WordRAM.ExactTriangle.ChunkCatalogue.before_add_lt (C : ℕ → ℕ) (cap : ℕ) {rho p k : ℕ} (hrho : rho < p) (hk : k < C rho ⌈/⌉ cap) :
                                                    before C cap rho + k < before C cap p

                                                    Every actual chunk lies strictly within the concatenated descriptor array.

                                                    theorem Cslib.Algorithms.WordRAM.ExactTriangle.ChunkCatalogue.before_index (C : ℕ → ℕ) (cap p i : ℕ) (hi : i < before C cap p) :
                                                    ∃! idx : (rho : Fin p) × Fin (C ↑rho ⌈/⌉ cap), i = before C cap ↑idx.fst + ↑idx.snd

                                                    Every occupied descriptor slot names exactly one class and one chunk. This is the existing finSigmaFinEquiv, expressed with the same prefix sum as the native concatenation loop.

                                                    theorem Cslib.Algorithms.WordRAM.ExactTriangle.ChunkCatalogue.before_le {C : ℕ → ℕ} {cap p N : ℕ} (hcap : 0 < cap) (hC : ∀ r < p, C r ≤ N) {rho : ℕ} (hrho : rho ≤ p) :
                                                    before C cap rho ≤ rho * N

                                                    At most N queries per class give at most rho * N occupied descriptors, since every nonempty chunk contains at least one query. This bounds the actual allocation before matrix preparation as well as the descriptor controller's own arithmetic.

                                                    theorem Cslib.Algorithms.WordRAM.ExactTriangle.ChunkCatalogue.exec {w : ℕ} (x : WordRAM.Data 32) (C : ℕ → ℕ) (hread : ∀ r < x.regs modulus, x.mem (x.regs counts + r) = C r) (hC : ∀ r < x.regs modulus, C r ≤ x.regs size * x.regs size) (hcap : 0 < x.regs capacity) (hcounts : x.regs counts + x.regs modulus ≤ x.regs dst) (hqueries : x.regs queries + 2 * x.regs modulus * (x.regs size * x.regs size) ≤ x.regs dst) (hfit : WordRAM.Fits w (x.regs dst + 5 * x.regs modulus * (x.regs size * x.regs size) + x.regs counts + x.regs modulus + x.regs queries + 2 * (x.regs size * x.regs size) + 5)) :
                                                    ∃ (y : WordRAM.Data 32), WordRAM.ExecWithin w program x y (x.regs modulus * (17 * (x.regs size * x.regs size) + 20) + 9) ∧ y.regs written = before C (x.regs capacity) (x.regs modulus) ∧ y.regs heap = x.regs dst + 3 * y.regs written ∧ (∀ (i : Fin 32), 14 ≤ ↑i → ↑i < 20 → y.regs i = x.regs i) ∧ (∀ r < x.regs modulus, ∀ k < C r ⌈/⌉ x.regs capacity, y.mem (x.regs dst + 3 * (before C (x.regs capacity) r + k)) = r ∧ y.mem (x.regs dst + 3 * (before C (x.regs capacity) r + k) + 1) = x.regs queries + 2 * r * (x.regs size * x.regs size) + 2 * (k * x.regs capacity) ∧ y.mem (x.regs dst + 3 * (before C (x.regs capacity) r + k) + 2) = min (x.regs capacity) (C r - k * x.regs capacity)) ∧ ∀ (a : ℕ), ¬(x.regs dst ≤ a ∧ a < x.regs dst + 3 * y.regs written) → y.mem a = x.mem a

                                                    Read the actual count table and concatenate every class's nonempty chunks. The controller receives no prefix sums. Both source blocks lie before dst; all other memory is preserved. The charged bound excludes halt.