Composing a proved record product with candidate verification #
exec_after_product composes a supplied 320-register product execution with the native witness
consumer on an occupied record from Instances.Output. The product premise supplies its returned
result offset, exact signed matrix-product answers, outside-window memory frame and preserved
registers below 65; concrete callers such as RecordWitness.Exec and BoxRecordWitness.Exec
discharge that premise with their compiled product programs.
theorem Cslib.Algorithms.WordRAM.ExactTriangle.RecordWitness.exec_after_product {w U m n g p : ℕ} (values : ℕ → ℤ) (AB BC AC : ℕ → ℕ → ℤ) (initial : WordRAM.Data 64) (x : WordRAM.Data 400) (h :
Instances.Output n (MatrixMultiplication.Schonhage.D m) g p values initial
(WordRAM.Data.comap RecordProduct.producerBank (WordRAM.Data.comap productBank 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) (hheaderG : initial.mem 2 = g) (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) (hi :
x.regs (productBank RecordProduct.Reg.ordinal) = RecordProduct.recordOrdinal n (MatrixMultiplication.Schonhage.D m) g p values idx) (hmem :
∀ a < n,
∀ b < n,
x.mem (5 + (a * n + b)) = WordRAM.Signed.encode (AB a b) ∧ x.mem (5 + n * n + (a * n + b)) = WordRAM.Signed.encode (BC a b) ∧ x.mem (5 + n * n + n * n + (a * n + b)) = WordRAM.Signed.encode (AC a b)) (hmag : ∀ a < n, ∀ b < n, (AB a b).natAbs ≤ U ∧ (BC a b).natAbs ≤ U ∧ (AC a b).natAbs ≤ U) (hU : GenericRAM.Signed.Fits w ↑(2 * U)) (product : WordRAM.Code WordRAM.Basis.standard 320) (T offset : ℕ) (hproduct :
have hn := ⋯;
have q := RecordProduct.recordQueries n (MatrixMultiplication.Schonhage.D m) p idx;
have Q := RecordProduct.recordQueryCount n (MatrixMultiplication.Schonhage.D m) p values idx;
have qs := RecordProduct.decodedQueries hn x.mem q Q;
∃ (r : WordRAM.Data 320),
WordRAM.ExecWithin (w + 2) product (WordRAM.Data.comap productBank x) r T ∧ r.regs RecordProduct.Reg.result = x.regs (productBank 42) + offset ∧ (∀ (j : Fin qs.length),
r.mem (x.regs (productBank 42) + offset + ↑j) = WordRAM.Signed.encode
((RecordProduct.leftMatrix m n g p values idx * RecordProduct.rightMatrix m n g p values idx)
(qs.get j).1 (qs.get j).2)) ∧ (∀ (u : ℕ),
u < x.regs (productBank 42) ∨ x.regs (productBank 42) + MatrixMultiplication.Schonhage.CallableProduct.windowSize n Q ≤ u →
r.mem u = x.mem u) ∧ ∀ (j : Fin 320), ↑j < 65 → r.regs j = x.regs (productBank j)) (hfit :
WordRAM.Fits (w + 2)
(witnessWindow n (MatrixMultiplication.Schonhage.D m) g (x.regs (productBank 42))
(RecordProduct.recordQueryCount n (MatrixMultiplication.Schonhage.D m) p values idx) offset)) :
WitnessPost ((WordRAM.Code.rename productBank product).seq consume) hD hN values AB BC AC x idx
fun (x : List (Fin n × Fin n)) => T
Compose a proved product execution with the real consumer. The actual result offset, exact signed answers, outside-window frame and producer registers are the only product postconditions used. Concrete callers discharge this premise with their actual programs.