Documentation

CslibFrontier.Algorithms.WordRAM.MatrixMultiplication.Strassen.Pending

Actual pending-child invariant for native Strassen #

The first child invariant follows from the actual complete positive-depth iteration. Later children use the same invariant after actual return, accumulation, operand production and push. It records only mathematical meanings of current memory/registers, not executions, time bounds or data supplied to the program. The controller induction must derive every instance from its actual preceding execution.

structure Cslib.Algorithms.WordRAM.Strassen.PendingChild (p k a b out scratch frames frame : ℕ) (phase : Fin 7) (u v : ℕ → ℤ) (parent child : WordRAM.Data 64) :

Current native child and protected parent data, after both form loops and frame push.

theorem Cslib.Algorithms.WordRAM.Strassen.NodeWrites.child_subset {p k a b out scratch frames frame d : ℕ} (hl : NodeLayout p (k + 1) a b out scratch frames frame) (h : NodeWrites p k (scratch + 2 * (4 ^ k * p)) (scratch + 3 * (4 ^ k * p)) frames (frame + 7) d) :
NodeWrites p (k + 1) out scratch frames frame d

Every descendant write is within the parent's complete output/scratch/frame footprint.

theorem Cslib.Algorithms.WordRAM.Strassen.NodeLayout.outside_stage {p k a b out scratch frames frame d : ℕ} (hl : NodeLayout p (k + 1) a b out scratch frames frame) (h : ¬NodeWrites p (k + 1) out scratch frames frame d) :
(d < out ∨ out + 4 ^ (k + 1) * p ≤ d) ∧ (d < scratch ∨ scratch + 2 * (4 ^ k * p) ≤ d) ∧ (d < frame + 6 ∨ frame + 14 ≤ d)

The three concrete stage-write envelopes all lie inside the parent footprint.

theorem Cslib.Algorithms.WordRAM.Strassen.PendingChild.after_result {p k a b out scratch frames frame : ℕ} {phase : Fin 7} {u v : ℕ → ℤ} {parent child returned : WordRAM.Data 64} (h : PendingChild p k a b out scratch frames frame phase u v parent child) (hl : NodeLayout p (k + 1) a b out scratch frames frame) (hr : NodeResult p k (scratch + 2 * (4 ^ k * p)) (scratch + 3 * (4 ^ k * p)) frames (frame + 7) (MatrixMultiplication.Strassen.leftOperand p k u phase) (MatrixMultiplication.Strassen.rightOperand p k v phase) child returned) :
(∀ j < 4 ^ (k + 1) * p, returned.mem (a + j) = WordRAM.Signed.encode (u j)) ∧ (∀ j < 4 ^ (k + 1) * p, returned.mem (b + j) = WordRAM.Signed.encode (v j)) ∧ (∀ (s : Fin 4), ∀ j < 4 ^ k * p, returned.mem (out + ↑s * (4 ^ k * p) + j) = WordRAM.Signed.encode (MatrixMultiplication.Strassen.partialValue p k (↑phase) u v s j)) ∧ ∀ j < 4 ^ k * p, returned.mem (scratch + 2 * (4 ^ k * p) + j) = WordRAM.Signed.encode (MatrixMultiplication.Strassen.childProduct p k u v phase j)

A completed child preserves the original parent arrays and its earlier partial sum. Its own returned values are exactly the current finite child product.

theorem Cslib.Algorithms.WordRAM.Strassen.exec_first_pending {w p k A B a b out scratch frames frame : ℕ} (x : WordRAM.Data 64) (u v : ℕ → ℤ) (hx : NodeReady p (k + 1) a b out scratch frames frame x) (hl : NodeLayout p (k + 1) a b out scratch frames frame) (hu : ∀ i < 4 ^ (k + 1) * p, (u i).natAbs ≤ A) (hv : ∀ i < 4 ^ (k + 1) * p, (v i).natAbs ≤ B) (hleft : ∀ i < 4 ^ (k + 1) * p, x.mem (a + i) = WordRAM.Signed.encode (u i)) (hright : ∀ i < 4 ^ (k + 1) * p, x.mem (b + i) = WordRAM.Signed.encode (v i)) (hmag : GenericRAM.Signed.Fits w ↑(magnitudeBound p A B (k + 1))) (haddr : WordRAM.Fits (w + 2) (addressBound frames frame (k + 1))) :
∃ (y : WordRAM.Data 64), WordRAM.ExecWithin (w + 2) step x y (68 * (4 ^ k * p) + 77) ∧ PendingChild p k a b out scratch frames frame 0 u v x y ∧ ∀ (d : ℕ), ¬NodeWrites p (k + 1) out scratch frames frame d → y.mem d = x.mem d

The actual first controller iteration establishes the first pending child from original parent coefficient arrays and its actual freshly written frame, even with dirty output.