NLA-lib Explorer

Johnson–Lindenstrauss lemma

Library · Result group

Theorem (HasJLProperty.measureReal_exists_abs_norm_mulVec_sq_sub_ge_le). 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.

Headline (provisional) 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

Other forms

Theorem (exists_forall_abs_norm_mulVec_sq_sub_le_of_jlDim_le). The Johnson–Lindenstrauss lemma, existence form: for points \mathbf{x}_i in \mathbb{R}^n, N = \lvert \iota \rvert, \delta = 1/(\binom{N}{2} + 1) and <!-- value jlDim \varepsilon \delta --> \lvert k \rvert \ge \log(2/\delta)/(\varepsilon^2/4 - \varepsilon^3/6) (jlDim at distortion \varepsilon and failure probability \delta), some k \times n matrix \mathbf{S} distorts every squared distance \|\mathbf{x}_i - \mathbf{x}_j\|^2 by a factor within 1 \pm \varepsilon, for 0 < \varepsilon < 3/2. A scaled Gaussian works with positive probability (the union bound over pairs, failure < 1). [Woodruff2014, Theorem 4], in squared-norm form; [MartinssonTropp2020, §8.6].

General form: sizes are index types

Lean statement and details
NLAlib.exists_forall_abs_norm_mulVec_sq_sub_le_of_jlDim_le.{u_2, u_3, u_5} {k : Type u_2}
  {n : Type u_3} {ι : Type u_5} [Fintype k] [Fintype n] {ε : ℝ} [Fintype ι] (x : ι → n → ℝ)
  (hε : 0 < ε) (hε1 : ε < 3 / 2)
  (hk : jlDim ε (1 / (↑((Fintype.card ι).choose 2) + 1)) ≤ ↑(Fintype.card k)) :
  ∃ S,
    ∀ (i j : ι),
      |‖WithLp.toLp 2 (S *ᵥ (x i - x j))‖ ^ 2 - ‖WithLp.toLp 2 (x i - x j)‖ ^ 2| ≤
        ε * ‖WithLp.toLp 2 (x i - x j)‖ ^ 2

Full source on GitHub

Copy link

General form: sizes are index types. A size is carried by a finite index type: |k| is the number of elements of the index type k, and "k nonempty" means k ≥ 1.