Documentation

CslibFrontier.Algorithms.WordRAM.MatrixMultiplication.Schonhage.Product.SavedGroups

Memory invariants for the saved routing arrays #

Main definitions #

Main results #

The earlier memory is a proof reference to an executed state, not program input. The native copy theorem establishes these equalities before any low-memory reuse occurs.

Values copied from the actual router state into protected caller-owned arrays.

theorem Cslib.Algorithms.WordRAM.MatrixMultiplication.Schonhage.QueriedProduct.SavedGroups.reframe {L m N Q : ℕ} {old μ ν : ℕ → ℕ} (h : SavedGroups L m N Q old μ) (hf : ∀ (a : ℕ), offsetBase L m N Q ≤ a → a < groupedBase L m N Q → ν a = μ a) :
SavedGroups L m N Q old ν

Preserving the protected readonly interval preserves the saved routing arrays.

Stable scatter covers every grouped cell, so every stored code is a valid query index. The proof uses the existing permutation theorem rather than a supplied inverse table.

theorem Cslib.Algorithms.WordRAM.MatrixMultiplication.Schonhage.QueriedProduct.SavedGroups.span_bounds {L m N Q : ℕ} {old μ : ℕ → ℕ} (h : SavedGroups L m N Q old μ) (key : ℕ → ℕ) (hoffsets : ∀ t ≤ MatrixMultiplication.Schonhage.numBands L m N ^ 2, old (Wanted.offsetAddress L m N Q + t) = Nat.count (fun (k : ℕ) => key k < t) Q) {t : ℕ} (ht : t < MatrixMultiplication.Schonhage.numBands L m N ^ 2) :
μ (offsetBase L m N Q + t) ≤ μ (offsetBase L m N Q + t + 1) ∧ μ (offsetBase L m N Q + t + 1) ≤ Q

The actual protected offset words satisfy the kernel's monotone span and count bounds. These inequalities follow from the executed prefix-count meanings, not input certificates.

theorem Cslib.Algorithms.WordRAM.MatrixMultiplication.Schonhage.QueriedProduct.SavedGroups.span_length {L m N Q : ℕ} {old μ : ℕ → ℕ} (h : SavedGroups L m N Q old μ) (key : ℕ → ℕ) (hoffsets : ∀ t ≤ MatrixMultiplication.Schonhage.numBands L m N ^ 2, old (Wanted.offsetAddress L m N Q + t) = Nat.count (fun (k : ℕ) => key k < t) Q) {t : ℕ} (ht : t < MatrixMultiplication.Schonhage.numBands L m N ^ 2) :
μ (offsetBase L m N Q + t + 1) - μ (offsetBase L m N Q + t) = Nat.count (fun (k : ℕ) => key k = t) Q

The length of a saved tile span is the number of input positions with that tile's key.

theorem Cslib.Algorithms.WordRAM.MatrixMultiplication.Schonhage.QueriedProduct.SavedGroups.position_lt_span {L m N Q : ℕ} {old μ : ℕ → ℕ} (h : SavedGroups L m N Q old μ) (key : ℕ → ℕ) (hoffsets : ∀ t ≤ MatrixMultiplication.Schonhage.numBands L m N ^ 2, old (Wanted.offsetAddress L m N Q + t) = Nat.count (fun (k : ℕ) => key k < t) Q) {t i : ℕ} (ht : t ≤ MatrixMultiplication.Schonhage.numBands L m N ^ 2) (hi : i < Q) (hk : key i < t) :
CountingSort.position key Q i < μ (offsetBase L m N Q + t)

Earlier-key positions precede a tile's saved lower offset.

theorem Cslib.Algorithms.WordRAM.MatrixMultiplication.Schonhage.QueriedProduct.SavedGroups.decode_span {L m N t : ℕ} (hm : m ≤ L) (qs : List (Fin N × Fin N)) {old μ : ℕ → ℕ} (h : SavedGroups L m N qs.length old μ) (hvalues : ∀ (i : Fin qs.length), old (Wanted.codeAddress L m N qs.length + CountingSort.position (Wanted.tileKey L m N ∘ Wanted.inputPairs qs) qs.length ↑i) = ↑(PrunedQuery.queryIndex (MatrixMultiplication.Schonhage.outStrOfPos (MatrixMultiplication.Schonhage.MaskTable.layout hm) ↑(qs.get i).1 ↑(qs.get i).2))) (hoffsets : ∀ t ≤ MatrixMultiplication.Schonhage.numBands L m N ^ 2, old (Wanted.offsetAddress L m N qs.length + t) = Nat.count (fun (k : ℕ) => (Wanted.tileKey L m N ∘ Wanted.inputPairs qs) k < t) qs.length) (ht : t < MatrixMultiplication.Schonhage.numBands L m N ^ 2) :
have B := MatrixMultiplication.Schonhage.numBands L m N; have T := (t / B, t % B); have a := μ (offsetBase L m N qs.length + t); have b := μ (offsetBase L m N qs.length + t + 1); T ∈ MatrixMultiplication.Schonhage.tiles L m N ∧ T.1 * B + T.2 = t ∧ (a ≤ b ∧ b ≤ qs.length) ∧ ∃ (queries : Fin (b - a) → MatrixMultiplication.Schonhage.OutStr L), (∀ (i : Fin (b - a)), μ (codeBase L m N qs.length + (a + ↑i)) = ↑(PrunedQuery.queryIndex (queries i))) ∧ Finset.image queries Finset.univ = MatrixMultiplication.Schonhage.wantedStrings (MatrixMultiplication.Schonhage.MaskTable.layout hm) qs.toFinset T.1 T.2

Decode the protected words at a tile's actual saved offsets. The decoded queries have exactly the original tile's finite request set, including when its span is empty.