The LLL algorithm #
The basis reduction algorithm of [LLL82], (1.15)–(1.21), on the rows of an
integer matrix B : Vector (Vector ℤ m) n, with exact rational arithmetic. Its rows, viewed in
EuclideanSpace ℝ (Fin m), are Cslib.Algorithms.LatticeReduction.realRows B.
Each round of Cslib.Algorithms.LatticeReduction.lllLoop δ at stage 0 < k < n computes the
Gram–Schmidt rows (Cslib.Algorithms.LatticeReduction.gramSchmidtRows), achieves |μₖ,ₖ₋₁| ≤ 1/2
by one rounding step (1.18), and then either swaps bₖ₋₁, bₖ and steps back when the exchange
condition (1.5) fails (Case 1, (1.19)), or size-reduces the rest of row k (1.21) and advances
(Case 2, (1.20)). The source indexes the basis from 1; stage k here is stage k + 1 of the
source. Unlike (1.18) and (1.21), which reduce only when |μᵢⱼ| > 1/2, each size-reduction step
subtracts ⌊μᵢⱼ⌉ bⱼ unconditionally; this is a no-op when |μᵢⱼ| < 1/2, and at μᵢⱼ = 1/2 it
replaces μᵢⱼ by -1/2.
Cslib.Algorithms.LatticeReduction.lll runs the loop with δ = 3/4 for
n + 2 (3 (⌊log₂ B⌋ + 1) · n(n-1)/2 + 1) rounds, where B = ∑ᵢ ‖bᵢ‖². The proof that this is
enough is the potential argument of (1.23)–(1.26): every swap divides D = ∏ dᵢ by more than
4/3, every other round advances k, and 1 ≤ D ≤ B^{n(n-1)/2}.
The source notes after (1.5) that 3/4 "may be replaced by any fixed real number y with
1/4 < y < 1". Cslib.Algorithms.LatticeReduction.lllWith δ runs the same loop with parameter δ
for n + 2 (⌈δ/(1-δ)⌉ (⌊log₂ B⌋ + 1) · n(n-1)/2 + 1) rounds: by Bernoulli's inequality
(1/δ)^⌈δ/(1-δ)⌉ ≥ 2, so each swap still divides D by more than 1/δ. For δ = 3/4 this is the
budget of lll (Cslib.Algorithms.LatticeReduction.lll_eq_lllWith).
Main definitions #
Cslib.Algorithms.LatticeReduction.gramSchmidtRows: the Gram–Schmidt rows of an integer matrix.Cslib.Algorithms.LatticeReduction.lllLoop: the LLL loop with parameterδand a round budget.Cslib.Algorithms.LatticeReduction.lll: the LLL algorithm withδ = 3/4.Cslib.Algorithms.LatticeReduction.lllWith: the LLL algorithm with a parameterδ.
Main results #
Cslib.Algorithms.LatticeReduction.lllLoop_spec: the loop invariant, for anyδ > 0(its hypotheses can hold only forδ < 1).Cslib.Algorithms.LatticeReduction.isReduced_lll: on linearly independent rows the output is3/4-reduced and linearly independent.Cslib.Algorithms.LatticeReduction.span_lll: the output spans the same lattice.Cslib.Algorithms.LatticeReduction.isReduced_lllWith,Cslib.Algorithms.LatticeReduction.span_lllWith: the same forlllWith δwith0 < δ < 1.Cslib.Algorithms.LatticeReduction.dotProduct_lll_zero_le: Proposition (1.11) for the output,|b₀|² ≤ 2ⁿ |x|²for every nonzero lattice vectorxofn + 1rows.Cslib.Algorithms.LatticeReduction.dotProduct_lllWith_zero_le: the same forlllWith δwith1/4 < δ < 1and the factor(4/(4δ - 1))ⁿof the remark after (1.9).Cslib.Algorithms.LatticeReduction.linearIndependent_realRows_iff: linear independence is decided by the integer Gram determinant.
The running time is not formalized: each round costs O(n² m) rational operations by
construction, but there is no cost model here, and the bit-size bound of (1.26) is not proved.
References #
Integer bases #
The rows of B as vectors of ℝᵐ.
Size reduction #
After the step bᵢ ← bᵢ - ⌊μᵢⱼ⌉ bⱼ, |μᵢⱼ| ≤ 1/2.
The step bᵢ ← bᵢ - r bⱼ leaves μᵢₗ unchanged for l > j.
Exchange #
The loop #
The first k vectors are reduced: size reduced in rows < k and the exchange condition at
consecutive pairs below k.
The LLL loop ([LLL82], (1.15)–(1.21)) with parameter δ in place of
3/4, for at most fuel rounds, at stage k (stage k + 1 of the source). For 0 < k < n
it computes the Gram–Schmidt rows, achieves |μₖ,ₖ₋₁| ≤ 1/2 (1.18), and then either swaps
bₖ₋₁, bₖ and steps back (Case 1, when (1.5) fails at (k - 1, k)) or size-reduces the rest of
row k (1.21) and advances (Case 2). Each round costs O(n² m) rational operations.
Invariant of the LLL loop: with 0 < δ, the potential below δ⁻¹ ^ s and enough fuel, the
loop returns a δ-reduced linearly independent family. Since the potential of linearly
independent integer rows is at least 1, the hypotheses can hold only for δ < 1.
The algorithm #
The number of exchange steps allowed by the potential argument: 3 (⌊log₂ B⌋ + 1) · n(n-1)/2
bounds log_{4/3} B^{n(n-1)/2}.
The number of exchange steps per doubling of the potential allowed for the parameter δ:
⌈δ / (1 - δ)⌉, so that δ⁻¹ ^ swapFactor δ ≥ 2 for 0 < δ < 1 (two_le_inv_pow_swapFactor).
For δ = 3/4 it is 3.
The number of exchange steps allowed by the potential argument for the parameter δ:
⌈δ / (1 - δ)⌉ (⌊log₂ B⌋ + 1) · n(n-1)/2 bounds log_{1/δ} B^{n(n-1)/2}.
Bernoulli's inequality gives δ⁻¹ ^ ⌈δ / (1 - δ)⌉ ≥ 2 for 0 < δ < 1.
The case δ = 3/4 of potential_realRows_lt_inv_pow.
The LLL algorithm ([LLL82], (1.15)–(1.21)) with parameter δ in place
of 3/4 on the rows of an integer matrix, run for at most n + 2 (swapBudgetOf δ n B + 1)
rounds. The source allows any fixed δ with 1/4 < δ < 1 (remark after (1.5)); termination and
reducedness need only 0 < δ < 1 (isReduced_lllWith), and 1/4 < δ is used for the
approximation bound (dotProduct_lllWith_zero_le).
Correctness of LLL: on linearly independent rows, the output is 3/4-reduced and linearly
independent.
Proposition (1.11) of [LLL82] with the constant of the remark after
(1.9): for 1/4 < δ < 1 and n + 1 linearly independent integer rows, the first row of
lllWith δ B satisfies |b₀|² ≤ (4/(4δ - 1))ⁿ |x|² for every nonzero x in the lattice. As
δ → 1 the factor tends to (4/3)ⁿ.
For n + 1 linearly independent integer rows, the first output row satisfies
|b₀|² ≤ 2ⁿ |x|² for every nonzero x in the lattice. This is (1.11) of
[LLL82], |b₁|² ≤ 2ⁿ⁻¹ |x|² for n vectors in the source's indexing.
A decidable criterion for the hypothesis of isReduced_lll: the integer Gram determinant
is nonzero.