Documentation

CslibFrontier.Algorithms.LatticeReduction.Babai

Babai's nearest-plane algorithm #

Babai's nearest-plane algorithm ([Bab86]; [Reg04], Lecture 3, §1) on the rows of an integer matrix B : Vector (Vector ℤ m) n and an integer target t ∈ ℤᵐ, with exact rational Gram–Schmidt vectors b*ⱼ. Starting from r = t, for j = n - 1, …, 0 it rounds the Gram–Schmidt coordinate cⱼ = ⌊⟨r, b*ⱼ⟩ / ⟨b*ⱼ, b*ⱼ⟩⌉ and sets r ← r - cⱼ bⱼ; the output is t - r (Cslib.Algorithms.LatticeReduction.nearestPlane). It is a lattice point, and every Gram–Schmidt coordinate of t - (t - r) = r lies in [-1/2, 1/2] (Cslib.Algorithms.LatticeReduction.isNearestPlane_nearestPlane).

Cslib.Algorithms.LatticeReduction.babai runs nearestPlane on the output of the LLL algorithm Cslib.Algorithms.LatticeReduction.lll. For linearly independent rows, the output y satisfies |y - t|² ≤ 2ⁿ |v - t|² for every lattice vector v (Cslib.Algorithms.LatticeReduction.babai_dotProduct_le): it solves the closest vector problem within a factor 2^{n/2}, [Reg04], Lecture 3, Lemma 6.

The target is an integer vector, as in [Reg04]; the abstract bound Cslib.Algorithms.LatticeReduction.IsNearestPlane.norm_sq_le holds for arbitrary real targets.

Main definitions #

Main results #

The running time is not formalized: the loop costs O(n m) rational operations after the Gram–Schmidt computation, but there is no cost model here, and the running time of lll is itself not yet bounded.

References #

The residual of the nearest-plane loop after the rounds j = k - 1, …, 0: for each j, round cⱼ = ⌊⟨r, b*ⱼ⟩ / ⟨b*ⱼ, b*ⱼ⟩⌉ with the Gram–Schmidt rows G and set r ← r - cⱼ bⱼ.

Babai's nearest-plane algorithm ([Bab86]; [Reg04], Lecture 3, §1) on the rows of B and the target t, without the preliminary basis reduction.

Babai's algorithm: LLL reduction ([LLL82]) followed by the nearest-plane loop.

theorem Cslib.Algorithms.LatticeReduction.nearestPlaneAux_spec {m n : ℕ} {G : Vector (Vector ℚ m) n} {B : Vector (Vector ℤ m) n} (hG : IsGramSchmidtRows G B) (k : ℕ) (r : Vector ℤ m) :
k ≤ n → ∃ (e : Fin n → ℤ), (∀ (i : Fin n), k ≤ ↑i → e i = 0) ∧ r.get - (nearestPlaneAux G B k r).get = ∑ i : Fin n, e i • rows B i ∧ ∀ (j : Fin n), ↑j < k → |inner ℝ (InnerProductSpace.gramSchmidt ℝ (realRows B) j) (intToEuclidean (nearestPlaneAux G B k r).get)| ≤ ‖InnerProductSpace.gramSchmidt ℝ (realRows B) j‖ ^ 2 / 2

The loop invariant: r - nearestPlaneAux G B k r = ∑ⱼ eⱼ bⱼ with eⱼ = 0 for j ≥ k, and the Gram–Schmidt coordinates of the output at j < k lie in [-1/2, 1/2].

The output of the nearest-plane loop: t - nearestPlane B t is the residual of the loop, so nearestPlane B t = ∑ⱼ eⱼ bⱼ for some integers eⱼ, and every Gram–Schmidt coordinate of t - nearestPlane B t lies in [-1/2, 1/2].

The nearest-plane loop satisfies the nearest-plane condition for the rows of B, with the target and output embedded in ℝᵐ.

The output of babai lies in the lattice spanned by the rows of B.

theorem Cslib.Algorithms.LatticeReduction.babai_dotProduct_le {m n : ℕ} (B : Vector (Vector ℤ m) n) (hB : LinearIndependent ℝ (realRows B)) (t : Vector ℤ m) {v : Fin m → ℤ} (hv : v ∈ Submodule.span ℤ (Set.range (rows B))) :
((babai B t).get - t.get) ⬝ᵥ ((babai B t).get - t.get) ≤ 2 ^ n * (v - t.get) ⬝ᵥ (v - t.get)

Babai's algorithm solves the closest vector problem within a factor 2^{n/2} ([Reg04], Lecture 3, Lemma 6): for linearly independent integer rows b₀, …, bₙ₋₁ and an integer target t, the output y satisfies |y - t|² ≤ 2ⁿ |v - t|² for every vector v of the lattice spanned by the rows.