Documentation

Complexity.Algorithms.WordRAM.MatrixMultiplication.Schonhage.Forms

Native execution of the encoding forms #

The form code reads seven strided entries and uses only the existing native signed arithmetic blocks. These results account for those blocks' actual instructions and their scratch registers.

Main results #

References #

The linear forms are from [AlmanWilliams2026, Section 2.4.1]; see Encoding for provenance.

Registers outside the signed workspace and the form's three local registers.

Instances For

    Form frames compose without changing any memory cell.

    theorem Cslib.Algorithms.WordRAM.MatrixMultiplication.Schonhage.Encoding.exec_summand {w : ℕ} (x : WordRAM.Data 32) (s : Fin 7) (c a v : ℤ) (base n : ℕ) (hc : c = 0 ∨ c = 1 ∨ c = -1) (hacc : x.regs accumulator = WordRAM.Signed.encode a) (hbase : x.regs group = base) (hn : x.regs stride = n) (hmem : x.mem (base + ↑s * n) = WordRAM.Signed.encode v) (ha : GenericRAM.Signed.Fits w a) (hv : GenericRAM.Signed.Fits w v) (haddr : WordRAM.Fits (w + 2) (base + 7 * n)) (hseven : WordRAM.Fits (w + 2) 7) :

    A single coefficient is executed by real loads and signed arithmetic. The seven address computations fit whenever the one-past-end address fits. The two operands must fit the signed source range; the sum itself may use the two extra target bits supplied by the arithmetic block.

    theorem Cslib.Algorithms.WordRAM.MatrixMultiplication.Schonhage.Encoding.exec_sumCode {w : ℕ} (hw : 0 < w) (pairs : List (Fin 7 × ℤ)) (x : WordRAM.Data 32) (a B : ℤ) (base n : ℕ) (v : Fin 7 → ℤ) (hc : ∀ sc ∈ pairs, sc.2 = 0 ∨ sc.2 = 1 ∨ sc.2 = -1) (hacc : x.regs accumulator = WordRAM.Signed.encode a) (hbase : x.regs group = base) (hn : x.regs stride = n) (hmem : ∀ (s : Fin 7), x.mem (base + ↑s * n) = WordRAM.Signed.encode (v s)) (hB : 0 ≤ B) (hv : ∀ (s : Fin 7), |v s| ≤ B) (hfitB : B < 2 ^ (w - 1)) (hfit : |a| + ↑pairs.length * B < 2 ^ (w - 1)) (haddr : WordRAM.Fits (w + 2) (base + 7 * n)) (hseven : WordRAM.Fits (w + 2) 7) :
    ∃ (y : WordRAM.Data 32), WordRAM.ExecWithin (w + 2) (sumCode pairs) x y (23 * pairs.length + 1) ∧ y.regs accumulator = WordRAM.Signed.encode (a + (List.map (fun (sc : Fin 7 × ℤ) => sc.2 * v sc.1) pairs).sum) ∧ FormFrame x y

    Execute any finite list of the fixed digit/coefficients. Partial sums are bounded by |a| + length * B; the theorem derives each arithmetic operand's fit from that inequality.

    theorem Cslib.Algorithms.WordRAM.MatrixMultiplication.Schonhage.Encoding.exec_form {w : ℕ} (hw : 0 < w) (side : Bool) (t : Fin 10) (x : WordRAM.Data 32) (B : ℤ) (base n : ℕ) (v : Fin 7 → ℤ) (hbase : x.regs group = base) (hn : x.regs stride = n) (hmem : ∀ (s : Fin 7), x.mem (base + ↑s * n) = WordRAM.Signed.encode (v s)) (hB : 0 ≤ B) (hv : ∀ (s : Fin 7), |v s| ≤ B) (hfit : 7 * B < 2 ^ (w - 1)) (haddr : WordRAM.Fits (w + 2) (base + 7 * n)) (hseven : WordRAM.Fits (w + 2) 7) :
    ∃ (y : WordRAM.Data 32), WordRAM.ExecWithin (w + 2) (form side t) x y 163 ∧ y.regs accumulator = WordRAM.Signed.encode (∑ s : Fin 7, coefficients side t s * v s) ∧ FormFrame x y

    A complete coefficient row, including initialization, costs at most 163 instructions. All seven entries have absolute value at most B, so every partial sum has magnitude at most 7B; this ordinary explicit width condition is sufficient for every signed operation.

    theorem Cslib.Algorithms.WordRAM.MatrixMultiplication.Schonhage.Encoding.exec_dispatch {w : ℕ} (hw : 0 < w) (side : Bool) (rows : List (Fin 10)) (t : Fin 10) (ht : t ∈ rows) (x : WordRAM.Data 32) (B : ℤ) (base n : ℕ) (v : Fin 7 → ℤ) (hterm : x.regs term = ↑t) (hbase : x.regs group = base) (hn : x.regs stride = n) (hmem : ∀ (s : Fin 7), x.mem (base + ↑s * n) = WordRAM.Signed.encode (v s)) (hB : 0 ≤ B) (hv : ∀ (s : Fin 7), |v s| ≤ B) (hfit : 7 * B < 2 ^ (w - 1)) (haddr : WordRAM.Fits (w + 2) (base + 7 * n)) (hten : WordRAM.Fits (w + 2) 10) :
    ∃ (y : WordRAM.Data 32), WordRAM.ExecWithin (w + 2) (dispatch side rows) x y (3 * rows.length + 163) ∧ y.regs accumulator = WordRAM.Signed.encode (∑ s : Fin 7, coefficients side t s * v s) ∧ FormFrame x y

    The finite term dispatch costs at most three instructions per inspected row in addition to the row's 163-instruction bound. All ten forms share the same native register file.