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 #
Wanted.routeCode: compute one tile and one query code using the computed table.Wanted.program: computed tables followed by counting, prefix and stable scatter passes.
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.
Original row of the current query.
Original column of the current query.
Computed row band.
Computed column band.
Row-major tile key.
Address of the first original row/column pair.
Number of original query positions, including duplicates.
Current original query position or tile position.
Tile-count array base.
Prefix-offset array base, with one additional terminal cell.
Current stable-scatter cursor array base.
Grouped query-code array base.
Grouped original-position array base.
Current tile's query count.
Running prefix sum.
Number of tiles.
Number of original positions in one band.
One past the readonly initialized query input.
One past the grouping arrays.
Address scratch.
Saved address of the current scatter cursor.
Current grouped output position.
Compute just the row-major tile key. No memory is touched.
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.
Zero each tile count once.
Load one original pair without changing its input words.
Count one input position in its actual tile, retaining duplicates.
Scan the original list once to obtain tile counts.
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.