Native in-place Strassen product accumulation #
The actual selected output quarter is both the first input and destination of the existing signed vector loop. Its exact-alias theorem is essential here. The child product buffer is disjoint; dirty words outside this one output quarter retain their previous values.
theorem Cslib.Algorithms.WordRAM.Strassen.exec_accumulate {w q t A B : ℕ} (subtract : Bool) (x : WordRAM.Data 64) (u v : ℕ → ℤ) (hq : x.regs Reg.quarter = q) (ht : t < 4) (hbound : GenericRAM.Signed.Fits w ↑(A + B)) (hu : ∀ j < q, (u j).natAbs ≤ A) (hv : ∀ j < q, (v j).natAbs ≤ B) (hout : ∀ j < q, x.mem (x.regs Reg.output + t * q + j) = WordRAM.Signed.encode (u j)) (hprod : ∀ j < q, x.mem (x.regs Reg.product + j) = WordRAM.Signed.encode (v j)) (hw : WordRAM.Fits (w + 2) (x.regs Reg.output + 4 * q + x.regs Reg.product + q + 8)) (hsep : x.regs Reg.product + q ≤ x.regs Reg.output ∨ x.regs Reg.output + 4 * q ≤ x.regs Reg.product) :
∃ (y : WordRAM.Data 64),
WordRAM.ExecWithin (w + 2) (accumulate t subtract) x y (26 * q + 10) ∧ (∀ j < q,
y.mem (x.regs Reg.output + t * q + j) = WordRAM.Signed.encode (if subtract = true then u j - v j else u j + v j)) ∧ (∀ (a : ℕ), a < x.regs Reg.output + t * q ∨ x.regs Reg.output + t * q + q ≤ a → y.mem a = x.mem a) ∧ ∀ (i : Fin 64), 32 ≤ ↑i → i ≠ Reg.temporary → y.regs i = x.regs i
Add/subtract one actual child result in place, charging the selected-quadrant address, all three argument copies, and the complete signed vector loop.