Documentation

CslibFrontier.Algorithms.WordRAM.ExactTriangle.RecordProduct.Readback

Pure source-span readback for either record product #

prepared_record gives the prepared record, raw matrix blocks, and query coordinates. producer_readback relates these to the original words of the queried product input. The readback includes the six-word record descriptor, raw left and right zero/one matrix spans, ordered query-coordinate words, heap bounds and occurrence sparsity from a genuine Instances.Output, without importing or executing either per-record product backend. raw_left_block and raw_right_block read a record's realized raw matrix blocks as the ordinary product's original input; producer_readback and the box record caller both use them.

The raw descriptor and matrix blocks of one prepared record, together with its protected query coordinates. The coordinates lie before the producer's record region.

theorem Cslib.Algorithms.WordRAM.ExactTriangle.RecordProduct.prepared_record {n D g p : ℕ} (values : ℕ → ℤ) {initial y : WordRAM.Data 64} (h : Instances.Output n D g p values initial y) (hD : 16 ≤ D) (hDn : D ≤ n) (hg : 1 ≤ g) (hp : p ≠ 0) (idx : ExactTriangle.InstanceIndex p) (hidx : idx ∈ ExactTriangle.instanceIndices (fun (a b : Fin n) => values (Matrix.pairIndex (a, b))) D g p) :
PreparedRecord n D g p values y idx (y.regs Instances.output + recordOrdinal n D g p values idx * (6 + 2 * (n * D)))

A finite instance selects an actual record and intact query span in the producer output.

theorem Cslib.Algorithms.WordRAM.ExactTriangle.RecordProduct.raw_left_block {m n g p s : ℕ} (values : ℕ → ℤ) (idx : ExactTriangle.InstanceIndex p) (mem : ℕ → ℕ) (qs : List (Fin n × Fin n)) (hleft : { base := s, length := n * MatrixMultiplication.Schonhage.D m }.Realizes mem fun (j : Fin { base := s, length := n * MatrixMultiplication.Schonhage.D m }.length) => WriteMatrices.entry false (matrixArgs n (MatrixMultiplication.Schonhage.D m) g p (↑idx.residue) idx.piece) (fun (q : ℕ) => (values (2 * (n * n) + q) % ↑p).toNat) ↑j) (a : ℕ) :
a < n * MatrixMultiplication.Schonhage.D m → mem (s + a) = (WordRAM.State.init (MatrixMultiplication.Schonhage.QueriedProduct.input true (19 * m) (leftMatrix m n g p values idx) (rightMatrix m n g p values idx) qs)).data.mem (5 + a)

A record's raw left block, as written by the producer, reads as the original left input of the ordinary queried product.

theorem Cslib.Algorithms.WordRAM.ExactTriangle.RecordProduct.raw_right_block {m n g p t : ℕ} (hn : 0 < n) (values : ℕ → ℤ) (idx : ExactTriangle.InstanceIndex p) (mem : ℕ → ℕ) (qs : List (Fin n × Fin n)) (hright : { base := t, length := n * MatrixMultiplication.Schonhage.D m }.Realizes mem fun (j : Fin { base := t, length := n * MatrixMultiplication.Schonhage.D m }.length) => WriteMatrices.entry true (matrixArgs n (MatrixMultiplication.Schonhage.D m) g p (↑idx.residue) idx.piece) (fun (q : ℕ) => (values (n * n + q) % ↑p).toNat) ↑j) (a : ℕ) :

A record's raw right block, in its D×n storage order, reads as the original right input of the ordinary queried product.

theorem Cslib.Algorithms.WordRAM.ExactTriangle.RecordProduct.producer_readback {m n g p : ℕ} (values : ℕ → ℤ) (initial : WordRAM.Data 64) (x : WordRAM.Data 320) (h : Instances.Output n (MatrixMultiplication.Schonhage.D m) g p values initial (WordRAM.Data.comap producerBank x)) (hD : 16 ≤ MatrixMultiplication.Schonhage.D m) (hg : 1 ≤ g) (hp : p ≠ 0) (hN : MatrixMultiplication.Schonhage.D m ^ 18 ≤ n) (hheaderD : initial.mem 1 = MatrixMultiplication.Schonhage.D m) (hheaderN : initial.mem 3 = n) (idx : ExactTriangle.InstanceIndex p) (hidx : idx ∈ ExactTriangle.instanceIndices (fun (a b : Fin n) => values (Matrix.pairIndex (a, b))) (MatrixMultiplication.Schonhage.D m) g p) :
have hn := ⋯; have ord := recordOrdinal n (MatrixMultiplication.Schonhage.D m) g p values idx; have base := x.regs 39 + ord * (6 + 2 * (n * MatrixMultiplication.Schonhage.D m)); have q := recordQueries n (MatrixMultiplication.Schonhage.D m) p idx; have qs := decodedQueries hn x.mem q (recordQueryCount n (MatrixMultiplication.Schonhage.D m) p values idx); x.mem 1 = MatrixMultiplication.Schonhage.D m ∧ x.mem 3 = n ∧ base + 6 ≤ x.regs 42 ∧ { base := base, length := 6 }.Realizes x.mem ![↑idx.residue, idx.piece, q, qs.length, base + 6, base + 6 + n * MatrixMultiplication.Schonhage.D m] ∧ base + 6 + n * MatrixMultiplication.Schonhage.D m ≤ x.regs 42 ∧ base + 6 + n * MatrixMultiplication.Schonhage.D m + n * MatrixMultiplication.Schonhage.D m ≤ x.regs 42 ∧ q + 2 * qs.length ≤ x.regs 42 ∧ (∀ a < n * MatrixMultiplication.Schonhage.D m, x.mem (base + 6 + a) = (WordRAM.State.init (MatrixMultiplication.Schonhage.QueriedProduct.input true (19 * m) (leftMatrix m n g p values idx) (rightMatrix m n g p values idx) qs)).data.mem (5 + a)) ∧ (∀ a < n * MatrixMultiplication.Schonhage.D m, x.mem (base + 6 + n * MatrixMultiplication.Schonhage.D m + a) = (WordRAM.State.init (MatrixMultiplication.Schonhage.QueriedProduct.input true (19 * m) (leftMatrix m n g p values idx) (rightMatrix m n g p values idx) qs)).data.mem (5 + n * MatrixMultiplication.Schonhage.D m + a)) ∧ (∀ a < 2 * qs.length, x.mem (q + a) = (WordRAM.State.init (MatrixMultiplication.Schonhage.QueriedProduct.input true (19 * m) (leftMatrix m n g p values idx) (rightMatrix m n g p values idx) qs)).data.mem (5 + 2 * (n * MatrixMultiplication.Schonhage.D m) + a)) ∧ qs.length * 2 ^ m ≤ n ^ 2

Derive both raw source matrices, ordered coordinate words, protected spans and occurrence sparsity from genuine producer output, without invoking either product backend.