Native shared tensor encoding #
The two fixed programs use unsigned addresses and counters, and sign-and-magnitude encoded
integer entries. Address 1 holds the depth; the 7^L encoded entries begin at address 2.
The ordinary State.init length header is at address 0. Output and scratch are consecutive
blocks of 10^L cells immediately after the input. Each coordinate transform reads the
previous stage and writes the other buffer. No initialization of unread scratch is needed.
A final charged copy puts the result in the first buffer, also at depth zero.
The coordinate transform is a new iterative implementation of the linear forms in
[AlmanWilliams2026, Section 2.4.1]. The coefficients and mathematical encoding are selectively
adapted from Anthropic's formal-math revision 16a5ce41304fcdaea4e0be7c132e1c361dc26da5,
Step
and Recursion. The source's
recursive machine and execution semantics are not used.
Main definitions #
Encoding.program: fixed native code for either coefficient table.Encoding.input: concrete input forState.init, including the depth header.Encoding.outputBase,Encoding.scratchBase: disjoint output and scratch blocks.
Seven variable digits: the three outer variables, then the four inner variables.
Right-variable digits use the same order as the left-variable digits.
Row-major order on the nine P terms, followed by P0.
Executable flat address digits for the seven left variables. LeftVar.equiv instead
exposes their mathematical sum carrier Fin 3 ⊕ (Fin 2 × Fin 2). This dictionary gives a
single Fin 7 digit for each variable, for the native array layout.
Executable flat address digits for the seven right variables. RightVar.equiv instead
exposes their mathematical sum carrier Fin 3 ⊕ (Fin 2 × Fin 2). This dictionary gives a
single Fin 7 digit for each variable, in the same order as leftDigits.
Executable flat address digits for all ten terms. Term.equiv instead exposes their
mathematical carrier Option (Fin 3 × Fin 3). The native dictionary uses Fin 10, with
row-major P i j at digit 3*i+j and P0 at digit 9.
Every actual coefficient is zero, one or minus one.
The input block ends where the output block begins.
The scratch block immediately follows the entire output block.
Concrete input: depth header followed by the signed input entries in flat order.
The caller encodes each integer with Signed.encode before passing the list to State.init.
The native unsigned length header is installed by State.init itself.
The concrete left-array input, using Mathlib's base-seven string numbering.
The concrete right-array input, in exactly the same flat memory layout.
All thirty-two registers are fixed independently of depth and width. Registers 0–8 are precisely the existing signed-arithmetic workspace.
All thirty-two registers are fixed independently of depth and width. Registers 0–8 are precisely the existing signed-arithmetic workspace.
All thirty-two registers are fixed independently of depth and width. Registers 0–8 are precisely the existing signed-arithmetic workspace.
All thirty-two registers are fixed independently of depth and width. Registers 0–8 are precisely the existing signed-arithmetic workspace.
All thirty-two registers are fixed independently of depth and width. Registers 0–8 are precisely the existing signed-arithmetic workspace.
All thirty-two registers are fixed independently of depth and width. Registers 0–8 are precisely the existing signed-arithmetic workspace.
All thirty-two registers are fixed independently of depth and width. Registers 0–8 are precisely the existing signed-arithmetic workspace.
All thirty-two registers are fixed independently of depth and width. Registers 0–8 are precisely the existing signed-arithmetic workspace.
All thirty-two registers are fixed independently of depth and width. Registers 0–8 are precisely the existing signed-arithmetic workspace.
All thirty-two registers are fixed independently of depth and width. Registers 0–8 are precisely the existing signed-arithmetic workspace.
All thirty-two registers are fixed independently of depth and width. Registers 0–8 are precisely the existing signed-arithmetic workspace.
All thirty-two registers are fixed independently of depth and width. Registers 0–8 are precisely the existing signed-arithmetic workspace.
All thirty-two registers are fixed independently of depth and width. Registers 0–8 are precisely the existing signed-arithmetic workspace.
All thirty-two registers are fixed independently of depth and width. Registers 0–8 are precisely the existing signed-arithmetic workspace.
All thirty-two registers are fixed independently of depth and width. Registers 0–8 are precisely the existing signed-arithmetic workspace.
All thirty-two registers are fixed independently of depth and width. Registers 0–8 are precisely the existing signed-arithmetic workspace.
All thirty-two registers are fixed independently of depth and width. Registers 0–8 are precisely the existing signed-arithmetic workspace.
All thirty-two registers are fixed independently of depth and width. Registers 0–8 are precisely the existing signed-arithmetic workspace.
All thirty-two registers are fixed independently of depth and width. Registers 0–8 are precisely the existing signed-arithmetic workspace.
All thirty-two registers are fixed independently of depth and width. Registers 0–8 are precisely the existing signed-arithmetic workspace.
All thirty-two registers are fixed independently of depth and width. Registers 0–8 are precisely the existing signed-arithmetic workspace.
All thirty-two registers are fixed independently of depth and width. Registers 0–8 are precisely the existing signed-arithmetic workspace.
One coefficient in {0, 1, -1} times one array entry. Zero coefficients cause no load.
Nonzero coefficients use the proved native signed addition or subtraction block.
A finite unrolling of the seven coefficients. This recursion constructs code; it does not recurse on the input depth.
One linear form, including accumulator initialization.
A fixed finite dispatch on the ten possible term digits.
Decode one flat output index into its mixed-radix coordinates and source group.
Store the computed entry and advance the flat index.
Divide the suffix stride and compute the next stage size.
Alternate the two buffers and advance the prefix and stage counters.
Transform the next coordinate, then alternate the output buffers.
Load the actual depth header and initialize the power counters.
One multiplication by each radix and one counter increment. Computing 7^L and 10^L
simultaneously in a single stage < depth loop charges 5 * L + 18 setup instructions and
shares one counter register, whereas two sequential WordRAM.Power.program loops would
duplicate the loop control and counter reset.
Compute the concrete buffer addresses from the powers and initialize the first stage.
Read the depth and compute both powers in a charged native loop.
Reuse the existing seven-register array copy inside the encoder's register file.
The seven copy registers are distinct.
A charged copy into the fixed output block, permitting disjoint blocks in either order or identical source and destination.
The complete fixed native encoder, excluding its final halt. The returned output
register identifies the first output cell; the capacity register holds its length.
The code performs no word-width queries.