Fixed native code for pruned tensor queries #
The controller uses an explicit depth-first stack. Query and value directories have one row per depth. A shared timestamp directory deduplicates child suffixes without clearing a dense array at every node. Encoded products and sums use the existing native signed kernels.
Main definitions #
PrunedQuery.kernel: evaluator with explicit caller-supplied array and scratch addresses.PrunedQuery.program: initialized-input wrapper computing all addresses from the depth and query-count headers.
Client execution interfaces are exec_kernel in Pruned.Kernel, runs and runs_bilinear
in Pruned.Flat, and runs_wide in Pruned.Width. Other stage exec_* lemmas and controller
invariants under Pruned/ are internal implementation APIs. They are public to compose proofs
across the stage modules, rather than intended as independent caller contracts.
References #
The query-set recursion is from [AlmanWilliams2026, Section 2.4.2], selectively adapted from
Anthropic's formal-math revision 16a5ce41304fcdaea4e0be7c132e1c361dc26da5,
pinned source. The explicit iterative stack and
timestamp implementation are new native code; the source machine is not imported.
The program has a fixed register bank, including nine signed-arithmetic scratch registers.
Instances For
Original tensor depth, loaded from the ordinary input header.
Instances For
Computed encoding-array length and per-depth directory capacity, 10^L.
Instances For
Pointer to the left canonical signed encoding array.
Instances For
Pointer to the right canonical signed encoding array.
Instances For
Pointer to the original unsigned query-code list, including repeats.
Instances For
Number of supplied queries, before native deduplication.
Instances For
Pointer to the answer list, in the original query order.
Instances For
Caller-supplied start of the explicit stack and directory workspace.
Instances For
Current timestamp generation for native query deduplication.
Instances For
Pointer to the first four-word stack frame.
Instances For
Pointer to the first per-depth distinct-query row.
Instances For
Pointer to the first per-depth signed-value row.
Instances For
Pointer to the shared query-membership timestamp directory.
Instances For
Current stack depth, with zero denoting the root.
Instances For
Controller phase: zero for entry, one for dispatch, two for returned-child accumulation.
Instances For
Traversal flag; returning from the root sets this to zero.
Instances For
Raw unsigned constant one for counters and offsets.
Instances For
Raw unsigned radix ten for the fixed term and query dictionaries.
Instances For
Inner-output wildcard digit, in the existing term numbering.
Instances For
Raw unsigned width of a stack frame: four words.
Instances For
Address of the currently loaded stack frame.
Instances For
Number of distinct requests stored in the current frame.
Instances For
Processed least-significant leaf digits of the current node.
Instances For
Place value of the next leaf digit, 10^level.
Instances For
Next term number to dispatch or accumulate.
Instances For
Loop counter for powers, scans, clearing, accumulation and reporting.
Instances For
Distinct child count computed by the actual timestamp scan.
Instances For
Current numerical output-string code loaded from a query list.
Instances For
First output digit computed by remainder modulo ten.
Instances For
Remaining output digits computed by division by ten.
Instances For
Scratch address used by native indexed loads and stores.
Instances For
Scratch word for arithmetic, branch fallbacks and loaded values.
Instances For
Scratch word for row-size and address products.
Instances For
Timestamp loaded from the membership directory.
Instances For
Address of the current depth's request row.
Instances For
Address of the current depth's accumulator row.
Instances For
Address of the next depth's computed request row.
Instances For
Address of the next depth's returned-value row.
Instances For
Computed child stack depth.
Instances For
Computed address of the frame about to be pushed.
Instances For
Computed leaf prefix of the child about to be pushed.
Instances For
Computed leaf place value for the child about to be pushed.
Instances For
Raw unsigned constant zero.
Instances For
Raw unsigned constant two, initialized with the fixed scalar constants.
Instances For
Constant initialization, before the depth-controlled power loop.
Instances For
One charged power multiplication and counter increment.
Instances For
Initialize constants and compute the actual encoding-array length 10^L.
Instances For
Separate stack frames, query lists, value directories and membership timestamps.
Instances For
Append one previously unseen suffix and mark it with the current epoch.
Instances For
The two fixed suffix kernels either divide a selected child query or copy a root query.
Instances For
A selected child suffix is computed by an actual unsigned division.
Instances For
Load the next supplied query and compute its actual first digit.
Instances For
Root queries are copied directly; child queries are filtered by the native digit tests.
Instances For
One deduplicating scan step, including input indexing, dispatch and counter increment.
Instances For
Initialize one query scan with a genuinely fresh native epoch.
Instances For
Scan and deduplicate an explicit source list.
Instances For
Point the deduplicating root scan at the actual supplied query list.
Instances For
Store the four actual root-frame words and enter its first controller phase.
Instances For
Deduplicate supplied queries into the root list; the original list remains read-only.
Instances For
Load the current frame and compute its depth-specific list/value addresses.
Instances For
Return to the parent's accumulation phase, or finish the root.
Instances For
Load both actual encoded words at the current leaf prefix.
Instances For
One requested leaf product, using the existing native signed multiplication kernel.
Instances For
Evaluate a requested leaf from the actual two encoded words.
Instances For
One actual indexed store for an explicitly listed requested value.
Instances For
Clear exactly the requested parent values, not the full dense directory.
Instances For
Store the actual next-term counter and enter the frame's dispatch phase.
Instances For
Initialize the stored next-term counter after sparse accumulator clearing.
Instances For
Initialize requested values and the frame's next-term counter.
Instances For
Entry phase: multiply at a leaf; otherwise initialize the requested accumulators.
Instances For
Form and deduplicate a child request set using actual tests, loads and stores.
Instances For
Advance the parent's term after an empty child or after accumulating its returned values.
Instances For
Push a nonempty child, with the exact least-significant-first leaf leafPrefix.
Instances For
Dispatch the next of the ten actual terms, recursing only on nonempty computed sets.
Instances For
Load the two encoded operands at the actual parent query and child suffix addresses.
Instances For
Store the signed sum back at the computed parent query address.
Instances For
Add one returned child value to its parent's actual signed accumulator.
Instances For
Select the returned child by the same two real digit comparisons as child construction.
Instances For
Load, dispatch and advance one actual parent query.
Instances For
Consume a returned child's values at the explicitly listed contributing parent queries.
Instances For
Traverse the parent requests once, then advance the stored term counter.
Instances For
One explicit-stack controller step. Every branch and frame address is native work.
Instances For
One actual lookup and indexed output store, including the reporting counter.
Instances For
Report results in the original input query order, including repeated queries.
Instances For
The common stack evaluator after powers and caller parameters have been initialized.
Instances For
Evaluate the computed root, then report the original query list.
Instances For
Generic native evaluator with explicit pointer arguments and a fresh timestamp epoch.
Instances For
Load the two ordinary scalar input headers.
Instances For
Compute all initial array/output/scratch pointers from the actual array and query lengths.
Instances For
One finite program reading the header and encoded arrays from ordinary initialized memory.
Instances For
The same program is used at every word width; it never reads the physical word size.
A fixed bound on both control code and all arithmetic blocks, including the final halt.