Documentation

CslibFrontier.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.

@[reducible, inline]

Original row of the current query.

@[reducible, inline]

Original column of the current query.

@[reducible, inline]

Computed column band.

@[reducible, inline]

Row-major tile key.

@[reducible, inline]

Address of the first original row/column pair.

@[reducible, inline]

Number of original query positions, including duplicates.

@[reducible, inline]

Current original query position or tile position.

@[reducible, inline]

Tile-count array base.

@[reducible, inline]

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

@[reducible, inline]

Current stable-scatter cursor array base.

@[reducible, inline]

Grouped query-code array base.

@[reducible, inline]

Grouped original-position array base.

@[reducible, inline]

Current tile's query count.

@[reducible, inline]

Number of original positions in one band.

@[reducible, inline]

One past the readonly initialized query input.

@[reducible, inline]

One past the grouping arrays.

@[reducible, inline]

Saved address of the current scatter cursor.

@[reducible, inline]

Current grouped output position.

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

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

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

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

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

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

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

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

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

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