Native row-major residue-class queries #
The program scans a square residue matrix and writes the row and column of each entry equal to
the runtime query residue. Its output order is the row-major order used by the existing finite
chunk construction. Prefix ranks use Mathlib's Nat.count.
This directly adapts the query-class construction in the pinned Theorem 17 class builder. The per-class scan is charged explicitly; composing all residue classes multiplies its bound by the modulus. No class-membership or query-list table is supplied to the program.
Main definitions #
QueryScan.program: the fixed twelve-register query scan.
Main results #
QueryScan.exec: actual scan execution, exact ranks and the output-prefix frame.
Square residue input pointer.
Output pointer for consecutive row/column pairs.
Matrix side.
Selected residue.
Flat input cursor.
Input area.
Number of emitted pairs.
Address temporary.
Loaded residue.
Constant one.
Output row.
Output column.
Every successful match computes both coordinates and stores their two words.
Constants, counters and matrix area are initialized by actual instructions.
The query scanner has a fixed instruction graph and no physical-width reads.
Scan an actual residue matrix, preserving the input and all cells outside the emitted pair
prefix. Each selected flat position is stored at its exact row-major rank, counted by Nat.count.
The final halt is excluded from the 14n²+6 instruction bound.