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.
Instances For
Original row of the current query.
Instances For
Original column of the current query.
Instances For
Computed row band.
Instances For
Computed column band.
Instances For
Row-major tile key.
Instances For
Address of the first original row/column pair.
Instances For
Number of original query positions, including duplicates.
Instances For
Current original query position or tile position.
Instances For
Tile-count array base.
Instances For
Prefix-offset array base, with one additional terminal cell.
Instances For
Current stable-scatter cursor array base.
Instances For
Grouped query-code array base.
Instances For
Grouped original-position array base.
Instances For
Current tile's query count.
Instances For
Running prefix sum.
Instances For
Number of tiles.
Instances For
Number of original positions in one band.
Instances For
One past the readonly initialized query input.
Instances For
One past the grouping arrays.
Instances For
Address scratch.
Instances For
Saved address of the current scatter cursor.
Instances For
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
Zero each tile count once.
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
Scan the original list once to obtain tile counts.
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.