NLA-lib Explorer

Embeddings and sketch guarantees

The right sketch property depends on what the algorithm must preserve. A subspace embedding preserves all vector norms in one subspace. Approximate matrix multiplication controls a product, while projection-cost preservation supports comparisons between low-rank subspaces.

Definition (Subspace embedding). A matrix \mathbf{S} is an embedding of a subspace V with squared-norm distortion \varepsilon if

(1-\varepsilon)\|\mathbf{x}\|_2^2\le\|\mathbf{S}\mathbf{x}\|_2^2\le(1+\varepsilon)\|\mathbf{x}\|_2^2\qquad\text{for every }\mathbf{x}\in V.

An oblivious distribution chooses \mathbf{S} independently of the fixed target subspace, with a stated success probability. The dimension and probability requirements differ among sketch laws.

Copy link

Background

Results

Theorem (AMM with a CountSketch).

, the bound \mathbb{E}\|\mathbf{A}^{\mathsf{H}}\mathbf{S}^{\mathsf{H}}\mathbf{S}\mathbf{B} - \mathbf{A}^{\mathsf{H}}\mathbf{B}\|_{\mathsf{F}}^2 \le \frac{2\|\mathbf{A}\|_{\mathsf{F}}^2\|\mathbf{B}\|_{\mathsf{F}}^2}{\lvert k \rvert}\,, over any field. [Woodruff2014, Theorems 13 and 14] (there 3\varepsilon through the JL moment, over \mathbb{R}).

General form: sizes are index types

Lean statement and details
NLAlib.integral_frobNorm_conjTranspose_mul_sub_sq_le_of_hasLaw_countSketch.{u_1, u_2, u_3, u_4, u_5,
    u_6}
  {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {𝕜 : Type u_2} [RCLike 𝕜] {k : Type u_3}
  {n : Type u_4} {q : Type u_5} {r : Type u_6} [Fintype k] [Fintype n] [DecidableEq k]
  {S : Ω → Matrix k n 𝕜} [Fintype q] [Fintype r] (hS : HasLaw S (countSketch k n) μ)
  (A : Matrix n q 𝕜) (B : Matrix n r 𝕜) :
  ∫ (ω : Ω), frobNorm (Aᴴ * (S ω)ᴴ * S ω * B - Aᴴ * B) ^ 2 ∂μ ≤
    2 * frobNorm A ^ 2 * frobNorm B ^ 2 / ↑(Fintype.card k)

Full source on GitHub

Copy link

Theorem (Approximate matrix multiplication from the JL moment property).

for a real sketch with the (\varepsilon, \delta, p) JL moment property, \varepsilon \ge 0, p \ge 2, \mathbb{E}\|\mathbf{A}^{\mathsf{H}}\mathbf{S}^{\mathsf{H}}\mathbf{S}\mathbf{B} - \mathbf{A}^{\mathsf{H}}\mathbf{B}\|_{\mathsf{F}}^p \le (\varepsilon \|\mathbf{A}\|_{\mathsf{F}} \|\mathbf{B}\|_{\mathsf{F}})^p \delta\,. [Woodruff2014, Theorem 13]; Woodruff has 3 \varepsilon; the constant 1 here is optimal (\mathbf{S}^{\mathsf{H}}\mathbf{S} = (1 + \varepsilon)\mathbf{I} attains it). Over \mathbb{R} only: over \mathbb{C} the hypothesis gives only \sqrt{2}\,\varepsilon, sharply, as \mathbf{E} = \mathbf{S}^{\mathsf{H}}\mathbf{S} - \mathbf{I} = c (\xi_1 \boldsymbol{\sigma}_x + \xi_2 \boldsymbol{\sigma}_y) shows (Rademacher \xi_1, \xi_2, Pauli \boldsymbol{\sigma}_x, \boldsymbol{\sigma}_y, c \le 1/\sqrt{2}: \mathbb{E}(\mathbf{x}^{\mathsf{H}}\mathbf{E}\mathbf{x})^2 \le c^2 \|\mathbf{x}\|^4, \mathbb{E}\lvert\mathbf{e}_1^{\mathsf{H}}\mathbf{E}\mathbf{e}_2\rvert^2 = 2 c^2).

Lean statement and details
NLAlib.HasJLMoment.integral_frobNorm_conjTranspose_mul_sub_rpow_le.{u_1, u_2, u_3, u_4, u_5}
  {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {k : Type u_2} {n : Type u_3}
  {q : Type u_4} {r : Type u_5} [Fintype k] [Fintype n] [Fintype q] [Fintype r]
  {S : Ω → Matrix k n ℝ} {ε δ p : ℝ} (h : HasJLMoment S ε δ p μ) (hε : 0 ≤ ε) (hp : 2 ≤ p)
  (hS : AEMeasurable S μ) (A : Matrix n q ℝ) (B : Matrix n r ℝ) :
  ∫ (ω : Ω), frobNorm (Aᴴ * (S ω)ᴴ * S ω * B - Aᴴ * B) ^ p ∂μ ≤
    (ε * frobNorm A * frobNorm B) ^ p * δ

Full source on GitHub

Copy link

Theorem (Approximate matrix multiplication by sampling, domination form).

if \|\mathbf{A}_i\| \, \|\mathbf{B}_i\| \le L p_i for every row, with k nonempty, \mathbb{E} \|\mathbf{A}^{\mathsf{H}} \mathbf{S}^{\mathsf{H}} \mathbf{S} \mathbf{B} - \mathbf{A}^{\mathsf{H}} \mathbf{B}\|_{\mathsf{F}}^2 \le \frac{L \|\mathbf{A}\|_{\mathsf{F}} \|\mathbf{B}\|_{\mathsf{F}}}{\lvert k \rvert} \,. Zero weights are allowed. At the optimal weights p_i \propto \|\mathbf{A}_i\| \, \|\mathbf{B}_i\|, where L = \sum_i \|\mathbf{A}_i\| \, \|\mathbf{B}_i\|, this is \|\mathbf{A}\|_{\mathsf{F}}^2 \|\mathbf{B}\|_{\mathsf{F}}^2 / \lvert k \rvert by Cauchy–Schwarz, and \beta-approximations of them have L = W/\beta, with W that sum. [MartinssonTropp2020, §7.1]; Drineas, Kannan and Mahoney 2006, Lemma 4 (citation to confirm). There the bound is \|\mathbf{A}\|_{\mathsf{F}}^2 \|\mathbf{B}\|_{\mathsf{F}}^2 / (\beta \lvert k \rvert).

General form: sizes are index types

Lean statement and details
NLAlib.integral_frobNorm_conjTranspose_mul_sub_sq_le_of_hasLaw_samplingSketch.{u_1, u_2, u_3, u_4,
    u_5, u_6}
  {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {𝕜 : Type u_2} [RCLike 𝕜] {k : Type u_3}
  {n : Type u_4} {q : Type u_5} {r : Type u_6} [Fintype k] [Fintype n] [Fintype q] [Fintype r]
  [DecidableEq n] {S : Ω → Matrix k n 𝕜} {p : n → ℝ≥0} {A : Matrix n q 𝕜} {B : Matrix n r 𝕜} {L : ℝ}
  [Nonempty k] (hS : HasLaw S (samplingSketch k p) μ) (hp : ∑ i, p i = 1)
  (hdom : ∀ (i : n), ‖WithLp.toLp 2 (A i)‖ * ‖WithLp.toLp 2 (B i)‖ ≤ L * ↑(p i)) :
  ∫ (ω : Ω), frobNorm (Aᴴ * (S ω)ᴴ * S ω * B - Aᴴ * B) ^ 2 ∂μ ≤
    L * frobNorm A * frobNorm B / ↑(Fintype.card k)

Full source on GitHub

Copy link

Theorem (Approximate matrix multiplication in the spectral norm by row sampling).

for k and r nonempty, weights p summing to 1 with \|\mathbf{A}_i\|^2 \le a p_i and \|\mathbf{B}_i\|^2 \le b p_i for every row i, a, b \ge 0, the row-sampling sketch \mathbf{S} with \lvert k\rvert i.i.d. rows drawn with probabilities p, and t \ge 0, \mathbb{P}\bigl[t \le \|\mathbf{A}^{\mathsf{H}}\mathbf{S}^{\mathsf{H}}\mathbf{S}\mathbf{B} - \mathbf{A}^{\mathsf{H}}\mathbf{B}\|_2\bigr] \le (\lvert q\rvert + \lvert r\rvert) \exp\Bigl(-\frac{\lvert k\rvert t^2/2}{\max(b\|\mathbf{A}\|_2^2, a\|\mathbf{B}\|_2^2) + 2\sqrt{ab}\,t/3}\Bigr)\,. Rectangular matrix Bernstein (NLAlib.measureReal_specNorm_sum_ge_le_bernstein) for the centred atoms. At p_i \propto \|\mathbf{A}_i\|^2 + \|\mathbf{B}_i\|^2 this is the stable-rank form. [MartinssonTropp2020, §7.3, Theorem 7.2]; [Tropp2015, §6.4] (locator of the corollary to check).

General form: sizes are index types

Lean statement and details
NLAlib.measureReal_specNorm_conjTranspose_mul_sub_ge_le_of_hasLaw_samplingSketch.{u_1, u_2, u_3,
    u_4, u_5, u_6}
  {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {𝕜 : Type u_2} [RCLike 𝕜] {k : Type u_3}
  {n : Type u_4} {q : Type u_5} {r : Type u_6} [Fintype k] [Fintype n] [Fintype q] [Fintype r]
  [DecidableEq n] {S : Ω → Matrix k n 𝕜} {p : n → ℝ≥0} [Nonempty k] [Nonempty r]
  (hS : HasLaw S (samplingSketch k p) μ) (hp : ∑ i, p i = 1) (A : Matrix n q 𝕜) (B : Matrix n r 𝕜)
  {a b : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b) (hA : ∀ (i : n), ‖WithLp.toLp 2 (A i)‖ ^ 2 ≤ a * ↑(p i))
  (hB : ∀ (i : n), ‖WithLp.toLp 2 (B i)‖ ^ 2 ≤ b * ↑(p i)) {t : ℝ} (ht : 0 ≤ t) :
  μ.real {ω | t ≤ specNorm (Aᴴ * (S ω)ᴴ * S ω * B - Aᴴ * B)} ≤
    (↑(Fintype.card q) + ↑(Fintype.card r)) *
      rexp
        (-(↑(Fintype.card k) * t ^ 2 / 2) /
          (max (b * specNorm A ^ 2) (a * specNorm B ^ 2) + 2 * √(a * b) * t / 3))

Full source on GitHub

Copy link

Theorem (Approximate matrix multiplication in the spectral norm by the SRHT).

for a bounded orthonormal \mathbf{F} with constant \beta, the SRHT \mathbf{S} built from it (independent random signs and an independent uniform choice of \lvert k\rvert distinct rows), r nonempty, \mathbf{A} \in \Bbbk^{n \times q}, \mathbf{B} \in \Bbbk^{n \times r} and s, t \ge 0, \mathbb{P}\bigl[t \le \|\mathbf{A}^{\mathsf{H}}\mathbf{S}^{\mathsf{H}}\mathbf{S}\mathbf{B} - \mathbf{A}^{\mathsf{H}}\mathbf{B}\|_2\bigr] \le (\lvert q\rvert + \lvert r\rvert) \exp\Bigl(-\frac{\lvert k\rvert t^2/2}{\max(\beta R_{\mathbf{B}}\|\mathbf{A}\|_2^2, \beta R_{\mathbf{A}}\|\mathbf{B}\|_2^2) + 2\beta\sqrt{R_{\mathbf{A}}R_{\mathbf{B}}}\,t/3}\Bigr) + 2\lvert n\rvert e^{-s}\,, with the flattened row-norm bounds R_{\mathbf{A}} = \|\mathbf{A}\|_{\mathsf{F}}^2 + 2\|\mathbf{A}\|_{\mathsf{F}}\|\mathbf{A}\|_2\sqrt{s} + 2\|\mathbf{A}\|_2^2 s (NLAlib.srhtRowNormBound A s) and R_{\mathbf{B}} likewise (srhtRowNormBound B s): condition on the signs, flatten both factors, then sample without replacement (measureReal_specNorm_conjTranspose_mul_sub_ge_le_of_hasLaw_samplingSketchWithoutReplacement). For \mathbf{A} = \mathbf{B} with \|\mathbf{A}\|_2 = 1 and stable rank r_s this is \lvert k\rvert = O(\beta(r_s + \log(n/\delta))\log((q + r)/\delta)/\varepsilon^2). [Tropp2011a, Lemma 3.3] for flattening; the bound is this proof's (no printed source in hand). Any field.

General form: sizes are index types

Lean statement and details
NLAlib.measureReal_specNorm_conjTranspose_mul_sub_ge_le_of_hasLaw_srht.{u_1, u_2, u_3, u_4, u_5,
    u_6}
  {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {𝕜 : Type u_2} [RCLike 𝕜] {k : Type u_3}
  {n : Type u_4} [Fintype k] [Fintype n] [DecidableEq n] {β : ℝ} {q : Type u_5} {r : Type u_6}
  [Fintype q] [Fintype r] {S : Ω → Matrix k n 𝕜} {F : Matrix n n 𝕜} [Nonempty r]
  (hF : IsBoundedOrthonormal F β) (hS : HasLaw S (srht k F) μ) (A : Matrix n q 𝕜) (B : Matrix n r 𝕜)
  {s t : ℝ} (hs : 0 ≤ s) (ht : 0 ≤ t) :
  μ.real {ω | t ≤ specNorm (Aᴴ * (S ω)ᴴ * S ω * B - Aᴴ * B)} ≤
    (↑(Fintype.card q) + ↑(Fintype.card r)) *
        rexp
          (-(↑(Fintype.card k) * t ^ 2 / 2) /
            (max (β * srhtRowNormBound B s * specNorm A ^ 2)
                (β * srhtRowNormBound A s * specNorm B ^ 2) +
              2 * β * √(srhtRowNormBound A s * srhtRowNormBound B s) * t / 3)) +
      2 * ↑(Fintype.card n) * rexp (-s)

Full source on GitHub

Copy link

Theorem (CountSketch JL moment).

at p = 2 with \delta = 2/(\lvert k \rvert \varepsilon^2) \,, any field: \mathbb{E}(\|\mathbf{S}\mathbf{x}\|^2 - 1)^2 \le 2/\lvert k \rvert for unit \mathbf{x}, the AMM bound at a one-column matrix. [Woodruff2014, Theorem 14] (after Thorup and Zhang, not in hand; over \mathbb{R}, there in size form).

General form: sizes are index types

Lean statement and details
NLAlib.hasJLMoment_of_hasLaw_countSketch.{u_1, u_2, u_3, u_4} {Ω : Type u_1}
  {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {𝕜 : Type u_2} [RCLike 𝕜] {k : Type u_3} {n : Type u_4}
  [Fintype k] [Fintype n] [DecidableEq k] {S : Ω → Matrix k n 𝕜} {ε : ℝ}
  (hS : HasLaw S (countSketch k n) μ) (hε : 0 < ε) :
  HasJLMoment S ε (2 / (↑(Fintype.card k) * ε ^ 2)) 2 μ

Full source on GitHub

Copy link

Theorem (CountSketch OSI).

for \varepsilon > 0 and nonempty k, a CountSketch is an oblivious subspace injection for dimension d with constant 1 - \varepsilon and failure probability (d^2 + d)/(\lvert k \rvert \varepsilon^2) \,: the lower half of the OSE, with isotropy. [CamanoEpperlyMeyerTropp2025, Definition 1.2] for the notion; their Table 3 lists CountSketch only as an OSE, with k = O(r^2).

General form: sizes are index types

Lean statement and details
NLAlib.isObliviousSubspaceInjection_of_hasLaw_countSketch.{u_1, u_2, u_3, u_4} {Ω : Type u_1}
  {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {𝕜 : Type u_2} [RCLike 𝕜] {k : Type u_3} {n : Type u_4}
  [Fintype k] [Fintype n] [DecidableEq k] {S : Ω → Matrix k n 𝕜} {ε : ℝ} [Nonempty k]
  [DecidableEq n] (hS : HasLaw S (countSketch k n) μ) (d : ℕ) (hε : 0 < ε) :
  IsObliviousSubspaceInjection S d (1 - ε) ((↑d ^ 2 + ↑d) / (↑(Fintype.card k) * ε ^ 2)) μ

Full source on GitHub

Copy link

Theorem (The exact mean of the squared Gram error).

of a CountSketch for \mathbf{U} with orthonormal columns, d = \lvert r \rvert: \mathbb{E}\|(\mathbf{S}\mathbf{U})^{\mathsf{H}}\mathbf{S}\mathbf{U} - \mathbf{I}\|_{\mathsf{F}}^2 = \frac{d^2 + \|\mathbf{U}^{\mathsf{T}}\mathbf{U}\|_{\mathsf{F}}^2 - 2 \sum_i \ell_i^2}{\lvert k \rvert}\,, \ell_i the leverage scores (NLAlib.leverageScore); over \mathbb{R} the middle term is d. The AMM identity at \mathbf{A} = \mathbf{B} = \mathbf{U}. Proved without a literature source.

General form: sizes are index types

Lean statement and details
NLAlib.HasOrthonormalCols.integral_frobNorm_conjTranspose_mul_self_sub_one_sq_of_hasLaw_countSketch.{u_1,
    u_2, u_3, u_4, u_6}
  {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {𝕜 : Type u_2} [RCLike 𝕜] {k : Type u_3}
  {n : Type u_4} {r : Type u_6} [Fintype k] [Fintype n] [DecidableEq k] {S : Ω → Matrix k n 𝕜}
  [Fintype r] [DecidableEq r] {U : Matrix n r 𝕜} (hU : HasOrthonormalCols U)
  (hS : HasLaw S (countSketch k n) μ) :
  ∫ (ω : Ω), frobNorm ((S ω * U)ᴴ * (S ω * U) - 1) ^ 2 ∂μ =
    (↑(Fintype.card r) ^ 2 + frobNorm (Uᵀ * U) ^ 2 - 2 * ∑ i, leverageScore U i ^ 2) /
      ↑(Fintype.card k)

Full source on GitHub

Copy link

Theorem (Gaussian subspace embedding).

for \mathbf{U} with orthonormal columns, \mathbf{S} = \lvert k \rvert^{-1/2} \, \mathbf{G} is a subspace embedding for \operatorname{range} \mathbf{U} with constants \Bigl(1 \mp \frac{\sqrt{\lvert p \rvert} + t}{\sqrt{\lvert k \rvert}}\Bigr)^2 outside probability 2 e^{-t^2/2}, for 0 \le t \le \sqrt{\lvert k \rvert} - \sqrt{\lvert p \rvert}; Gordon's Gram sandwich for the k \times p Gaussian \mathbf{G}\mathbf{U}. [Woodruff2014, Theorem 6] (\lvert k \rvert = \Theta((\lvert p \rvert + \log(1/\delta))/\varepsilon^2), no constant); [MartinssonTropp2020, §8.7.2], there 1 \mp (1 + \sqrt{\lvert p \rvert})/\sqrt{\lvert k \rvert} \mp t/\sqrt{\lvert k \rvert} for our t.

General form: sizes are index types

Lean statement and details
NLAlib.HasOrthonormalCols.hasSubspaceEmbedding_of_hasLaw_gaussianMatrix.{u_1, u_2, u_3, u_4}
  {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {k : Type u_2} {n : Type u_3}
  {p : Type u_4} [Fintype k] [Fintype n] [Fintype p] {G : Ω → Matrix k n ℝ} {U : Matrix n p ℝ}
  {t : ℝ} [DecidableEq p] (hU : HasOrthonormalCols U) (hG : HasLaw G (gaussianMatrix k n) μ)
  (ht : 0 ≤ t) (htk : t ≤ √↑(Fintype.card k) - √↑(Fintype.card p)) :
  HasSubspaceEmbedding (fun ω ↦ (√↑(Fintype.card k))⁻¹ • G ω) U
    ((1 - (√↑(Fintype.card p) + t) / √↑(Fintype.card k)) ^ 2)
    ((1 + (√↑(Fintype.card p) + t) / √↑(Fintype.card k)) ^ 2) (2 * rexp (-t ^ 2 / 2)) μ

Full source on GitHub

Copy link

Theorem (The Gaussian OSI).

\mathbf{S} = \lvert k \rvert^{-1/2} \, \mathbf{G} is an oblivious subspace injection for dimension d with constant \Bigl(1 - \frac{\sqrt{d} + t}{\sqrt{\lvert k \rvert}}\Bigr)^2 and failure probability e^{-t^2/2}, for k nonempty and 0 \le t \le \sqrt{\lvert k \rvert} - \sqrt{d}; for d > \lvert n \rvert the proof works at \min(d, \lvert n \rvert) and weakens. [CamanoEpperlyMeyerTropp2025, Definition 1.6, §1.5.0], who cite [MartinssonTropp2020, §8.7.2] for it; the one-sided tail gives the better failure probability.

General form: sizes are index types

Lean statement and details
NLAlib.isObliviousSubspaceInjection_of_hasLaw_gaussianMatrix.{u_1, u_2, u_3} {Ω : Type u_1}
  {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {k : Type u_2} {n : Type u_3} [Fintype k] [Fintype n]
  {G : Ω → Matrix k n ℝ} {t : ℝ} [DecidableEq n] [Nonempty k] (hG : HasLaw G (gaussianMatrix k n) μ)
  (d : ℕ) (ht : 0 ≤ t) (htd : t ≤ √↑(Fintype.card k) - √↑d) :
  IsObliviousSubspaceInjection (fun ω ↦ (√↑(Fintype.card k))⁻¹ • G ω) d
    ((1 - (√↑d + t) / √↑(Fintype.card k)) ^ 2) (rexp (-t ^ 2 / 2)) μ

Full source on GitHub

Copy link

Theorem (Gaussian rows suffice for a rank-d projection-cost-preserving sketch).

O((d+1)\log(1/\delta)/\varepsilon^2) rows give one, with constants 1 \mp \varepsilon and failure probability \delta, for \varepsilon and \delta below absolute constants; the constants come before every dimension. Proved from NLAlib.hasProjectionCostPreserving_of_hasLaw_gaussianMatrix_of_jlMomentDim_le with \varepsilon_0 = 1 and \delta \le 1/2; the OSE size O((d + \log(1/\delta))/\varepsilon^2) is dominated by the tail size there. The literature's additive (d + \log(1/\delta))/\varepsilon^2 needs stable-rank spectral approximate multiplication. [CohenElderMuscoMuscoPersu2015, Theorem 12]. Asymptotic: NLAlib.hasProjectionCostPreserving_of_hasLaw_gaussianMatrix_of_jlMomentDim_le

General form: sizes are index types

Lean statement and details
NLAlib.exists_forall_hasProjectionCostPreserving_of_hasLaw_gaussianMatrix :
  ∃ C ε₀,
    0 < C ∧
      0 < ε₀ ∧
        ∀ {Ω k m n : Type} [inst : MeasurableSpace Ω] [inst_1 : Fintype k] [inst_2 : Fintype m]
          [inst_3 : Fintype n] (μ : Measure Ω) (G : Ω → Matrix k n ℝ) (A : Matrix m n ℝ) (d : ℕ)
          (ε δ : ℝ),
          HasLaw G (gaussianMatrix k n) μ →
            0 < ε →
              ε ≤ ε₀ →
                0 < δ →
                  δ ≤ 1 / 2 →
                    C * ((↑d + 1) * Real.log (1 / δ) / ε ^ 2) ≤ ↑(Fintype.card k) →
                      HasProjectionCostPreserving (fun ω ↦ (√↑(Fintype.card k))⁻¹ • G ω) A d (1 - ε)
                        (1 + ε) δ μ

Full source on GitHub

Copy link

Theorem (Haar rows suffice for a rank-d projection-cost-preserving sketch).

O((d+1)\log(1/\delta)/\varepsilon^2) rows give one: for \lvert k\rvert \le \lvert n\rvert, the Haar sketch \mathbf{S} = \sqrt{\lvert n\rvert/\lvert k\rvert}\,\mathbf{Q}^{\mathsf{H}} makes \mathbf{A}\mathbf{S}^{\mathsf{H}} a rank-d projection-cost-preserving sketch with constants 1 \mp \varepsilon and failure probability \delta, for \varepsilon and \delta below absolute constants; the constants come before every dimension. Proved from NLAlib.hasProjectionCostPreserving_of_hasLaw_haarFrame_of_jlMomentDim_le with \varepsilon_0 = 1 and \delta \le 1/2. [CohenElderMuscoMuscoPersu2015, proof of Theorem 12]. Asymptotic: NLAlib.hasProjectionCostPreserving_of_hasLaw_haarFrame_of_jlMomentDim_le

General form: sizes are index types

Lean statement and details
NLAlib.exists_forall_hasProjectionCostPreserving_of_hasLaw_haarFrame :
  ∃ C ε₀,
    0 < C ∧
      0 < ε₀ ∧
        ∀ {Ω k m n : Type} [inst : MeasurableSpace Ω] [inst_1 : Fintype k] [inst_2 : Fintype m]
          [inst_3 : Fintype n] [inst_4 : DecidableEq k] (μ : Measure Ω) (Q : Ω → Matrix n k ℝ)
          (A : Matrix m n ℝ) (d : ℕ) (ε δ : ℝ),
          HasLaw Q (haarFrame n k) μ →
            Fintype.card k ≤ Fintype.card n →
              0 < ε →
                ε ≤ ε₀ →
                  0 < δ →
                    δ ≤ 1 / 2 →
                      C * ((↑d + 1) * Real.log (1 / δ) / ε ^ 2) ≤ ↑(Fintype.card k) →
                        HasProjectionCostPreserving
                          (fun ω ↦ √(↑(Fintype.card n) / ↑(Fintype.card k)) • (Q ω)ᴴ) A d (1 - ε)
                          (1 + ε) δ μ

Full source on GitHub

Copy link

Theorem (Haar subspace embedding, deterministic upper half).

for \mathbf{U} with orthonormal columns and \lvert k \rvert \le \lvert n \rvert, the Haar sketch is a subspace embedding for \operatorname{range} \mathbf{U} with constants a_{\mathrm{H}} = \frac{(1 - (\sqrt{\lvert p \rvert} + t)/\sqrt{\lvert k \rvert})^2} {(1 + (\sqrt{\lvert k \rvert} + s)/\sqrt{\lvert n \rvert})^2}, \qquad b = \frac{\lvert n \rvert}{\lvert k \rvert} outside probability e^{-t^2/2} + e^{-s^2/2}, for 0 \le t \le \sqrt{\lvert k \rvert} - \sqrt{\lvert p \rvert} and s \ge 0; no condition on s and \lvert k \rvert < \lvert n \rvert not needed. The lower constant is that of NLAlib.HasOrthonormalCols.hasSubspaceInjection_of_hasLaw_haarFrame. The upper half is NLAlib.ae_conjTranspose_mul_self_mul_le_smul_of_hasLaw_haarFrame. Its upper constant is exact at \lvert k \rvert = \lvert n \rvert and incomparable with the b_{\mathrm{H}} of NLAlib.HasOrthonormalCols.hasSubspaceEmbedding_of_hasLaw_haarFrame_of_lt_sqrt_sub_sqrt, which is better for \lvert k \rvert small against \lvert n \rvert (rule 4).

General form: sizes are index types

Lean statement and details
NLAlib.HasOrthonormalCols.hasSubspaceEmbedding_of_hasLaw_haarFrame.{u_1, u_2, u_3, u_4}
  {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {k : Type u_2} {n : Type u_3}
  {p : Type u_4} [Fintype k] [Fintype n] [Fintype p] [DecidableEq k] {Q : Ω → Matrix n k ℝ}
  {U : Matrix n p ℝ} {t s : ℝ} [DecidableEq p] (hU : HasOrthonormalCols U)
  (hQ : HasLaw Q (haarFrame n k) μ) (hk : Fintype.card k ≤ Fintype.card n) (ht : 0 ≤ t)
  (htk : t ≤ √↑(Fintype.card k) - √↑(Fintype.card p)) (hs : 0 ≤ s) :
  HasSubspaceEmbedding (fun ω ↦ √(↑(Fintype.card n) / ↑(Fintype.card k)) • (Q ω)ᴴ) U
    ((1 - (√↑(Fintype.card p) + t) / √↑(Fintype.card k)) ^ 2 /
      (1 + (√↑(Fintype.card k) + s) / √↑(Fintype.card n)) ^ 2)
    (↑(Fintype.card n) / ↑(Fintype.card k)) (rexp (-t ^ 2 / 2) + rexp (-s ^ 2 / 2)) μ

Full source on GitHub

Copy link

Theorem (The Haar OSI).

the Haar sketch is an oblivious subspace injection for dimension d with constant \frac{(1 - (\sqrt{d} + t)/\sqrt{\lvert k \rvert})^2} {(1 + (\sqrt{\lvert k \rvert} + s)/\sqrt{\lvert n \rvert})^2} and failure probability e^{-t^2/2} + e^{-s^2/2}, for k nonempty and 0 \le t \le \sqrt{\lvert k \rvert} - \sqrt{d} and s \ge 0.

General form: sizes are index types

Lean statement and details
NLAlib.isObliviousSubspaceInjection_of_hasLaw_haarFrame.{u_1, u_2, u_3} {Ω : Type u_1}
  {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {k : Type u_2} {n : Type u_3} [Fintype k] [Fintype n]
  [DecidableEq k] {Q : Ω → Matrix n k ℝ} {t s : ℝ} [DecidableEq n] [Nonempty k]
  (hQ : HasLaw Q (haarFrame n k) μ) (hk : Fintype.card k ≤ Fintype.card n) (d : ℕ) (ht : 0 ≤ t)
  (htd : t ≤ √↑(Fintype.card k) - √↑d) (hs : 0 ≤ s) :
  IsObliviousSubspaceInjection (fun ω ↦ √(↑(Fintype.card n) / ↑(Fintype.card k)) • (Q ω)ᴴ) d
    ((1 - (√↑d + t) / √↑(Fintype.card k)) ^ 2 /
      (1 + (√↑(Fintype.card k) + s) / √↑(Fintype.card n)) ^ 2)
    (rexp (-t ^ 2 / 2) + rexp (-s ^ 2 / 2)) μ

Full source on GitHub

Copy link

Theorem (Distributional Johnson–Lindenstrauss for a Gaussian sketch).

for every unit \mathbf{x} and every \varepsilon \ge 0, \mathbb{P}\bigl[\varepsilon \le \lvert \|\mathbf{S}\mathbf{x}\|^2 - 1 \rvert\bigr] \le 2 e^{-\lvert k \rvert (\varepsilon^2/4 - \varepsilon^3/6)} \,; \|\mathbf{S}\mathbf{x}\|^2 = \|\mathbf{G}\mathbf{x}\|^2/\lvert k \rvert is \chi^2_{\lvert k \rvert} / \lvert k \rvert (NLAlib.measureReal_abs_norm_sq_div_card_sub_one_ge_le_of_hasLaw_gaussianVector). [Woodruff2014, Lemma 18] (there \varepsilon^2 \lvert k \rvert / 16); [MartinssonTropp2020, §8.6]; the exponent of Dasgupta and Gupta. No \varepsilon < 1: the bound is at least 2 for \varepsilon \ge 3/2.

General form: sizes are index types

Lean statement and details
NLAlib.hasJLProperty_of_hasLaw_gaussianMatrix.{u_1, u_2, u_3} {Ω : Type u_1}
  {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {k : Type u_2} {n : Type u_3} [Fintype k] [Fintype n]
  {G : Ω → Matrix k n ℝ} {ε : ℝ} (hG : HasLaw G (gaussianMatrix k n) μ) (hε : 0 ≤ ε) :
  HasJLProperty (fun ω ↦ (√↑(Fintype.card k))⁻¹ • G ω) ε
    (2 * rexp (-(↑(Fintype.card k) * (ε ^ 2 / 4 - ε ^ 3 / 6)))) μ

Full source on GitHub

Copy link

Theorem (Haar distributional JL, sample-size form).

at least \log(2/\delta)/(\varepsilon^2/4 - \varepsilon^3/6) rows (jlDim ε δ) give the JL property of \mathbf{S} = \sqrt{\lvert n \rvert / \lvert k \rvert}\,\mathbf{Q}^{\mathsf{H}} with distortion \varepsilon and failure probability \delta, for 0 < \varepsilon < 3/2 and \delta > 0. [Vershynin2018, Lemma 5.3.2] (the tail form: for the projection \mathbf{P} onto a uniformly random m-dimensional subspace of \mathbb{R}^n and a fixed \mathbf{z}, \|\mathbf{P}\mathbf{z}\| = (1 \pm \varepsilon)\sqrt{m/n}\,\|\mathbf{z}\| outside probability 2e^{-c\varepsilon^2 m}, with an unspecified constant c); here solved for the row count, with the Gaussian's exponent. Asymptotic form: NLAlib.exists_forall_hasJLProperty_of_hasLaw_haarFrame.

General form: sizes are index types

Lean statement and details
NLAlib.hasJLProperty_of_hasLaw_haarFrame_of_jlDim_le.{u_1, u_2, u_3} {Ω : Type u_1}
  {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {k : Type u_2} {n : Type u_3} [Fintype k] [Fintype n]
  [DecidableEq k] {Q : Ω → Matrix n k ℝ} {ε δ : ℝ} (hQ : HasLaw Q (haarFrame n k) μ)
  (hk : Fintype.card k ≤ Fintype.card n) (hε : 0 < ε) (hε1 : ε < 3 / 2) (hδ : 0 < δ)
  (hk' : jlDim ε δ ≤ ↑(Fintype.card k)) :
  HasJLProperty (fun ω ↦ √(↑(Fintype.card n) / ↑(Fintype.card k)) • (Q ω)ᴴ) ε δ μ

Full source on GitHub

Copy link

Theorem (Johnson–Lindenstrauss lemma).

for finitely many points \mathbf{x}_i, i \in \iota, and \delta \ge 0, the probability that some pairwise difference \mathbf{x}_i - \mathbf{x}_j \ne \mathbf{0} has its squared norm distorted by a factor \varepsilon or more, \varepsilon \|\mathbf{x}_i - \mathbf{x}_j\|^2 \le \bigl\lvert \|\mathbf{S}(\mathbf{x}_i - \mathbf{x}_j)\|^2 - \|\mathbf{x}_i - \mathbf{x}_j\|^2 \bigr\rvert, is at most \binom{\lvert \iota \rvert}{2} \delta (union over unordered pairs). [Woodruff2014, Definition 3]; there inner products on a finite set, here squared norms of differences.

General form: sizes are index types

Lean statement and details
NLAlib.HasJLProperty.measureReal_exists_abs_norm_mulVec_sq_sub_ge_le.{u_1, u_2, u_3, u_4, u_5}
  {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {𝕜 : Type u_2} [RCLike 𝕜] {k : Type u_3}
  {n : Type u_4} [Fintype k] [Fintype n] {S : Ω → Matrix k n 𝕜} {ε δ : ℝ}
  (h : HasJLProperty S ε δ μ) (hδ : 0 ≤ δ) {ι : Type u_5} [Fintype ι] (x : ι → n → 𝕜) :
  μ.real
      {ω |
        ∃ i j,
          x i ≠ x j ∧
            ε * ‖WithLp.toLp 2 (x i - x j)‖ ^ 2 ≤
              |‖WithLp.toLp 2 (S ω *ᵥ (x i - x j))‖ ^ 2 - ‖WithLp.toLp 2 (x i - x j)‖ ^ 2|} ≤
    ↑((Fintype.card ι).choose 2) * δ

Full source on GitHub

Copy link

Theorem (Frobenius-norm preservation from the JL moment property).

for \varepsilon \ge 0 and p \ge 1, \mathbb{E}\bigl\lvert\|\mathbf{S}\mathbf{X}\|_{\mathsf{F}}^2 - \|\mathbf{X}\|_{\mathsf{F}}^2 \bigr\rvert^p \le (\varepsilon\|\mathbf{X}\|_{\mathsf{F}}^2)^p\,\delta\,. The matrix twin of NLAlib.HasJLMoment.integral_abs_norm_mulVec_sq_sub_rpow_le. Any field: only the vector property is used, column by column, with Jensen's inequality for the weights \|\mathbf{X}_{:,j}\|^2/\|\mathbf{X}\|_{\mathsf{F}}^2 (NLAlib.integral_rpow_sum_le). As a remark, the distortion is the trace of the approximate-multiplication error at \mathbf{A} = \mathbf{B} = \mathbf{X}, which the Frobenius bound on that error does not control without a rank bound. [Woodruff2014, proof of Theorem 13], the same summation over columns; [CohenElderMuscoMuscoPersu2015, §7, discussion after Lemma 11], stated there as standard for embedding matrices.

Lean statement and details
NLAlib.HasJLMoment.integral_abs_frobNorm_mul_sq_sub_rpow_le.{u_1, u_2, u_3, u_4, u_5} {Ω : Type u_1}
  {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {𝕜 : Type u_2} [RCLike 𝕜] {k : Type u_3} {n : Type u_4}
  [Fintype k] [Fintype n] {S : Ω → Matrix k n 𝕜} {ε δ p : ℝ} {q : Type u_5} [Fintype q]
  (h : HasJLMoment S ε δ p μ) (hε : 0 ≤ ε) (hp : 1 ≤ p) (hS : AEMeasurable S μ) (X : Matrix n q 𝕜) :
  ∫ (ω : Ω), |frobNorm (S ω * X) ^ 2 - frobNorm X ^ 2| ^ p ∂μ ≤ (ε * frobNorm X ^ 2) ^ p * δ

Full source on GitHub

Copy link

Theorem (Gaussian JL moments, asymptotic form).

O(\log(1/\delta)/\varepsilon^2) rows suffice for the Gaussian sketch \mathbf{S} = \lvert k\rvert^{-1/2}\mathbf{G} to have the JL moment property with distortion \varepsilon, failure probability \delta and exponent \max(2, \log(1/\delta)), for \varepsilon and \delta below absolute constants; the constants come before every dimension. Proved from NLAlib.hasJLMoment_of_hasLaw_gaussianMatrix_of_jlMomentDim_le with C = 384, \varepsilon_0 = 1 and \delta \le 1/2, where \max(2, \log(1/\delta)) \le 3\log(1/\delta). [Woodruff2014, Definition 12 and Theorem 13]. Asymptotic: NLAlib.hasJLMoment_of_hasLaw_gaussianMatrix_of_jlMomentDim_le

General form: sizes are index types

Lean statement and details
NLAlib.exists_forall_hasJLMoment_of_hasLaw_gaussianMatrix :
  ∃ C ε₀,
    0 < C ∧
      0 < ε₀ ∧
        ∀ {Ω k n : Type} [inst : MeasurableSpace Ω] [inst_1 : Fintype k] [inst_2 : Fintype n]
          (μ : Measure Ω) (G : Ω → Matrix k n ℝ) (ε δ : ℝ),
          HasLaw G (gaussianMatrix k n) μ →
            0 < ε →
              ε ≤ ε₀ →
                0 < δ →
                  δ ≤ 1 / 2 →
                    C * (Real.log (1 / δ) / ε ^ 2) ≤ ↑(Fintype.card k) →
                      HasJLMoment (fun ω ↦ (√↑(Fintype.card k))⁻¹ • G ω) ε δ
                        (max 2 (Real.log (1 / δ))) μ

Full source on GitHub

Copy link

Theorem (Haar JL moments, asymptotic form).

O(\log(1/\delta)/\varepsilon^2) rows suffice for the Haar sketch \mathbf{S} = \sqrt{\lvert n \rvert / \lvert k \rvert}\,\mathbf{Q}^{\mathsf{H}}, \lvert k\rvert \le \lvert n\rvert, to have the JL moment property with distortion \varepsilon, failure probability \delta and exponent \max(2, \log(1/\delta)) \,, for \varepsilon and \delta below absolute constants; the constants come before every dimension. Proved from NLAlib.hasJLMoment_of_hasLaw_haarFrame_of_jlMomentDim_le with C = 384, \varepsilon_0 = 1 and \delta \le 1/2. [Woodruff2014, Definition 12 and Theorem 13]. Asymptotic: NLAlib.hasJLMoment_of_hasLaw_haarFrame_of_jlMomentDim_le

General form: sizes are index types

Lean statement and details
NLAlib.exists_forall_hasJLMoment_of_hasLaw_haarFrame :
  ∃ C ε₀,
    0 < C ∧
      0 < ε₀ ∧
        ∀ {Ω k n : Type} [inst : MeasurableSpace Ω] [inst_1 : Fintype k] [inst_2 : Fintype n]
          [inst_3 : DecidableEq k] (μ : Measure Ω) (Q : Ω → Matrix n k ℝ) (ε δ : ℝ),
          HasLaw Q (haarFrame n k) μ →
            Fintype.card k ≤ Fintype.card n →
              0 < ε →
                ε ≤ ε₀ →
                  0 < δ →
                    δ ≤ 1 / 2 →
                      C * (Real.log (1 / δ) / ε ^ 2) ≤ ↑(Fintype.card k) →
                        HasJLMoment (fun ω ↦ √(↑(Fintype.card n) / ↑(Fintype.card k)) • (Q ω)ᴴ) ε δ
                          (max 2 (Real.log (1 / δ))) μ

Full source on GitHub

Copy link

Theorem (Sub-Gaussian JL moments, asymptotic form).

O(c^2\log(1/\delta)/\varepsilon^2) rows suffice for the sketch with independent isotropic rows, sub-Gaussian with proxy c, to have the JL moment property with distortion \varepsilon, failure probability \delta and exponent \max(2, \log(1/\delta)) \,, for \varepsilon and \delta below absolute constants; the constants come before every dimension and the proxy. Proved from NLAlib.hasJLMoment_of_isSubgaussianVector_of_subgaussianJLMomentDim_le with C = 1728, \varepsilon_0 = 1 and \delta \le 1/2; isotropy forces c \ge 1 once there is a column. [Woodruff2014, Definition 12 and Theorem 13]. Asymptotic: NLAlib.hasJLMoment_of_isSubgaussianVector_of_subgaussianJLMomentDim_le

General form: sizes are index types

Lean statement and details
NLAlib.exists_forall_hasJLMoment_of_isSubgaussianVector :
  ∃ C ε₀,
    0 < C ∧
      0 < ε₀ ∧
        ∀ {Ω k n : Type} [inst : MeasurableSpace Ω] [inst_1 : Fintype k] [inst_2 : Fintype n]
          [inst_3 : DecidableEq n] [Nonempty k] (μ : Measure Ω) (X : Ω → Matrix k n ℝ) (c : ℝ≥0)
          (ε δ : ℝ),
          iIndepFun (fun i ω ↦ X ω i) μ →
            (∀ (i : k), IsSubgaussianVector (fun ω ↦ X ω i) c μ) →
              (∀ (i : k), IsIsotropic (fun ω ↦ X ω i) μ) →
                0 < ε →
                  ε ≤ ε₀ →
                    0 < δ →
                      δ ≤ 1 / 2 →
                        C * (↑c ^ 2 * Real.log (1 / δ) / ε ^ 2) ≤ ↑(Fintype.card k) →
                          HasJLMoment (fun ω ↦ (√↑(Fintype.card k))⁻¹ • X ω) ε δ
                            (max 2 (Real.log (1 / δ))) μ

Full source on GitHub

Copy link

Theorem (Sign-sketch distributional JL).

with Gaussian constants: for every unit \mathbf{x} and every \varepsilon \ge 0, \mathbb{P}\bigl[\varepsilon \le \lvert \|\mathbf{S}\mathbf{x}\|^2 - 1 \rvert\bigr] \le 2 e^{-\lvert k \rvert (\varepsilon^2/4 - \varepsilon^3/6)} \,, the bound of NLAlib.hasJLProperty_of_hasLaw_gaussianMatrix. From NLAlib.hasJLProperty_of_isSubgaussianVector_of_integral_pow_four_le, with \mathbb{E} \langle \boldsymbol{\xi}, \mathbf{x} \rangle^4 = \operatorname{Var}(\langle \boldsymbol{\xi}, \mathbf{x} \rangle^2) + \|\mathbf{x}\|^4 = 3 \|\mathbf{x}\|^4 - 2 \sum_j \mathbf{x}_j^4 (NLAlib.variance_quadForm_of_hasLaw_rademacherVector at vecMulVec x x). [Woodruff2014, §2.1, after Theorem 6]; constants of [Achlioptas2003, Theorem 1.1], locator to confirm. For \varepsilon \gtrsim 1.43, NLAlib.hasJLProperty_of_isSubgaussianVector at c = 1 is better.

General form: sizes are index types

Lean statement and details
NLAlib.hasJLProperty_of_hasLaw_rademacherMatrix.{u_1, u_2, u_3} {Ω : Type u_1}
  {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {k : Type u_2} {n : Type u_3} [Fintype k] [Fintype n]
  {X : Ω → Matrix k n ℝ} {ε : ℝ} (hX : HasLaw X (rademacherMatrix k n) μ) (hε : 0 ≤ ε) :
  HasJLProperty (fun ω ↦ (√↑(Fintype.card k))⁻¹ • X ω) ε
    (2 * rexp (-(↑(Fintype.card k) * (ε ^ 2 / 4 - ε ^ 3 / 6)))) μ

Full source on GitHub

Copy link

Theorem (Distributional JL for the SRHT, asymptotic form).

O(\beta(1 + \log(\lvert n\rvert/\delta))\log(1/\delta)/\varepsilon^2) rows suffice for the SRHT of a bounded orthonormal \mathbf{F} with constant \beta to have the JL property with distortion \varepsilon and failure probability \delta, for \varepsilon and \delta below absolute constants; the constants come before every dimension and before \beta, and the \log\lvert n\rvert of the flattening stays in the threshold. Proved from NLAlib.hasJLProperty_of_hasLaw_srht_of_samplingEmbeddingDim_le with \varepsilon_0 = 1 and \delta \le 1/2. [Woodruff2014, Theorem 7]. Asymptotic: NLAlib.hasJLProperty_of_hasLaw_srht_of_samplingEmbeddingDim_le

General form: sizes are index types

Lean statement and details
NLAlib.exists_forall_hasJLProperty_of_hasLaw_srht :
  ∃ C ε₀,
    0 < C ∧
      0 < ε₀ ∧
        ∀ {Ω 𝕜 k n : Type} [inst : MeasurableSpace Ω] [inst_1 : RCLike 𝕜] [inst_2 : Fintype k]
          [inst_3 : Fintype n] [inst_4 : DecidableEq n] (μ : Measure Ω) (S : Ω → Matrix k n 𝕜)
          (F : Matrix n n 𝕜) (β ε δ : ℝ),
          IsBoundedOrthonormal F β →
            HasLaw S (srht k F) μ →
              0 < ε →
                ε ≤ ε₀ →
                  0 < δ →
                    δ ≤ 1 / 2 →
                      C * (β * (1 + Real.log (↑(Fintype.card n) / δ)) * Real.log (1 / δ) / ε ^ 2) ≤
                          ↑(Fintype.card k) →
                        HasJLProperty S ε δ μ

Full source on GitHub

Copy link

Theorem (Sub-Gaussian JL for independent entries).

for a random \mathbf{X} with independent entries \mathbf{X}_{i,j}, each sub-Gaussian with proxy c and with \mathbb{E}[\mathbf{X}_{i,j}^2] = 1, \mathbf{S} = \lvert k \rvert^{-1/2} \, \mathbf{X} has the JL property with failure probability 2 e^{-(1/36) \lvert k \rvert \min(\varepsilon^2/c^2, \varepsilon/c)}, the constant being subgaussianJLConstant. The mean is 0 by HasSubgaussianMGF.integral_eq_zero, so the second moment is the variance. The rows hypotheses follow by NLAlib.iIndepFun_row_of_iIndepFun_entry, IsSubgaussianVector.of_iIndepFun and IsIsotropic.of_iIndepFun; the other rows theorems apply to entries through the same three steps. [Vershynin2018, Exercise 5.3.3].

General form: sizes are index types

Lean statement and details
NLAlib.hasJLProperty_of_iIndepFun_entry.{u_1, u_2, u_3} {Ω : Type u_1} {mΩ : MeasurableSpace Ω}
  {μ : Measure Ω} {k : Type u_2} {n : Type u_3} [Fintype k] [Fintype n] {X : Ω → Matrix k n ℝ}
  {c : ℝ≥0} {ε : ℝ} (hind : iIndepFun (fun p ω ↦ X ω p.1 p.2) μ)
  (hsub : ∀ (i : k) (j : n), HasSubgaussianMGF (fun ω ↦ X ω i j) c μ)
  (hvar : ∀ (i : k) (j : n), ∫ (ω : Ω), X ω i j ^ 2 ∂μ = 1) :
  HasJLProperty (fun ω ↦ (√↑(Fintype.card k))⁻¹ • X ω) ε
    (2 * rexp (-(subgaussianJLConstant * ↑(Fintype.card k) * min (ε ^ 2 / ↑c ^ 2) (ε / ↑c)))) μ

Full source on GitHub

Copy link

Theorem (Row sampling under leverage domination).

if \ell_i(\mathbf{U}) \le L p_i for every row, the row-sampling sketch with k samples is a subspace embedding for \operatorname{range}\mathbf{U} with constants 1 \mp \varepsilon outside probability 2 \operatorname{rank}\mathbf{U} \cdot e^{-\varepsilon^2 k / (3L)} \,, for 0 \le \varepsilon \le 1 and any \mathbf{U}. [Woodruff2014, Theorem 17], there \mathbf{U} with orthonormal columns, p a \beta-approximation of the leverage-score distribution and s > 144 d \log(2d/\delta) / (\beta \varepsilon^2) samples through a Bernstein bound (Fact 1); here matrix Chernoff, L = d/\beta, any shape and rank; [MartinssonTropp2020, §9.6.3]; [Tropp2015, Theorem 5.1.1].

General form: sizes are index types

Lean statement and details
NLAlib.hasSubspaceEmbedding_of_hasLaw_samplingSketch.{u_1, u_2, u_3, u_4, u_6} {Ω : Type u_1}
  {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {𝕜 : Type u_2} [RCLike 𝕜] {k : Type u_3} {n : Type u_4}
  {r : Type u_6} [Fintype k] [Fintype n] [Fintype r] [DecidableEq n] {S : Ω → Matrix k n 𝕜}
  {U : Matrix n r 𝕜} {p : n → ℝ≥0} {L ε : ℝ} (hS : HasLaw S (samplingSketch k p) μ)
  (hp : ∑ i, p i = 1) (hdom : ∀ (i : n), leverageScore U i ≤ L * ↑(p i)) (hε : 0 ≤ ε)
  (hε1 : ε ≤ 1) :
  HasSubspaceEmbedding S U (1 - ε) (1 + ε)
    (2 * ↑U.rank * rexp (-ε ^ 2 * ↑(Fintype.card k) / (3 * L))) μ

Full source on GitHub

Copy link

Theorem (Leverage-score sampling: subspace injection).

row sampling under leverage domination \ell_i(\mathbf{U}) \le L p_i is a subspace injection for \operatorname{range}\mathbf{U} with constant 1 - \varepsilon and failure probability \delta, for \varepsilon > 0, \delta > 0 and \lvert k \rvert \ge 2 L \log(\operatorname{rank}\mathbf{U}/\delta)/\varepsilon^2 samples (NLAlib.samplingInjectionDim U.rank L ε δ). [Woodruff2014, Theorem 17] (the two-sided form for orthonormal columns, more than 144 d \log(2d/\delta)/(\beta\varepsilon^2) samples with d = \operatorname{rank}\mathbf{U} and L = d/\beta); [Tropp2015, Theorem 5.1.1, (5.1.5)] (the lower tail, here weakened and solved for the sample size). Asymptotic form: NLAlib.exists_forall_hasSubspaceInjection_of_hasLaw_samplingSketch.

General form: sizes are index types

Lean statement and details
NLAlib.hasSubspaceInjection_of_hasLaw_samplingSketch_of_samplingInjectionDim_le.{u_1, u_2, u_3, u_4,
    u_6}
  {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {𝕜 : Type u_2} [RCLike 𝕜] {k : Type u_3}
  {n : Type u_4} {r : Type u_6} [Fintype k] [Fintype n] [Fintype r] [DecidableEq n]
  {S : Ω → Matrix k n 𝕜} {U : Matrix n r 𝕜} {p : n → ℝ≥0} {L ε δ : ℝ}
  (hS : HasLaw S (samplingSketch k p) μ) (hp : ∑ i, p i = 1)
  (hdom : ∀ (i : n), leverageScore U i ≤ L * ↑(p i)) (hε : 0 < ε) (hδ : 0 < δ)
  (hk : samplingInjectionDim U.rank L ε δ ≤ ↑(Fintype.card k)) :
  HasSubspaceInjection S U (1 - ε) δ μ

Full source on GitHub

Copy link

Theorem (The head–tail constructor, tail form).

under the frame hypotheses of NLAlib.IsSubspaceEmbedding.isProjectionCostPreserving_of_hasOrthonormalCols, with \mathbf{E} = \mathbf{A} - \mathbf{A}\mathbf{Z}\mathbf{Z}^{\mathsf{H}}, if the head embedding fails with probability \delta_1 and the three tail conditions \begin{aligned} \|\mathbf{E}\mathbf{S}^{\mathsf{H}}\mathbf{S}\mathbf{E}^{\mathsf{H}} - \mathbf{E}\mathbf{E}^{\mathsf{H}}\|_{\mathsf{F}} &\le \varepsilon_w\|\mathbf{E}\|_{\mathsf{F}}^2,\\ \|\mathbf{E}\mathbf{S}^{\mathsf{H}}\mathbf{S}\mathbf{Z} - \mathbf{E}\mathbf{Z}\|_{\mathsf{F}} &\le \varepsilon_\chi\|\mathbf{E}\|_{\mathsf{F}},\\ \|\mathbf{S}\mathbf{E}^{\mathsf{H}}\|_{\mathsf{F}}^2 &\le (1 + \varepsilon_{\mathrm{F}})\|\mathbf{E}\|_{\mathsf{F}}^2 \end{aligned} fail with probabilities \delta_2, \delta_3, \delta_4, then \mathbf{S} is a rank-k projection-cost-preserving sketch of \mathbf{A} with constants a - \sqrt{k}\,\varepsilon_w - 2\varepsilon_\chi and b + \sqrt{k}\,\varepsilon_w + 2\varepsilon_\chi + \varepsilon_{\mathrm{F}}, except with probability \delta_1 + \delta_2 + \delta_3 + \delta_4 (union bound). The interface for a family with its own approximate-multiplication tails, over any field. [CohenElderMuscoMuscoPersu2015, proof of Theorem 12].

Lean statement and details
NLAlib.HasSubspaceEmbedding.hasProjectionCostPreserving_of_hasOrthonormalCols.{u_1, u_2, u_3, u_4,
    u_5, u_6}
  {𝕜 : Type u_1} [RCLike 𝕜] {l : Type u_2} {m : Type u_3} {n : Type u_4} [Fintype l] [Fintype m]
  [Fintype n] {Ω : Type u_5} {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {r : Type u_6} [Fintype r]
  [DecidableEq r] [IsFiniteMeasure μ] {S : Ω → Matrix l n 𝕜} {Z : Matrix n r 𝕜}
  {a b δ₁ δ₂ δ₃ δ₄ εw εχ εF : ℝ} (h : HasSubspaceEmbedding S Z a b δ₁ μ) (hZ : HasOrthonormalCols Z)
  (ha : a ≤ 1) (hb : 1 ≤ b) {A : Matrix m n 𝕜} {k : ℕ}
  (hZA : frobNorm (A - A * Z * Zᴴ) ≤ frobNorm (A - truncatedSVD A k)) (hεw : 0 ≤ εw) (hεχ : 0 ≤ εχ)
  (hεF : 0 ≤ εF)
  (hw :
    μ.real
        {ω |
          εw * frobNorm (A - A * Z * Zᴴ) ^ 2 <
            frobNorm
              ((A - A * Z * Zᴴ) * (S ω)ᴴ * S ω * (A - A * Z * Zᴴ)ᴴ -
                (A - A * Z * Zᴴ) * (A - A * Z * Zᴴ)ᴴ)} ≤
      δ₂)
  (hχ :
    μ.real
        {ω |
          εχ * frobNorm (A - A * Z * Zᴴ) <
            frobNorm ((A - A * Z * Zᴴ) * (S ω)ᴴ * S ω * Z - (A - A * Z * Zᴴ) * Z)} ≤
      δ₃)
  (hF :
    μ.real {ω | (1 + εF) * frobNorm (A - A * Z * Zᴴ) ^ 2 < frobNorm (S ω * (A - A * Z * Zᴴ)ᴴ) ^ 2} ≤
      δ₄) :
  HasProjectionCostPreserving S A k (a - √↑k * εw - 2 * εχ) (b + √↑k * εw + 2 * εχ + εF)
    (δ₁ + δ₂ + δ₃ + δ₄) μ

Full source on GitHub

Copy link

Theorem (Constrained low-rank approximation through a projection-cost-preserving sketch).

If \mathbf{P} is \gamma-optimal for the sketch against a competitor \mathbf{P}', both orthogonal projectors of rank at most k and \gamma \ge 1, then it is \gamma b / a-optimal for \mathbf{A}: a\|\mathbf{A} - \mathbf{P}\mathbf{A}\|_{\mathsf{F}}^2 \le \gamma\, b\,\|\mathbf{A} - \mathbf{P}'\mathbf{A}\|_{\mathsf{F}}^2\,. In the two-sided form the factor is \gamma(1+\varepsilon)/(1-\varepsilon). The multiplied form needs no a > 0 and is vacuous for a \le 0. [CohenElderMuscoMuscoPersu2015, Lemmas 3 and 4]; there for the minimizer over a set of rank-k projectors and the factors (1+\varepsilon)/(1-\varepsilon) or 1 + \varepsilon; here any competitor and constants a, b.

Lean statement and details
NLAlib.IsProjectionCostPreserving.mul_frobNorm_sub_mul_sq_le.{u_1, u_2, u_3, u_4} {𝕜 : Type u_1}
  [RCLike 𝕜] {l : Type u_2} {m : Type u_3} {n : Type u_4} [Fintype l] [Fintype m] [Fintype n]
  {A : Matrix m n 𝕜} {Ã : Matrix m l 𝕜} {k : ℕ} {a b : ℝ} (h : IsProjectionCostPreserving A Ã k a b)
  {P P' : Matrix m m 𝕜} (hP : IsStarProjection P) (hPk : P.rank ≤ k) (hP' : IsStarProjection P')
  (hP'k : P'.rank ≤ k) {γ : ℝ} (hγ : 1 ≤ γ)
  (hopt : frobNorm (Ã - P * Ã) ^ 2 ≤ γ * frobNorm (Ã - P' * Ã) ^ 2) :
  a * frobNorm (A - P * A) ^ 2 ≤ γ * b * frobNorm (A - P' * A) ^ 2

Full source on GitHub

Copy link

Theorem (Sign-sketch OSE).

for \varepsilon \ge 0, \mathbf{S} = \lvert k \rvert^{-1/2} \, \mathbf{X} is an oblivious subspace embedding for dimension d with constants 1 \mp \varepsilon and failure probability 2 \cdot 21^d e^{-\lvert k \rvert (4\varepsilon^2/25 - 32\varepsilon^3/375)} \,: JL plus a net of radius 1/10 at 4\varepsilon/5 (NLAlib.HasJLProperty.isObliviousSubspaceEmbedding). [Woodruff2014, §2.1, Theorem 6], there with O(\varepsilon) and unspecified constants.

General form: sizes are index types

Lean statement and details
NLAlib.isObliviousSubspaceEmbedding_of_hasLaw_rademacherMatrix.{u_1, u_2, u_3} {Ω : Type u_1}
  {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {k : Type u_2} {n : Type u_3} [Fintype k] [Fintype n]
  {X : Ω → Matrix k n ℝ} {ε : ℝ} (hX : HasLaw X (rademacherMatrix k n) μ) (d : ℕ) (hε : 0 ≤ ε) :
  IsObliviousSubspaceEmbedding (fun ω ↦ (√↑(Fintype.card k))⁻¹ • X ω) d (1 - ε) (1 + ε)
    (2 * 21 ^ d * rexp (-(↑(Fintype.card k) * (4 * ε ^ 2 / 25 - 32 * ε ^ 3 / 375)))) μ

Full source on GitHub

Copy link

Theorem (Row sampling without replacement).

if the leverage scores of \mathbf{U} (any shape and rank) satisfy \ell_i(\mathbf{U}) \le L / \lvert n \rvert, the row-sampling sketch without replacement with k samples is a subspace embedding for \operatorname{range}\mathbf{U} with constants 1 \mp \varepsilon outside probability 2 \operatorname{rank}\mathbf{U} \cdot e^{-\varepsilon^2 k / (3L)} \,, for 0 \le \varepsilon \le 1. Sampling without replacement is never worse than with replacement (NLAlib.hasSubspaceEmbedding_of_hasLaw_samplingSketch at uniform weights has the same bound). [Tropp2011a, Lemma 3.4] (the sampling step of the SRHT, there for orthonormal columns and L = \lvert n \rvert \max_i \ell_i, with the two Chernoff tails before weakening); [Tropp2015, Theorem 5.1.1] (the i.i.d. form).

General form: sizes are index types

Lean statement and details
NLAlib.hasSubspaceEmbedding_of_hasLaw_samplingSketchWithoutReplacement.{u_1, u_2, u_3, u_4, u_5}
  {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {𝕜 : Type u_2} [RCLike 𝕜] {k : Type u_3}
  {n : Type u_4} {r : Type u_5} [Fintype k] [Fintype n] [Fintype r] [DecidableEq n]
  {S : Ω → Matrix k n 𝕜} {U : Matrix n r 𝕜} {L ε : ℝ}
  (hS : HasLaw S (samplingSketchWithoutReplacement k n) μ)
  (hdom : ∀ (i : n), leverageScore U i ≤ L * (↑(Fintype.card n))⁻¹) (hε : 0 ≤ ε) (hε1 : ε ≤ 1) :
  HasSubspaceEmbedding S U (1 - ε) (1 + ε)
    (2 * ↑U.rank * rexp (-ε ^ 2 * ↑(Fintype.card k) / (3 * L))) μ

Full source on GitHub

Copy link

Theorem (Row sampling without replacement: subspace injection).

row sampling without replacement under the domination \ell_i(\mathbf{U}) \le L / \lvert n \rvert is a subspace injection for \operatorname{range}\mathbf{U} with constant 1 - \varepsilon and failure probability \delta, for \varepsilon > 0, \delta > 0 and \lvert k \rvert \ge 2 L \log(\operatorname{rank}\mathbf{U}/\delta)/\varepsilon^2 samples (NLAlib.samplingInjectionDim U.rank L ε δ). [Tropp2011a, Lemma 3.4] (the lower bound, there for orthonormal columns, the sample size \alpha L \log d with d = \operatorname{rank}\mathbf{U} and the Chernoff tail left explicit). Asymptotic form: NLAlib.exists_forall_hasSubspaceInjection_of_hasLaw_samplingSketchWithoutReplacement.

General form: sizes are index types

Lean statement and details
NLAlib.hasSubspaceInjection_of_hasLaw_samplingSketchWithoutReplacement_of_samplingInjectionDim_le.{u_1,
    u_2, u_3, u_4, u_5}
  {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {𝕜 : Type u_2} [RCLike 𝕜] {k : Type u_3}
  {n : Type u_4} {r : Type u_5} [Fintype k] [Fintype n] [Fintype r] [DecidableEq n]
  {S : Ω → Matrix k n 𝕜} {U : Matrix n r 𝕜} {L ε δ : ℝ}
  (hS : HasLaw S (samplingSketchWithoutReplacement k n) μ)
  (hdom : ∀ (i : n), leverageScore U i ≤ L * (↑(Fintype.card n))⁻¹) (hε : 0 < ε) (hδ : 0 < δ)
  (hk : samplingInjectionDim U.rank L ε δ ≤ ↑(Fintype.card k)) :
  HasSubspaceInjection S U (1 - ε) δ μ

Full source on GitHub

Copy link

Theorem (CountSketch OSE).

for \varepsilon > 0, a CountSketch is an oblivious subspace embedding for dimension d with constants 1 \mp \varepsilon and failure probability \frac{d^2 + d}{\lvert k \rvert \varepsilon^2}\,. [Woodruff2014, Theorem 9] (there O(d^2/(\delta\varepsilon^2)) rows, after Meng and Mahoney and Nelson and Nguyen; Woodruff's own route through Theorems 13 and 14 reaches 18 d^2/(\delta\varepsilon^2)). The constant is the proof's; the second-moment route is Meng and Mahoney 2013 and Nelson and Nguyen 2013 (Woodruff, Theorem 9), neither in hand, so the constant is not attributed.

General form: sizes are index types

Lean statement and details
NLAlib.isObliviousSubspaceEmbedding_of_hasLaw_countSketch.{u_1, u_2, u_3, u_4} {Ω : Type u_1}
  {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {𝕜 : Type u_2} [RCLike 𝕜] {k : Type u_3} {n : Type u_4}
  [Fintype k] [Fintype n] [DecidableEq k] {S : Ω → Matrix k n 𝕜} {ε : ℝ}
  (hS : HasLaw S (countSketch k n) μ) (d : ℕ) (hε : 0 < ε) :
  IsObliviousSubspaceEmbedding S d (1 - ε) (1 + ε) ((↑d ^ 2 + ↑d) / (↑(Fintype.card k) * ε ^ 2)) μ

Full source on GitHub

Copy link

Theorem (CountSketch rows suffice for a rank-d projection-cost-preserving sketch).

O((d+1)^2/(\varepsilon^2\delta)) rows give one, with constants 1 \mp \varepsilon and failure probability \delta, over any field, for \varepsilon below an absolute constant; the constants come before every dimension. Proved from NLAlib.hasProjectionCostPreserving_of_hasLaw_countSketch_of_le_card with C = 768 and \varepsilon_0 = 1. [CohenElderMuscoMuscoPersu2015, Theorem 12, Lemma 11 family 2]. Asymptotic: NLAlib.hasProjectionCostPreserving_of_hasLaw_countSketch_of_le_card

General form: sizes are index types

Lean statement and details
NLAlib.exists_forall_hasProjectionCostPreserving_of_hasLaw_countSketch :
  ∃ C ε₀,
    0 < C ∧
      0 < ε₀ ∧
        ∀ {Ω 𝕜 k m n : Type} [inst : MeasurableSpace Ω] [inst_1 : RCLike 𝕜] [inst_2 : Fintype k]
          [inst_3 : Fintype m] [inst_4 : Fintype n] [inst_5 : DecidableEq k] (μ : Measure Ω)
          (S : Ω → Matrix k n 𝕜) (A : Matrix m n 𝕜) (d : ℕ) (ε δ : ℝ),
          HasLaw S (countSketch k n) μ →
            0 < ε →
              ε ≤ ε₀ →
                0 < δ →
                  C * ((↑d + 1) ^ 2 / (ε ^ 2 * δ)) ≤ ↑(Fintype.card k) →
                    HasProjectionCostPreserving S A d (1 - ε) (1 + ε) δ μ

Full source on GitHub

Copy link

Theorem (Flattening).

a randomized unitary transform makes every subspace incoherent. For a bounded orthonormal \mathbf{F} with constant \beta, independent signs \boldsymbol{\xi}, \mathbf{D} = \operatorname{diag}(\boldsymbol{\xi}), any \mathbf{U} with d = \operatorname{rank}\mathbf{U} and t \ge 0, outside probability \lvert n \rvert e^{-t} every leverage score satisfies \ell_i(\mathbf{F}\mathbf{D}\mathbf{U}) \le \frac{\beta\,(d + 2\sqrt{d t} + 2t)}{\lvert n \rvert} \,. [CamanoEpperlyMeyerTropp2025, Imported Theorem 4.3] (there O((d + \log(n/\delta))/n) for a unitary Walsh–Hadamard, cosine or Fourier transform with entries O(n^{-1/2}); they note the argument needs only these two features); [Tropp2011a, Lemma 3.3] (real signs, Walsh–Hadamard, orthonormal \mathbf{U}; (\sqrt{d} + \sqrt{8 \log(n/\delta)})^2 / n outside probability \delta). Here any \mathbf{F} with n \lvert \mathbf{F}_{i,j} \rvert^2 \le \beta, any field, any \mathbf{U}, the Hsu–Kakade–Zhang constant. The proof passes to an orthonormal basis \mathbf{Q} of \operatorname{range}\mathbf{U} (NLAlib.leverageScore_eq_of_range_eq); almost surely \mathbf{F}\mathbf{D}\mathbf{Q} is orthonormal and score i is \|(\mathbf{F}\mathbf{D}\mathbf{Q})_i\|^2 = \|\mathbf{M}_i \boldsymbol{\xi}\|^2 with \mathbf{M}_i = \mathbf{Q}^{\mathsf{T}} \operatorname{diag}(\mathbf{F}_{i,\cdot}), \|\mathbf{M}_i\|_{\mathsf{F}}^2 \le \beta d / \lvert n \rvert and \|\mathbf{M}_i\|_2^2 \le \beta / \lvert n \rvert; the Hsu–Kakade–Zhang tail at proxy 1 per row, then a union over the rows.

General form: sizes are index types

Lean statement and details
NLAlib.measureReal_exists_leverageScore_mul_diagonal_gt_le_of_hasLaw_rademacherVector.{u_1, u_2,
    u_4, u_5}
  {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {𝕜 : Type u_2} [RCLike 𝕜] {n : Type u_4}
  {r : Type u_5} [Fintype n] [Fintype r] [DecidableEq n] {F : Matrix n n 𝕜} {ξ : Ω → n → ℝ}
  {β t : ℝ} (hF : IsBoundedOrthonormal F β) (hξ : HasLaw ξ (rademacherVector n) μ)
  (U : Matrix n r 𝕜) (ht : 0 ≤ t) :
  μ.real
      {ω |
        ∃ i,
          β * (↑U.rank + 2 * √(↑U.rank * t) + 2 * t) * (↑(Fintype.card n))⁻¹ <
            leverageScore ((F * diagonal fun l ↦ ↑(ξ ω l)) * U) i} ≤
    ↑(Fintype.card n) * rexp (-t)

Full source on GitHub

Copy link

Theorem (The SRHT OSE).

for a bounded orthonormal \mathbf{F} with constant \beta, 0 \le \varepsilon \le 1 and t \ge 0, the SRHT is an oblivious subspace embedding for dimension d with constants 1 \mp \varepsilon and failure probability 2 d \exp\Bigl(-\frac{\varepsilon^2 \lvert k \rvert}{3 \beta (d + 2\sqrt{d t} + 2t)}\Bigr) + \lvert n \rvert e^{-t}\,. [Woodruff2014, Theorem 7] (there r = \Omega(\varepsilon^{-2} \log d\, (\sqrt{d} + \sqrt{\log n})^2) rows, probability 0.99, real Walsh, n a power of two); [MartinssonTropp2020, §9.3] (d = O(k \log k), any SRTT); [HalkoMartinssonTropp2011, Theorem 11.1] (the SRFT with complex signs, 0.40 \le \sigma_{\min}, \sigma_{\max} \le 1.48, failure O(1/k)); [Tropp2011a, Theorems 1.3 and 3.1] (Walsh–Hadamard, orthonormal columns: the same constants at 4(\sqrt{d} + \sqrt{8 \log(d \lvert n \rvert)})^2 \log d rows, and 1/\sqrt{6} \le \sigma_{\min}, \sigma_{\max} \le \sqrt{13/6} outside probability 3/d). Here any field, any \mathbf{F} with entry bound \beta, the tail in natural parameters. For \lvert n \rvert < \lvert k \rvert the law is 0, so \mu = 0.

General form: sizes are index types

Lean statement and details
NLAlib.isObliviousSubspaceEmbedding_of_hasLaw_srht.{u_1, u_2, u_3, u_4} {Ω : Type u_1}
  {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {𝕜 : Type u_2} [RCLike 𝕜] {k : Type u_3} {n : Type u_4}
  [Fintype k] [Fintype n] [DecidableEq n] {S : Ω → Matrix k n 𝕜} {F : Matrix n n 𝕜} {β ε t : ℝ}
  (hF : IsBoundedOrthonormal F β) (hS : HasLaw S (srht k F) μ) (d : ℕ) (hε : 0 ≤ ε) (hε1 : ε ≤ 1)
  (ht : 0 ≤ t) :
  IsObliviousSubspaceEmbedding S d (1 - ε) (1 + ε)
    (2 * ↑d * rexp (-ε ^ 2 * ↑(Fintype.card k) / (3 * (β * (↑d + 2 * √(↑d * t) + 2 * t)))) +
      ↑(Fintype.card n) * rexp (-t))
    μ

Full source on GitHub

Copy link

Theorem (The SRHT OSI).

for a bounded orthonormal \mathbf{F} with constant \beta, nonempty k, \lvert k \rvert \le \lvert n \rvert, \varepsilon \ge 0 and t \ge 0, the SRHT is an oblivious subspace injection for dimension d with constant 1 - \varepsilon and failure probability d \exp\Bigl(-\frac{\varepsilon^2 \lvert k \rvert}{2 \beta (d + 2\sqrt{d t} + 2t)}\Bigr) + \lvert n \rvert e^{-t}\,: the lower matrix Chernoff half after flattening. [CamanoEpperlyMeyerTropp2025, §1.5.2] (the OSI view; k = \Omega(d \log d) is necessary, their citation of Tropp 2011a); [Tropp2011a, Theorem 3.1] (Walsh–Hadamard, orthonormal columns: \sigma_{\min} \ge 1/\sqrt{6} at 4(\sqrt{d} + \sqrt{8 \log(d \lvert n \rvert)})^2 \log d rows, outside probability 3/d for both halves). Flattening (NLAlib.measureReal_exists_leverageScore_mul_diagonal_gt_le_of_hasLaw_rademacherVector), then NLAlib.hasSubspaceInjection_of_hasLaw_samplingSketchWithoutReplacement through NLAlib.hasSubspaceInjection_mul_of_indepFun_of_leverageScore_le.

General form: sizes are index types

Lean statement and details
NLAlib.isObliviousSubspaceInjection_of_hasLaw_srht.{u_1, u_2, u_3, u_4} {Ω : Type u_1}
  {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {𝕜 : Type u_2} [RCLike 𝕜] {k : Type u_3} {n : Type u_4}
  [Fintype k] [Fintype n] [DecidableEq n] {S : Ω → Matrix k n 𝕜} {F : Matrix n n 𝕜} {β ε t : ℝ}
  [Nonempty k] (hF : IsBoundedOrthonormal F β) (hS : HasLaw S (srht k F) μ)
  (hk : Fintype.card k ≤ Fintype.card n) (d : ℕ) (hε : 0 ≤ ε) (ht : 0 ≤ t) :
  IsObliviousSubspaceInjection S d (1 - ε)
    (↑d * rexp (-ε ^ 2 * ↑(Fintype.card k) / (2 * (β * (↑d + 2 * √(↑d * t) + 2 * t)))) +
      ↑(Fintype.card n) * rexp (-t))
    μ

Full source on GitHub

Copy link

Theorem (SRHT rows suffice for a rank-d projection-cost-preserving sketch).

O(\beta(d + \log(\lvert n\rvert/\delta))\log(d/\delta)/\varepsilon^2 + \beta^2(d+1)/(\varepsilon^2\delta)) rows give one: for a real bounded orthonormal \mathbf{F} with constant \beta and its SRHT \mathbf{S}, \mathbf{A}\mathbf{S}^{\mathsf{H}} is a rank-d projection-cost-preserving sketch of \mathbf{A} with constants 1 \mp \varepsilon and failure probability \delta, for \varepsilon and \delta below absolute constants; the constants come before every dimension and before \beta. Proved from NLAlib.hasProjectionCostPreserving_of_hasLaw_srht_of_le_card with \varepsilon_0 = 1 and \delta \le 1/2. [CohenElderMuscoMuscoPersu2015, proof of Theorem 12]. Asymptotic: NLAlib.hasProjectionCostPreserving_of_hasLaw_srht_of_le_card

General form: sizes are index types

Lean statement and details
NLAlib.exists_forall_hasProjectionCostPreserving_of_hasLaw_srht :
  ∃ C ε₀,
    0 < C ∧
      0 < ε₀ ∧
        ∀ {Ω k m n : Type} [inst : MeasurableSpace Ω] [inst_1 : Fintype k] [inst_2 : Fintype m]
          [inst_3 : Fintype n] [inst_4 : DecidableEq n] (μ : Measure Ω) (S : Ω → Matrix k n ℝ)
          (F : Matrix n n ℝ) (β : ℝ) (A : Matrix m n ℝ) (d : ℕ) (ε δ : ℝ),
          IsBoundedOrthonormal F β →
            HasLaw S (srht k F) μ →
              0 < ε →
                ε ≤ ε₀ →
                  0 < δ →
                    δ ≤ 1 / 2 →
                      C *
                            (β * (↑d + Real.log (↑(Fintype.card n) / δ)) * Real.log (↑d / δ) /
                                ε ^ 2 +
                              β ^ 2 * (↑d + 1) / (ε ^ 2 * δ)) ≤
                          ↑(Fintype.card k) →
                        HasProjectionCostPreserving S A d (1 - ε) (1 + ε) δ μ

Full source on GitHub

Copy link

Theorem (Sub-Gaussian OSE).

for a random \mathbf{X} with independent, isotropic, sub-Gaussian rows with proxy c, \mathbf{S} = \lvert k \rvert^{-1/2} \, \mathbf{X} is an oblivious subspace embedding for dimension d with constants 1 \mp \varepsilon and failure probability 2 \cdot 21^d \, e^{-\frac{1}{36} \lvert k \rvert \min(16\varepsilon^2/(25c^2), \, 4\varepsilon/(5c))} \,, the constant being subgaussianJLConstant: JL plus a net of radius 1/10 at 4\varepsilon/5 (NLAlib.HasJLProperty.isObliviousSubspaceEmbedding). [Vershynin2018, Theorem 4.6.1, (4.22)], there for the singular values, K^2 \max(\delta, \delta^2) with an unspecified constant; it dominates the rows theorem's Gram sandwich in every regime.

General form: sizes are index types

Lean statement and details
NLAlib.isObliviousSubspaceEmbedding_of_isSubgaussianVector.{u_1, u_2, u_3} {Ω : Type u_1}
  {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {k : Type u_2} {n : Type u_3} [Fintype k] [Fintype n]
  {X : Ω → Matrix k n ℝ} {c : ℝ≥0} {ε : ℝ} [DecidableEq n] (hind : iIndepFun (fun i ω ↦ X ω i) μ)
  (hsub : ∀ (i : k), IsSubgaussianVector (fun ω ↦ X ω i) c μ)
  (hiso : ∀ (i : k), IsIsotropic (fun ω ↦ X ω i) μ) (d : ℕ) :
  IsObliviousSubspaceEmbedding (fun ω ↦ (√↑(Fintype.card k))⁻¹ • X ω) d (1 - ε) (1 + ε)
    (2 * 21 ^ d *
      rexp
        (-(subgaussianJLConstant * ↑(Fintype.card k) *
            min (16 * ε ^ 2 / (25 * ↑c ^ 2)) (4 * ε / (5 * ↑c)))))
    μ

Full source on GitHub

Copy link

Theorem (Sub-Gaussian rows suffice for a rank-d projection-cost-preserving sketch).

O(c^2 (d+1)\log(1/\delta)/\varepsilon^2) independent isotropic rows, sub-Gaussian with proxy c, give one, with constants 1 \mp \varepsilon and failure probability \delta, for \varepsilon and \delta below absolute constants; the constants come before every dimension and the proxy. At c = 1 this covers Rademacher sketches. Proved from NLAlib.hasProjectionCostPreserving_of_isSubgaussianVector_of_subgaussianJLMomentDim_le with \varepsilon_0 = 1 and \delta \le 1/2; isotropy forces c \ge 1 once there is a column. [CohenElderMuscoMuscoPersu2015, proof of Theorem 12]. Asymptotic: NLAlib.hasProjectionCostPreserving_of_isSubgaussianVector_of_subgaussianJLMomentDim_le

General form: sizes are index types

Lean statement and details
NLAlib.exists_forall_hasProjectionCostPreserving_of_isSubgaussianVector :
  ∃ C ε₀,
    0 < C ∧
      0 < ε₀ ∧
        ∀ {Ω k m n : Type} [inst : MeasurableSpace Ω] [inst_1 : Fintype k] [inst_2 : Fintype m]
          [inst_3 : Fintype n] [inst_4 : DecidableEq n] [Nonempty k] (μ : Measure Ω)
          (X : Ω → Matrix k n ℝ) (c : ℝ≥0) (A : Matrix m n ℝ) (d : ℕ) (ε δ : ℝ),
          iIndepFun (fun i ω ↦ X ω i) μ →
            (∀ (i : k), IsSubgaussianVector (fun ω ↦ X ω i) c μ) →
              (∀ (i : k), IsIsotropic (fun ω ↦ X ω i) μ) →
                0 < ε →
                  ε ≤ ε₀ →
                    0 < δ →
                      δ ≤ 1 / 2 →
                        C * (↑c ^ 2 * (↑d + 1) * Real.log (1 / δ) / ε ^ 2) ≤ ↑(Fintype.card k) →
                          HasProjectionCostPreserving (fun ω ↦ (√↑(Fintype.card k))⁻¹ • X ω) A d
                            (1 - ε) (1 + ε) δ μ

Full source on GitHub

Copy link

Formal definitions

Used by algorithms

Broader topics