Documentation

CslibFrontier.Algorithms.LatticeReduction.Potential

The LLL potential and the bound on exchange steps #

The LLL algorithm ([LLL82], (1.15)–(1.21)) changes a family b : Fin n → E by two kinds of steps:

Both steps preserve the integer span and linear independence. Size reduction leaves all Gram–Schmidt vectors unchanged, and rounding μᵢⱼ makes |μᵢⱼ| ≤ 1/2 (Cslib.Algorithms.LatticeReduction.abs_gramSchmidtCoeff_round_le). An exchange step changes the i-th Gram–Schmidt vector to b*ᵢ₊₁ + μᵢ₊₁,ᵢ b*ᵢ (Cslib.Algorithms.LatticeReduction.gramSchmidt_swap_self, (1.22)).

The termination argument of (1.23) and (1.26) uses the prefix Gram determinants dₖ = ∏_{j<k} ‖b*ⱼ‖² = det (⟪bᵢ, bⱼ⟫)_{i,j<k} (Cslib.Algorithms.LatticeReduction.gramPrefixDet, Cslib.Algorithms.LatticeReduction.gramPrefixDet_eq_det) and the potential D = ∏_{k<n} dₖ (Cslib.Algorithms.LatticeReduction.potential). Size-reduction steps do not change D, and an exchange step multiplies it by less than δ (Cslib.Algorithms.LatticeReduction.IsSwapStep.potential_lt). When all inner products ⟪bᵢ, bⱼ⟫ are integers (Cslib.Algorithms.LatticeReduction.HasIntegralGram, as for bᵢ ∈ ℤᵐ) and b is linearly independent, each dₖ is a positive integer, so D ≥ 1. If moreover ‖bᵢ‖² ≤ B, then D ≤ B^{n(n-1)/2}. Hence along any run of such steps the number s of exchange steps satisfies (1/δ)ˢ ≤ B^{n(n-1)/2} (Cslib.Algorithms.LatticeReduction.inv_pow_swapCount_le), i.e. s ≤ (n(n-1)/2) log B / log (1/δ) (Cslib.Algorithms.LatticeReduction.swapCount_le).

This bounds exchange steps only. An executable LLL algorithm, the bound on the arithmetic operations and bit sizes of (1.26), and a polynomial-time statement are not formalized here.

Main definitions #

Main results #

References #

noncomputable def Cslib.Algorithms.LatticeReduction.gramPrefixDet {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] {n : ℕ} (b : Fin n → E) (k : ℕ) :

The prefix Gram determinant dₖ = ∏_{j<k} ‖b*ⱼ‖² of [LLL82], (1.24)–(1.25). The product runs over the indices j < k of Fin n.

noncomputable def Cslib.Algorithms.LatticeReduction.potential {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] {n : ℕ} (b : Fin n → E) :

The potential D = ∏_{k<n} dₖ of [LLL82], (1.23). The factor d₀ is 1.

For linearly independent b, every dₖ is positive.

For linearly independent b, the potential is positive.

dₖ is the Gram determinant of b₀, …, bₖ₋₁ ([LLL82], (1.24)–(1.25)).

All inner products ⟪bᵢ, bⱼ⟫ are integers, as for a basis of a sublattice of ℤᵐ.

theorem Cslib.Algorithms.LatticeReduction.exists_int_gramPrefixDet {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] {n : ℕ} {b : Fin n → E} (hb : HasIntegralGram b) {k : ℕ} (hk : k ≤ n) :
∃ (z : ℤ), gramPrefixDet b k = ↑z

With integral inner products, every dₖ with k ≤ n is an integer.

With integral inner products and linear independence, 1 ≤ dₖ for k ≤ n.

With integral inner products and linear independence, 1 ≤ D ([LLL82], (1.26)).

theorem Cslib.Algorithms.LatticeReduction.gramPrefixDet_le {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] {n : ℕ} {b : Fin n → E} {B : ℝ} (hB : ∀ (i : Fin n), ‖b i‖ ^ 2 ≤ B) {k : ℕ} (hk : k ≤ n) :

If ‖bᵢ‖² ≤ B for all i, then dₖ ≤ Bᵏ for k ≤ n.

theorem Cslib.Algorithms.LatticeReduction.potential_le {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] {n : ℕ} {b : Fin n → E} {B : ℝ} (hB : ∀ (i : Fin n), ‖b i‖ ^ 2 ≤ B) :
potential b ≤ B ^ (n * (n - 1) / 2)

If ‖bᵢ‖² ≤ B for all i, then D ≤ B^{n(n-1)/2} ([LLL82], (1.26)).

theorem Cslib.Algorithms.LatticeReduction.exists_int_inner_of_mem_span {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] {n : ℕ} {b : Fin n → E} (hb : HasIntegralGram b) {x y : E} (hx : x ∈ Submodule.span ℤ (Set.range b)) (hy : y ∈ Submodule.span ℤ (Set.range b)) :
∃ (z : ℤ), inner ℝ x y = ↑z

Integral inner products pass from a generating family b to any pair of vectors in its integer span Submodule.span ℤ (Set.range b).

theorem Cslib.Algorithms.LatticeReduction.HasIntegralGram.of_span_le {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] {n m : ℕ} {b : Fin n → E} {c : Fin m → E} (hb : HasIntegralGram b) (hc : ∀ (i : Fin m), c i ∈ Submodule.span ℤ (Set.range b)) :

Integral inner products pass to families inside the integer span.

A size-reduction step bᵢ ← bᵢ - r bⱼ with j < i and r ∈ ℤ.

A size-reduction step leaves every Gram–Schmidt vector unchanged.

A size-reduction step preserves the integer span.

A size-reduction step leaves the potential unchanged.

A size-reduction step preserves linear independence.

After bᵢ ← bᵢ - r bⱼ with j < i, the coefficients of row i become μᵢₗ - r μⱼₗ (as in [LLL82], (1.18)).

Subtracting round μᵢⱼ times bⱼ makes |μᵢⱼ| ≤ 1/2, provided b*ⱼ ≠ 0.

Subtracting round μᵢⱼ times bⱼ makes |μᵢⱼ| ≤ 1/2, for linearly independent b.

An exchange step: swap bᵢ and bᵢ₊₁ when condition (1.5) fails at i. This allows any such i, so it is more general than Case 1 of [LLL82], which swaps only at the current stage and after (1.18); the potential argument needs only the failure of (1.5).

An exchange step preserves the integer span.

An exchange step preserves linear independence.

theorem Cslib.Algorithms.LatticeReduction.gramSchmidt_swap_of_lt {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] {n : ℕ} {b : Fin n → E} {i j l : Fin n} (hij : ↑j = ↑i + 1) (hl : l < i) :

Swapping bᵢ and bᵢ₊₁ leaves the Gram–Schmidt vectors before i unchanged.

After swapping bᵢ and bᵢ₊₁, the new i-th Gram–Schmidt vector is b*ᵢ₊₁ + μ (i+1) i • b*ᵢ ([LLL82], (1.22)).

theorem Cslib.Algorithms.LatticeReduction.IsSwapStep.exists_norm_sq_lt {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] {n : ℕ} {δ : ℝ} {b c : Fin n → E} (h : IsSwapStep δ b c) :
∃ (i : Fin n) (j : Fin n), ↑j = ↑i + 1 ∧ c = b ∘ ⇑(Equiv.swap i j) ∧ ‖InnerProductSpace.gramSchmidt ℝ c i‖ ^ 2 < δ * ‖InnerProductSpace.gramSchmidt ℝ b i‖ ^ 2

An exchange step at i makes ‖b*ᵢ‖² smaller than δ times its old value.

dₗ₊₁ = dₗ ‖b*ₗ‖².

theorem Cslib.Algorithms.LatticeReduction.gramPrefixDet_swap_of_le {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] {n : ℕ} {b : Fin n → E} {i j : Fin n} (hij : ↑j = ↑i + 1) {m : ℕ} (hm : m ≤ ↑i) :

Swapping bᵢ and bᵢ₊₁ leaves dₘ unchanged for m ≤ i.

theorem Cslib.Algorithms.LatticeReduction.gramPrefixDet_swap_of_lt {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] {n : ℕ} {b : Fin n → E} {i j : Fin n} (hij : ↑j = ↑i + 1) {m : ℕ} (hjm : ↑j < m) (hm : m ≤ n) :

Swapping bᵢ and bᵢ₊₁ leaves dₘ unchanged for i + 1 < m ≤ n.

An exchange step decreases the potential by a factor less than δ ([LLL82], (1.23)).

A size-reduction step preserves integral inner products.

An exchange step preserves integral inner products.

One step of the LLL algorithm: a size-reduction step or an exchange step.

noncomputable def Cslib.Algorithms.LatticeReduction.swapCount {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] {n : ℕ} (δ : ℝ) (b : ℕ → Fin n → E) (T : ℕ) :

The number of exchange steps among the first T steps of a run b.

theorem Cslib.Algorithms.LatticeReduction.swapCount_succ {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] {n : ℕ} (δ : ℝ) (b : ℕ → Fin n → E) (T : ℕ) [Decidable (IsSwapStep δ (b T) (b (T + 1)))] :
swapCount δ b (T + 1) = swapCount δ b T + if IsSwapStep δ (b T) (b (T + 1)) then 1 else 0

Unfolding swapCount by one step.

theorem Cslib.Algorithms.LatticeReduction.inv_pow_swapCount_le {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] {n : ℕ} {δ B : ℝ} (hδ : 0 < δ) {b : ℕ → Fin n → E} (hli : LinearIndependent ℝ (b 0)) (hint : HasIntegralGram (b 0)) (hB : ∀ (i : Fin n), ‖b 0 i‖ ^ 2 ≤ B) (T : ℕ) (hstep : ∀ t < T, IsStep δ (b t) (b (t + 1))) :
δ⁻¹ ^ swapCount δ b T ≤ B ^ (n * (n - 1) / 2)

Bound on the number of exchange steps ([LLL82], proof of (1.26)): along any run of T size-reduction and exchange steps from a linearly independent b₀ with integral inner products and ‖b₀ᵢ‖² ≤ B, the number s of exchange steps satisfies (1/δ)ˢ ≤ B^{n(n-1)/2}.

theorem Cslib.Algorithms.LatticeReduction.swapCount_le {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] {n : ℕ} {δ B : ℝ} (hδ : 0 < δ) (hδ1 : δ < 1) {b : ℕ → Fin n → E} (hli : LinearIndependent ℝ (b 0)) (hint : HasIntegralGram (b 0)) (hB : ∀ (i : Fin n), ‖b 0 i‖ ^ 2 ≤ B) (T : ℕ) (hstep : ∀ t < T, IsStep δ (b t) (b (t + 1))) :
↑(swapCount δ b T) ≤ ↑(n * (n - 1) / 2) * Real.log B / Real.log δ⁻¹

Logarithmic form: at most (n(n-1)/2) log B / log (1/δ) exchange steps, i.e. O(n² log B) for fixed δ < 1.