Actual query preparation from original input words #
The native adaptation reads all four headers and computes both array pointers. The existing complete box-table constructor then builds the shared directory, descriptors and every retained value. The same final state supplies all memory readback consumed by the query; no geometry, execution, time or table certificate is supplied.
theorem Cslib.Algorithms.WordRAM.MatrixMultiplication.Schonhage.BoxQuery.exec_inputHeaders {w L m t Q : ℕ} (x : WordRAM.Data registers) (hL : x.mem 1 = L) (hm : x.mem 2 = m) (ht : x.mem 3 = t) (hQ : x.mem 4 = Q) (hfit : WordRAM.Fits w 4) :
∃ (y : WordRAM.Data registers),
WordRAM.ExecWithin w inputHeaders x y 8 ∧ y.regs BoxTable.Reg.levels = L ∧ y.regs BoxTable.Reg.inner = m ∧ y.regs BoxTable.Reg.threshold = t ∧ y.regs Reg.query = Q ∧ y.mem = x.mem
Read the four actual scalar input words, leaving memory unchanged.
theorem Cslib.Algorithms.WordRAM.MatrixMultiplication.Schonhage.BoxQuery.exec_loadInput {w L m t Q : ℕ} (x : WordRAM.Data registers) (hL : x.mem 1 = L) (hm : x.mem 2 = m) (ht : x.mem 3 = t) (hQ : x.mem 4 = Q) (hfit : WordRAM.Fits w (2 * 10 ^ L + L + 16)) :
∃ (y : WordRAM.Data registers),
WordRAM.ExecWithin w loadInput x y (4 * L + 21) ∧ y.regs BoxTable.Reg.levels = L ∧ y.regs BoxTable.Reg.inner = m ∧ y.regs BoxTable.Reg.threshold = t ∧ y.regs Reg.query = Q ∧ y.regs BoxTable.Reg.arrayA = 5 ∧ y.regs BoxTable.Reg.arrayB = 5 + 10 ^ L ∧ y.regs BoxTable.Reg.directory = directoryBase L ∧ y.mem = x.mem
Complete original-input adaptation computes the actual span and array/directory pointers.
theorem Cslib.Algorithms.WordRAM.MatrixMultiplication.Schonhage.BoxQuery.exec_prepare {w L m t A B : ℕ} (hmL : m ≤ L) (x : WordRAM.Data registers) (q : Fin (10 ^ L)) (a b : Fin (10 ^ L) → ℤ) (ha : ∀ (i : Fin (10 ^ L)), (a i).natAbs ≤ A) (hb : ∀ (i : Fin (10 ^ L)), (b i).natAbs ≤ B) (hL : x.mem 1 = L) (hm : x.mem 2 = m) (ht : x.mem 3 = t) (hQ : x.mem 4 = ↑q) (hleft : ∀ (i : Fin (10 ^ L)), x.mem (5 + ↑i) = WordRAM.Signed.encode (a i)) (hright : ∀ (i : Fin (10 ^ L)), x.mem (5 + 10 ^ L + ↑i) = WordRAM.Signed.encode (b i)) (haddr : WordRAM.Fits (w + 2) (originalAddressBound L m t)) (hmag : GenericRAM.Signed.Fits w ↑(magnitudeBound L A B)) :
∃ (y : WordRAM.Data registers),
WordRAM.ExecWithin (w + 2) prepare x y (preparationTime L m t) ∧ y.regs BoxTable.Reg.levels = L ∧ y.regs BoxTable.Reg.inner = m ∧ y.regs BoxTable.Reg.threshold = t ∧ y.regs Reg.query = ↑q ∧ y.regs BoxTable.Reg.height = m - t ∧ y.regs BoxTable.Reg.span = 10 ^ L ∧ y.regs BoxTable.Reg.directory = directoryBase L ∧ y.regs BoxTable.Reg.records = recordBase L m t ∧ y.regs BoxTable.Reg.values = valueBase L m t ∧ y.regs BoxTable.Reg.count = (MatrixMultiplication.Schonhage.boxes L m t).card ∧ y.regs BoxTable.Reg.arrayA = 5 ∧ y.regs BoxTable.Reg.arrayB = 5 + 10 ^ L ∧ Readback m t (directoryBase L) (valueBase L m t) 5 (5 + 10 ^ L)
(fun (τ : MatrixMultiplication.Schonhage.Leaf L) => a (Encoding.leafIndex τ))
(fun (τ : MatrixMultiplication.Schonhage.Leaf L) => b (Encoding.leafIndex τ)) y.mem ∧ ∀ (p : ℕ), ¬(directoryBase L ≤ p ∧ p < stackBase L m t) → y.mem p = x.mem p
Prepare the real query table from original caller words and canonical signed leaf arrays.
theorem Cslib.Algorithms.WordRAM.MatrixMultiplication.Schonhage.BoxQuery.exec_prepare_input {w L m t A B : ℕ} (hmL : m ≤ L) (q : Fin (10 ^ L)) (a b : Fin (10 ^ L) → ℤ) (ha : ∀ (i : Fin (10 ^ L)), (a i).natAbs ≤ A) (hb : ∀ (i : Fin (10 ^ L)), (b i).natAbs ≤ B) (haddr : WordRAM.Fits (w + 2) (originalAddressBound L m t)) (hmag : GenericRAM.Signed.Fits w ↑(magnitudeBound L A B)) :
WordRAM.InputFits (w + 2) (input L m t q a b) ∧ ∃ (y : WordRAM.Data registers),
WordRAM.ExecWithin (w + 2) prepare (WordRAM.State.init (input L m t q a b)).data y (preparationTime L m t) ∧ WordRAM.Data.Bounded (w + 2) y ∧ y.regs BoxTable.Reg.levels = L ∧ y.regs BoxTable.Reg.inner = m ∧ y.regs BoxTable.Reg.threshold = t ∧ y.regs Reg.query = ↑q ∧ y.regs BoxTable.Reg.height = m - t ∧ y.regs BoxTable.Reg.span = 10 ^ L ∧ y.regs BoxTable.Reg.directory = directoryBase L ∧ y.regs BoxTable.Reg.records = recordBase L m t ∧ y.regs BoxTable.Reg.values = valueBase L m t ∧ y.regs BoxTable.Reg.count = (MatrixMultiplication.Schonhage.boxes L m t).card ∧ y.regs BoxTable.Reg.arrayA = 5 ∧ y.regs BoxTable.Reg.arrayB = 5 + 10 ^ L ∧ Readback m t (directoryBase L) (valueBase L m t) 5 (5 + 10 ^ L)
(fun (τ : MatrixMultiplication.Schonhage.Leaf L) => a (Encoding.leafIndex τ))
(fun (τ : MatrixMultiplication.Schonhage.Leaf L) => b (Encoding.leafIndex τ))
y.mem ∧ ∀ (p : ℕ),
¬(directoryBase L ≤ p ∧ p < stackBase L m t) →
y.mem p = (WordRAM.State.init (input L m t q a b)).data.mem p
Actual initialized preparation derives input fit and bounded final data while exposing the same native table witness consumed by the subsequent query.