Documentation

CslibFrontier.Algorithms.WordRAM.MatrixMultiplication.Strassen.State

Internal explicit-stack Strassen invariants #

The program takes ordinary pointers, depth and coefficient length. These structures describe its actual intermediate state for the execution induction. They contain no run, result or time oracle. Root readiness follows from the native setup theorem; child readiness is derived from the actual operand writes and frame push. The final caller interface must compose those derivations from original input data, rather than require these invariants.

structure Cslib.Algorithms.WordRAM.Strassen.NodeLayout (p k a b out scratch frames frame : ℕ) :

Numerical separation maintained by the actual Strassen buffers and frame stack.

  • modulus_pos : 0 < p

    Scalar cyclic ring length is positive.

  • left_before : a + 4 ^ k * p ≤ scratch

    The complete first input is protected below current scratch.

  • right_before : b + 4 ^ k * p ≤ scratch

    The complete second input is protected below current scratch.

  • output_before : out + 4 ^ k * p ≤ scratch

    The output also ends before current scratch.

  • scratch_before : scratch + 4 ^ k * p ≤ frames

    Recursive coefficient buffers end before the actual stack base.

  • frames_before : frames ≤ frame

    Older frames precede the current frame.

  • left_disjoint : a + 4 ^ k * p ≤ out ∨ out + 4 ^ k * p ≤ a

    The output is disjoint from the first input.

  • right_disjoint : b + 4 ^ k * p ≤ out ∨ out + 4 ^ k * p ≤ b

    The output is disjoint from the second input.

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

The actual three-buffer advancement gives the child all separation properties.

theorem Cslib.Algorithms.WordRAM.Strassen.NodeLayout.input_outside {p k a b out scratch frames frame i : ℕ} (hl : NodeLayout p k a b out scratch frames frame) (hi : i < 4 ^ k * p) :
((a + i < out ∨ out + 4 ^ k * p ≤ a + i) ∧ a + i < scratch) ∧ (b + i < out ∨ out + 4 ^ k * p ≤ b + i) ∧ b + i < scratch

Every index of either input array lies outside the output block and strictly below scratch.

theorem Cslib.Algorithms.WordRAM.Strassen.NodeLayout.inputs_of_outside {p k a b out scratch frames frame : ℕ} (hl : NodeLayout p k a b out scratch frames frame) {μ ν : ℕ → ℕ} (hν : ∀ (d : ℕ), d < out ∨ out + 4 ^ k * p ≤ d → ν d = μ d) :
(∀ i < 4 ^ k * p, ν (a + i) = μ (a + i)) ∧ ∀ i < 4 ^ k * p, ν (b + i) = μ (b + i)

Both input arrays lie outside the current output block, so any state whose memory agrees outside [out, out + 4 ^ k * p) retains both input arrays.

theorem Cslib.Algorithms.WordRAM.Strassen.NodeLayout.inputs_of_stage {p k a b out scratch frames frame : ℕ} (hl : NodeLayout p (k + 1) a b out scratch frames frame) {μ ν : ℕ → ℕ} (hν : ∀ (d : ℕ), d < out ∨ out + 4 ^ (k + 1) * p ≤ d → d < scratch ∨ scratch + 2 * (4 ^ k * p) ≤ d → d < frame + 6 ∨ frame + 14 ≤ d → ν d = μ d) :
(∀ i < 4 ^ (k + 1) * p, ν (a + i) = μ (a + i)) ∧ ∀ i < 4 ^ (k + 1) * p, ν (b + i) = μ (b + i)

Both parent input arrays precede scratch and frame and are disjoint from out, so stage executions that modify only output, child scratch and current/child frame preserve them.

structure Cslib.Algorithms.WordRAM.Strassen.NodeHeader (p k a b out scratch frames frame : ℕ) (x : WordRAM.Data 64) :

Current matrix parameters and fixed controller constants, before phase-specific work.

theorem Cslib.Algorithms.WordRAM.Strassen.NodeHeader.of_regs_eq {p k a b out scratch frames frame : ℕ} {x y : WordRAM.Data 64} (h : NodeHeader p k a b out scratch frames frame x) (hr : ∀ (i : Fin 64), 32 ≤ ↑i → ↑i < 50 → y.regs i = x.regs i) :
NodeHeader p k a b out scratch frames frame y

Reuse the common header after a real helper call preserving its high register bank.

theorem Cslib.Algorithms.WordRAM.Strassen.NodeHeader.of_regs_eq_cursors {p k a b out scratch frames frame : ℕ} {x y : WordRAM.Data 64} (h : NodeHeader p k a b out scratch frames frame x) (hr : ∀ (i : Fin 64), i ≠ Reg.address → i ≠ Reg.index → y.regs i = x.regs i) :
NodeHeader p k a b out scratch frames frame y

Frame loads and output clearing may change the two cursors, which are not parameters of the current node. All actual header fields are preserved.

structure Cslib.Algorithms.WordRAM.Strassen.NodeReady (p k a b out scratch frames frame : ℕ) (x : WordRAM.Data 64) extends Cslib.Algorithms.WordRAM.Strassen.NodeHeader p k a b out scratch frames frame x :

Actual current fields and frame words at a newly entered root or pushed child.

def Cslib.Algorithms.WordRAM.Strassen.NodeWrites (p k out scratch frames frame a : ℕ) :

Only current output, recursive coefficient scratch and current/descendant frames may change during this node. Older parent frames are protected.

structure Cslib.Algorithms.WordRAM.Strassen.NodeResult (p k out scratch frames frame : ℕ) (u v : ℕ → ℤ) (x y : WordRAM.Data 64) :

Semantic/memory result of a node return, independent of an execution or time claim.

Native instruction budget established by the subsequent controller composition proof. Its definition alone supplies no execution or source Light instruction-count theorem.

theorem Cslib.Algorithms.WordRAM.Strassen.traceBudget_potential_le (p k : ℕ) :
traceBudget p k + 231 * p * 4 ^ k + 150 ≤ (42 * p * p + 240 * p + 178) * 7 ^ k

Arithmetic bound for the native budget. The strengthened potential pays the linear quarter-size work; the actual execution theorem is proved separately in Strassen.Exec.

The actual native setup constructs root readiness, rather than taking it as a premise.