Documentation

CslibFrontier.Algorithms.WordRAM.MatrixMultiplication.Strassen.Program

Native cyclic-coefficient Strassen stack #

The fixed controller traverses an explicit seven-word frame stack. Each nonleaf creates the seven actual operand forms, calls the same controller on the child, and accumulates the returned coefficient array into its output quadrants. Leaves execute the native quadratic cyclic-convolution kernel. Every form, accumulation, copy, frame access and dispatch is code on the standard unsigned machine, using the existing signed arithmetic kernels.

Inputs are runtime pointers to Morton-ordered coefficient arrays, the coefficient length, a matrix depth, an output and a scratch base. The setup computes the actual array length. The scratch layout uses three child-sized arrays at each level, followed by child scratch; the explicit frames start after one root-array length of scratch. Output and scratch may start dirty. This module defines code; its definition alone supplies neither correctness nor a running-time theorem.

The seven products adapt the pinned Anthropic source Spec/Sec3/Theorem17/Strassen.lean and Programs/Sec3/Theorem17/Hashing/Strassen.lean at revision 16a5ce41304fcdaea4e0be7c132e1c361dc26da5. The native iterative stack is original code.

@[reducible, inline]

Low-bank result of the existing natural-power routine.

@[reducible, inline]

Low-bank base of the existing natural-power routine.

@[reducible, inline]

Low-bank exponent of the existing natural-power routine.

@[reducible, inline]

Low-bank arguments of the native copying kernel.

@[reducible, inline]

Low-bank destination of the native copying kernel.

@[reducible, inline]

Low-bank word count of the native copying kernel.

@[reducible, inline]

Low-bank first operand of signed array kernels.

@[reducible, inline]

Low-bank second operand of signed array kernels.

@[reducible, inline]

Low-bank destination of signed array kernels.

@[reducible, inline]

Low-bank coefficient count of signed array kernels.

@[reducible, inline]

Current first matrix pointer.

@[reducible, inline]

Current second matrix pointer.

@[reducible, inline]

Current output pointer.

@[reducible, inline]

Current scratch pointer.

@[reducible, inline]

Current matrix depth.

@[reducible, inline]

Current matrix length in coefficient words.

@[reducible, inline]

Zero on entry; one through seven after the corresponding child returns.

@[reducible, inline]

Current explicit frame pointer.

@[reducible, inline]

Root explicit frame pointer.

@[reducible, inline]

One until the root returns.

@[reducible, inline]

Constant one.

@[reducible, inline]

Constant four.

@[reducible, inline]

Constant seven, the number of words per frame.

@[reducible, inline]

Runtime cyclic coefficient length, preserved across all children.

@[reducible, inline]

Initialization and clearing loop counter.

@[reducible, inline]

Frame and output address temporary.

@[reducible, inline]

Canonical signed zero and raw unsigned zero.

@[reducible, inline]

Coefficient length of a child quadrant.

@[reducible, inline]

First child operand buffer.

@[reducible, inline]

Second child operand buffer.

@[reducible, inline]

Child product buffer.

@[reducible, inline]

Start of scratch available to the child.

@[reducible, inline]

Computed child matrix depth.

@[reducible, inline]

Quarter-offset arithmetic temporary.

@[reducible, inline]

Constant phase-dispatch temporary.

Compute the address of a statically selected contiguous quadrant.

Materialize an operand form, including a real copy in the single-quadrant case.

Add or subtract the actual child product into one output quadrant.

Store the seven current frame fields at the computed frame address.

Derive all child-buffer pointers from the loaded parent frame.

One actual store per output coefficient; no global workspace clearing.

Save the parent's return phase and prepare the real child fields in registers.

Save the parent's return phase, create a child frame, then let the controller enter it.

Return to a real parent frame, or finish when the root has returned.

def Cslib.Algorithms.WordRAM.Strassen.prepare (phase a₁ a₂ : ℕ) (asign : ℤ) (b₁ b₂ : ℕ) (bsign : ℤ) :

A recursive child is dispatched only after both actual operand forms have been stored.

The seven actual child calls, in the same order as the mathematical product recurrence.

Execute the corresponding returned-child accumulation and prepare the next product.

Static seven-way branch chain reads the phase stored by the actual push.

A scalar leaf uses the real cyclic-convolution program, then returns through the stack.

One explicit stack iteration; it never invokes a recursive semantic evaluator.

Fixed controller constants and actual runtime arguments to the existing power routine.

Compute the coefficient-array length and actual root-frame address after the power call.

Actual runtime powers, stack placement and complete dirty-root frame initialization.

Fixed finite native code independent of coefficient length, depth and word size.

Root initialization followed by the actual explicit-stack traversal.