Documentation

Complexity.Algorithms.WordRAM.MatrixMultiplication.Schonhage.Wanted.Program

Native routing and stable grouping of wanted positions #

The initialized input contains only L,m,N,Q and Q ordinary row/column pairs. The code computes the valid-mask tables, band parameters, tile counts, prefix offsets and scatter positions. Each scatter writes the unchanged pruned-query code and its original position. No sorted request list, layout certificate or dispatch decision is supplied as input.

Main definitions #

These programs use only the existing standard unsigned instructions. Correctness, width, frame and resource theorems are separate from the definitions. Supporting exec_* lemmas are internal implementation APIs exported across proof modules; consumers use runs, runs_grouped or the generic-memory exec_program when composing a caller.

References #

The routing goal comes from [AlmanWilliams2026, Section 2.4.4] and Anthropic's pinned Wanted/Codes.lean at revision 16a5ce41304fcdaea4e0be7c132e1c361dc26da5. This is original native code with its own charged proofs, using the existing finite output-string definitions. It does not import the source Light machine, its sorting procedure or its instruction counts.

Register embedding for the unchanged sixteen-register digit packer.

Instances For
    @[reducible, inline]

    Original row of the current query.

    Instances For
      @[reducible, inline]

      Original column of the current query.

      Instances For
        @[reducible, inline]

        Computed row band.

        Instances For
          @[reducible, inline]

          Computed column band.

          Instances For
            @[reducible, inline]

            Row-major tile key.

            Instances For
              @[reducible, inline]

              Address of the first original row/column pair.

              Instances For
                @[reducible, inline]

                Number of original query positions, including duplicates.

                Instances For
                  @[reducible, inline]

                  Current original query position or tile position.

                  Instances For
                    @[reducible, inline]

                    Tile-count array base.

                    Instances For
                      @[reducible, inline]

                      Prefix-offset array base, with one additional terminal cell.

                      Instances For
                        @[reducible, inline]

                        Current stable-scatter cursor array base.

                        Instances For
                          @[reducible, inline]

                          Grouped query-code array base.

                          Instances For
                            @[reducible, inline]

                            Grouped original-position array base.

                            Instances For
                              @[reducible, inline]

                              Current tile's query count.

                              Instances For
                                @[reducible, inline]

                                Running prefix sum.

                                Instances For
                                  @[reducible, inline]

                                  Number of tiles.

                                  Instances For
                                    @[reducible, inline]

                                    Number of original positions in one band.

                                    Instances For
                                      @[reducible, inline]

                                      One past the readonly initialized query input.

                                      Instances For
                                        @[reducible, inline]

                                        One past the grouping arrays.

                                        Instances For
                                          @[reducible, inline]

                                          Address scratch.

                                          Instances For
                                            @[reducible, inline]

                                            Saved address of the current scatter cursor.

                                            Instances For
                                              @[reducible, inline]

                                              Current grouped output position.

                                              Instances For

                                                Compute just the row-major tile key. No memory is touched.

                                                Instances For

                                                  Compute the selected subset rank and load its actual mask from the computed table.

                                                  Instances For

                                                    Compute a tile key and its output code, with actual digit decisions and table load.

                                                    Instances For

                                                      Relocate the computed tables and every grouping array after the initialized input.

                                                      Instances For

                                                        Load one original pair without changing its input words.

                                                        Instances For

                                                          Count one input position in its actual tile, retaining duplicates.

                                                          Instances For

                                                            Store both the immutable prefix offset and the initial scatter cursor of one tile.

                                                            Instances For

                                                              Compute exact tile spans, including the terminal offset after the last tile.

                                                              Instances For

                                                                Append one code and original position to its tile, advancing the actual cursor.

                                                                Instances For

                                                                  Recompute one query's code and scatter it stably into its counted tile.

                                                                  Instances For

                                                                    The second original-order scan retains every occurrence and its original position.

                                                                    Instances For

                                                                      Complete initialized native routing; no mathematical layout is an input word.

                                                                      Instances For