Documentation

CslibFrontier.Algorithms.WordRAM.ExactTriangle.InstancePair

Native matrix pairs and instance records #

One call writes a six-word record (rho,piece,queries,count,X,Y) and the actual raw unsigned zero/one matrices X : n×D and Y : D×n immediately after it. Both matrices reuse WriteMatrices.program; all pointer arithmetic, argument delivery and record stores are charged. The query words remain in the earlier computed catalogue and are shared by reference.

setup, writeHeader, deliverLeft, deliverRight and matrix are internal program stages. They are exposed so that the complete catalogue controller can reuse the same fixed program.

Main definitions #

Main results #

@[reducible, inline]

Computed A–C residue-array pointer.

@[reducible, inline]

Computed B–C residue-array pointer.

@[reducible, inline]

First word of the instance record.

@[reducible, inline]

Outer matrix dimension.

@[reducible, inline]

Padded middle matrix dimension.

@[reducible, inline]

Positive residue modulus.

@[reducible, inline]

First original vertex in the piece.

@[reducible, inline]

Actual number of vertices in the piece.

@[reducible, inline]

Query residue.

@[reducible, inline]

Actual query-pair pointer.

@[reducible, inline]

Actual number of query pairs.

@[reducible, inline]

Index of the original piece.

@[reducible, inline]

Constant one, preserved by both matrix calls.

@[reducible, inline]

Header cursor.

@[reducible, inline]

Number of words in one matrix.

Existing left-matrix arguments, with its output following the six-word record.

Existing right-matrix arguments, immediately following the left matrix.

Compute the left output pointer and matrix area with native arithmetic.

Write the actual query reference and both computed matrix pointers.

Deliver the seven remaining left-matrix arguments; its destination is already computed.

The left writer preserves its argument registers, so only the source and output pointer change for the right call.

Reuse either native matrix writer in the lower seventeen registers.

Finite code independent of every runtime dimension and physical width.

Six raw unsigned record words: residue, piece index, shared query pointer/count, then the two computed matrix pointers. Matrix entries themselves are raw zero/one words.

theorem Cslib.Algorithms.WordRAM.ExactTriangle.InstancePair.exec {w : ℕ} (x : WordRAM.Data 32) (L R : ℕ → ℕ) (hrho : x.regs rho < x.regs modulus) (hpiece : x.regs first + x.regs length ≤ x.regs size) (hL : ∀ i < x.regs size * x.regs size, L i < x.regs modulus) (hR : ∀ i < x.regs size * x.regs size, R i < x.regs modulus) (hleft : ∀ i < x.regs size * x.regs size, x.mem (x.regs srcLeft + i) = L i) (hright : ∀ i < x.regs size * x.regs size, x.mem (x.regs srcRight + i) = R i) (hsL : x.regs srcLeft + x.regs size * x.regs size ≤ x.regs base) (hsR : x.regs srcRight + x.regs size * x.regs size ≤ x.regs base) (hfit : WordRAM.Fits w (x.regs base + 6 + 2 * (x.regs size * x.regs dimension) + x.regs srcLeft + x.regs srcRight + 2 * (x.regs size * x.regs size) + 2 * x.regs modulus + 7)) :
∃ (y : WordRAM.Data 32), WordRAM.ExecWithin w program x y (40 * (x.regs size * x.regs dimension) + 38) ∧ { base := x.regs base, length := 6 }.Realizes y.mem (recordWords x) ∧ ({ base := (leftArgs x).dst, length := x.regs size * x.regs dimension }.Realizes y.mem fun (i : Fin { base := (leftArgs x).dst, length := x.regs size * x.regs dimension }.length) => WriteMatrices.entry false (leftArgs x) L ↑i) ∧ ({ base := (rightArgs x).dst, length := x.regs size * x.regs dimension }.Realizes y.mem fun (i : Fin { base := (rightArgs x).dst, length := x.regs size * x.regs dimension }.length) => WriteMatrices.entry true (rightArgs x) R ↑i) ∧ ∀ (a : ℕ), ¬(x.regs base ≤ a ∧ a < x.regs base + 6 + 2 * (x.regs size * x.regs dimension)) → y.mem a = x.mem a

Write both actual matrices and their shared-query instance record. The source arrays are ordinary residue words before the output region. Existing WriteMatrices.entry supplies the semantics; no adjacency array, execution or time contract is an input. Halt is excluded.