The packed same-lattice certificate: decide M * A = C and hence
sameLatticeCert over integer arithmetic by comparing rows packed as
single big integers in balanced base 2 ^ K, never forming the matrix
product.
Horner evaluation of an integer digit list at base P.
Equations
- Hex.Internal.packDigits P [] = 0
- Hex.Internal.packDigits P (x_1 :: xs) = x_1 + P * Hex.Internal.packDigits P xs
Instances For
Pack the entries of a row as one integer in balanced base 2^K.
Equations
- Hex.Internal.packRow K v = Hex.Internal.packDigits (2 ^ K) v.toList
Instances For
Maximum absolute value of the entries of an integer matrix.
Equations
- Hex.Internal.maxAbs M = List.foldl (fun (acc : Nat) (row : Vector Int m) => acc.max (List.foldl (fun (a : Nat) (x : Int) => a.max x.natAbs) 0 row.toList)) 0 M.rows.toList
Instances For
Digit width at which every entry of M * A and of C packs injectively:
2 · |entry| < 2^K for all entries, since each is bounded by
n · maxAbs M · maxAbs A + maxAbs C.
Equations
- Hex.Internal.packWidth M A C = (n * Hex.Internal.maxAbs M * Hex.Internal.maxAbs A + Hex.Internal.maxAbs C).log2 + 2
Instances For
Packed product-equality certificate: decides M * A = C without forming
the product. Each row of A and of C is packed into one integer in
balanced base 2^K at the width packWidth M A C, and row i of the
(unformed) product is compared via the single packed dot product
Σ_l M[i][l] · packA[l]: n big-integer dot products in place of the
n · m entry dot products of a materialized Matrix.mul.
When the entries are word-scale the multiplications are big-by-small and the
same-lattice clause costs O(n²) big-by-small multiplications; on wide
entries the packed dot products cost the same bit operations as the
materialized product. Either way the single packed comparison decides exactly
M * A = C (mulEqCert_iff).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Packing is linear over a coefficient-times-row update.
The packed dot product evaluates to the pack of the corresponding row of
the (unformed) product M * A.
Uniqueness of the balanced base-2^K representation: digit lists of equal
length whose digits all satisfy 2 · |digit| < 2^K pack injectively.
The packed certificate decides product equality: sound (= true implies
M * A = C, by balanced-digit uniqueness at width packWidth M A C) and
complete (M * A = C implies = true, by congruence through
dotProduct_packRow).
Executable same-lattice certificate: two integer transforms that multiply
the bases into each other. Each product equality is verified by the packed
certificate mulEqCert, so neither product matrix is ever formed.
Equations
- B.sameLatticeCert B' U V = (Hex.Internal.mulEqCert U B B' && Hex.Internal.mulEqCert V B' B)
Instances For
Soundness of sameLatticeCert: accepted certificates prove identical
integer row lattices.