Documentation

CslibFrontier.Algorithms.WordRAM.ThreeSum.Fill

Native matrix-building loop for Convolution-3SUM #

This is a fixed native word-RAM program for one tripartite instance. Its parameters are supplied in registers. Every row/column calculation, index calculation, guarded input read, store and loop instruction is charged. The three matrices follow the input in disjoint blocks.

The construction directly adapts Anthropic's convFillBody and its prefix invariant at formal-math@16a5ce4. The graph builder does not invoke an Exact Triangle solver.

Main definitions #

Main results #

References #

@[reducible, inline]

Register holding the number of cells in each matrix.

@[reducible, inline]

Loop increment.

Write all three weights at the current cell and advance the counter.

Initialize the counter and matrix area, then write each row-major cell.

theorem Cslib.Algorithms.WordRAM.ThreeSum.Fill.exec {w : ℕ} (A : Args) (x : WordRAM.Data 28) (ht : x.regs Cell.side = A.t) (hs : x.regs Cell.inst = A.s) (hab : x.regs Cell.matAB = A.ab) (hbc : x.regs Cell.matBC = A.bc) (hac : x.regs Cell.matAC = A.ac) (hlen : x.regs Cell.len = A.N) (hbase : x.regs Cell.base = A.base) (hf : x.regs Cell.filler = WordRAM.Signed.encode A.filler) (hmem : ∀ i < A.N, x.mem (A.base + i) = WordRAM.Signed.encode (A.values i)) (hidx : GenericRAM.Signed.Fits w ↑(2 * (A.t * A.t) + A.s + 1)) (hF : GenericRAM.Signed.Fits w A.filler) (hnF : GenericRAM.Signed.Fits w (-A.filler)) (hμ : ∀ i < A.N, GenericRAM.Signed.Fits w (A.values i)) (haddr : WordRAM.Fits (w + 2) (A.base + A.N)) (habfit : WordRAM.Fits (w + 2) (A.ab + A.t * A.t)) (hbcfit : WordRAM.Fits (w + 2) (A.bc + A.t * A.t)) (hacfit : WordRAM.Fits (w + 2) (A.ac + A.t * A.t)) (hbelow : A.base + A.N ≤ A.ab) (hABBC : A.ab + A.t * A.t ≤ A.bc) (hBCAC : A.bc + A.t * A.t ≤ A.ac) :

Fill three disjoint matrices within 131t² + 5 native instructions, excluding the halt. All matrix addresses and the one-past-end addresses fit target words. The signed index bound and both signs of the filler fit the source width. The program keeps its input and parameters.