Documentation

CslibFrontier.Algorithms.LatticeReduction.RationalGramSchmidt

Exact rational Gram–Schmidt on the rows of a matrix #

The LLL algorithm of [LLL82] computes the Gram–Schmidt vectors b*ᵢ and the coefficients μᵢⱼ of an integer basis exactly, over ℚ. This file provides that computation on the rows of a Vector (Vector ℚ m) n and proves that it agrees with Mathlib's real InnerProductSpace.gramSchmidt after the coordinate embedding Cslib.Algorithms.LatticeReduction.ratToEuclidean : (Fin m → ℚ) → EuclideanSpace ℝ (Fin m).

Cslib.Algorithms.LatticeReduction.gramSchmidtRowsAux bq t orthogonalizes rows 0, …, t - 1, each with one pass over the earlier rows (formulas (1.2)–(1.3) of [LLL82]), so n rows cost O(n² m) rational operations. The rows are data, not functions, so each b*ⱼ is computed once.

Main definitions #

Main results #

References #

Rational vectors in Euclidean space #

A rational vector as a point of Euclidean space.

@[simp]
theorem Cslib.Algorithms.LatticeReduction.ratToEuclidean_apply {m : ℕ} (v : Fin m → ℚ) (k : Fin m) :
(ratToEuclidean v).ofLp k = ↑(v k)
theorem Cslib.Algorithms.LatticeReduction.ratToEuclidean_sub_sum {m : ℕ} {ι : Type u_1} (v : Fin m → ℚ) (s : Finset ι) (c : ι → ℚ) (g : ι → Fin m → ℚ) :
(ratToEuclidean fun (k : Fin m) => v k - ∑ j ∈ s, c j * g j k) = ratToEuclidean v - ∑ j ∈ s, ↑(c j) • ratToEuclidean (g j)

The projection coefficient ⟨g, v⟩ / ⟨g, g⟩.

Exact Gram–Schmidt on rows #

The rows 0, …, t - 1 of the Gram–Schmidt orthogonalization of the rows of bq; the other rows are those of bq. Each row costs O(n m) rational operations.

theorem Cslib.Algorithms.LatticeReduction.gramSchmidtRowsAux_spec {m n : ℕ} (bq : Vector (Vector ℚ m) n) (t : ℕ) (i : Fin n) :
↑i < t → (ratToEuclidean fun (k : Fin m) => (gramSchmidtRowsAux bq t)[i][k]) = InnerProductSpace.gramSchmidt ℝ (fun (l : Fin n) => ratToEuclidean fun (k : Fin m) => bq[l][k]) i