Documentation

CslibFrontier.Foundations.Analysis.SignedDigitStream.Multiplication

Minimum-index dyadic band multiplication of signed-digit streams #

This module formalizes the minimum-index dyadic band multiplication algorithm of [OpenAI2026LogSpace, Section 10.3, Lemma 10.4].

Grouping cross-terms x_i y_j 2^{-(i+j)} by min i j into a zero band (min i j = 0) and positive dyadic bands 2 ^ k ≤ min i j < 2 ^ (k + 1) with band-specific truncation margin bandMargin k = 16 + bandStart k / 4 achieves three properties simultaneously:

  1. Scaled accuracy < 2 (mulApprox_isScaledApprox): folding the retained band sums from maxBand t down to 0 by signed floor shifts approximates 2 ^ t * (streamVal x * streamVal y) within < 2.
  2. Diagonal residue locality (mulResidue_eq_mulApprox_emod): modulo 2 ^ q, mulApprox x y t depends in band k only on diagonals t - q < i + j ≤ t + bandMargin k, propagated downward by exact signed floor shifts of residues (ediv_two_pow_emod_eq).
  3. Clock-drop latency payment (three_mul_bandStart_le_four_mul_drop): for any retained pair (i, j) in a positive band k + 1 (D = 2 ^ k), both indices satisfy 4 * j + 3 * D ≤ 4 * (t + 16), so D ≤ (4 / 3) * (t - j + 16) pays for the band circuit depth out of the clock drop t - j.

Main definitions #

Main results #

References #

Base margin h_∘ = 16 for minimum-index dyadic band multiplication.

Lower inclusive endpoint of dyadic band k (0 at k = 0, 2 ^ k at k + 1).

Upper exclusive endpoint of dyadic band k (1 at k = 0, 2 ^ (k + 1) at k + 1).

Width bandEnd k - bandStart k of dyadic band k.

Unique band index k such that bandStart k ≤ m < bandEnd k.

Band margin h_k = h_∘ + ⌊bandStart k / 4⌋ [OpenAI2026LogSpace, Section 10.3].

Logarithmic cutoff band count above which all retained bands at clock t are empty.

Retained index pairs (i, j) in band k at output clock t.

def Cslib.SignedDigitStream.bandSum (x y : ℕ → ℤ) (t k : ℕ) :

Exact mathematical integer sum S_k for band k at scale 2 ^ (t + bandMargin k) [OpenAI2026LogSpace, (10.6)].

def Cslib.SignedDigitStream.bandFold (x y : ℕ → ℤ) (t : ℕ) :
ℕ → ℤ

Downward signed floor-shift fold across the rem highest active bands below maxBand t [OpenAI2026LogSpace, (10.9)].

Scaled integer product approximation ⌊2 ^ (-h_0) F_0⌋ [OpenAI2026LogSpace, (10.9)].

Diagonal-windowed band pairs satisfying t - q < i + j ≤ t + bandMargin k [OpenAI2026LogSpace, (10.10)].

Windowed integer sum omitting terms divisible by 2 ^ (q + bandMargin k).

def Cslib.SignedDigitStream.bandFoldMod (x y : ℕ → ℤ) (t q : ℕ) :
ℕ → ℤ

Modular downward band fold maintaining only the canonical (q + bandMargin k)-bit residue.

Mod-2^q residue of mulApprox x y t computed purely from windowed band residues.

theorem Cslib.SignedDigitStream.three_mul_bandStart_le_four_mul_drop {t k : ℕ} {p : ℕ × ℕ} (hp : p ∈ bandPairs t (k + 1)) :
4 * p.1 + 3 * bandStart (k + 1) ≤ 4 * (t + mulBaseMargin) ∧ 4 * p.2 + 3 * bandStart (k + 1) ≤ 4 * (t + mulBaseMargin)

Clock-drop latency inequality [OpenAI2026LogSpace, (10.12)]: for any retained pair (i, j) in a positive band k + 1 (D = 2 ^ k), 4 * j + 3 * D ≤ 4 * (t + mulBaseMargin) (and symmetrically for i).

Every retained operand index i or j across all bands k obeys i ≤ t + mulBaseMargin and j ≤ t + mulBaseMargin.

theorem Cslib.SignedDigitStream.bandFoldMod_eq_bandFold_emod (x y : ℕ → ℤ) (t q rem : ℕ) :
rem ≤ maxBand t → bandFoldMod x y t q rem = bandFold x y t rem % 2 ^ (q + bandMargin (maxBand t - rem))

Windowed modular product residue theorem [OpenAI2026LogSpace, Lemma 10.4]: mulResidue x y t q computes the exact mod-2^q Euclidean residue of mulApprox x y t while retaining only diagonals t - q < i + j ≤ t + bandMargin k in each band.

Lemma 10.4 (scaled product approximation) [OpenAI2026LogSpace, Lemma 10.4]: for any two signed-digit streams x, y, mulApprox x y approximates streamVal x * streamVal y within scaled error < 2.