Documentation

CslibFrontier.Algorithms.WordRAM.ExactTriangle.CallableFixedPrime.InputSpec

Original-word sum and copied-input meaning #

The runtime copy loop computes the sum of exactly the three original matrix spans. That sum bounds every signed input magnitude and is polynomial under the original weight hypothesis. It is not supplied as a certificate or computed by an uncharged preprocessing operation.

Sum accumulated by the three native matrix copies, in original row-major order.

theorem Cslib.Algorithms.WordRAM.ExactTriangle.CallableFixedPrime.rawTotal_split (n : ℕ) (values : List ℤ) :
rawTotal n values = ∑ q ∈ Finset.range (n * n), WordRAM.Signed.encode (values.getD q 0) + ∑ q ∈ Finset.range (n * n), WordRAM.Signed.encode (values.getD (n * n + q) 0) + ∑ q ∈ Finset.range (n * n), WordRAM.Signed.encode (values.getD (2 * (n * n) + q) 0)

No additional scan of the matrices is needed: the three copy accumulators concatenate.

theorem Cslib.Algorithms.WordRAM.ExactTriangle.CallableFixedPrime.natAbs_le_rawTotal {n : ℕ} (values : List ℤ) (hlen : values.length = 3 * (n * n)) (z : ℤ) (hz : z ∈ values) :
z.natAbs ≤ rawTotal n values

Every original integer fits the magnitude supplied by the actual word accumulator.

theorem Cslib.Algorithms.WordRAM.ExactTriangle.CallableFixedPrime.rawTotal_le {n A : ℕ} (values : List ℤ) (hlen : values.length = 3 * (n * n)) (hv : ∀ z ∈ values, z.natAbs ≤ A) :
rawTotal n values ≤ 3 * (n * n) * (2 * A + 1)

Original polynomial weight bounds also bound the computed runtime word sum.

theorem Cslib.Algorithms.WordRAM.ExactTriangle.CallableFixedPrime.headerMemory_below (mem : ℕ → ℕ) (b n D g p q : ℕ) (hq : q < b) :
headerMemory mem b n D g p q = mem q

Scalar stores do not change the caller prefix.

theorem Cslib.Algorithms.WordRAM.ExactTriangle.CallableFixedPrime.headerMemory_outside (mem : ℕ → ℕ) (b n D g p q : ℕ) (hq : q < b ∨ b + 5 ≤ q) :
headerMemory mem b n D g p q = mem q

The scalar header writes exactly five cells.

Memory after the actual five header stores and three square copies.

theorem Cslib.Algorithms.WordRAM.ExactTriangle.CallableFixedPrime.copyMemory_below (mem : ℕ → ℕ) (b n D g p ab bc ac q : ℕ) (hq : q < b) :
copyMemory mem b n D g p ab bc ac q = mem q

The actual copied spans never change the original caller prefix.

theorem Cslib.Algorithms.WordRAM.ExactTriangle.CallableFixedPrime.copyMemory_outside (mem : ℕ → ℕ) (b n D g p ab bc ac q : ℕ) (hq : q < b ∨ b + 5 + 3 * (n * n) ≤ q) :
copyMemory mem b n D g p ab bc ac q = mem q

Input adaptation touches only its five header words and three original squares.

theorem Cslib.Algorithms.WordRAM.ExactTriangle.CallableFixedPrime.copyMemory_payload {n b D g p ab bc ac : ℕ} (mem : ℕ → ℕ) (values : List ℤ) (hab : ab + n * n ≤ b) (hbc : bc + n * n ≤ b) (hac : ac + n * n ≤ b) (vab : ∀ q < n * n, mem (ab + q) = WordRAM.Signed.encode (values.getD q 0)) (vbc : ∀ q < n * n, mem (bc + q) = WordRAM.Signed.encode (values.getD (n * n + q) 0)) (vac : ∀ q < n * n, mem (ac + q) = WordRAM.Signed.encode (values.getD (2 * (n * n) + q) 0)) (q : ℕ) (hq : q < 3 * (n * n)) :
copyMemory mem b n D g p ab bc ac (b + 5 + q) = WordRAM.Signed.encode (values.getD q 0)

The three real copies preserve canonical signed encoding and original matrix order. Their source arrays may alias one another; every source span precedes caller workspace.

theorem Cslib.Algorithms.WordRAM.ExactTriangle.CallableFixedPrime.copyMemory_input {n b D g p ab bc ac : ℕ} (mem : ℕ → ℕ) (values : List ℤ) (hlen : values.length = 3 * (n * n)) (hab : ab + n * n ≤ b) (hbc : bc + n * n ≤ b) (hac : ac + n * n ≤ b) (vab : ∀ q < n * n, mem (ab + q) = WordRAM.Signed.encode (values.getD q 0)) (vbc : ∀ q < n * n, mem (bc + q) = WordRAM.Signed.encode (values.getD (n * n + q) 0)) (vac : ∀ q < n * n, mem (ac + q) = WordRAM.Signed.encode (values.getD (2 * (n * n) + q) 0)) (q : ℕ) (hq : q < 5 + 3 * (n * n)) :
copyMemory mem b n D g p ab bc ac (b + q) = (WordRAM.Data.init (PreparationInput.input n D g p values)).mem q

The copied words form exactly the existing initialized input block. This is readback of actual stores and copies, not an input layout supplied to the algorithm.