An open API service indexing awesome lists of open source software.

https://github.com/leanprover/hex-lll-mathlib

Mathlib correspondence proofs for hex-lll
https://github.com/leanprover/hex-lll-mathlib

Last synced: about 1 month ago
JSON representation

Mathlib correspondence proofs for hex-lll

Awesome Lists containing this project

README

          

# hex-lll-mathlib

Part of [`hex`](https://github.com/kim-em/hex-dev), a computer algebra
library for Lean 4. The aim is fast executable code, fully verified, built
with spec-driven development.

`hex-lll-mathlib` is the Mathlib bridge for
[`hex-lll`](https://github.com/leanprover/hex-lll). Its headline result is the LLL
short-vector guarantee, stated in Mathlib's Euclidean norm: for an independent
integer basis, the executable `Hex.lll` returns a first row that is short
relative to *every* nonzero lattice vector, and so in particular relative to
the actual shortest one. To state it the bridge models the integer row lattice
of an executable `Hex.Matrix` as a `Submodule ℤ`, identifies that submodule
with the executable `Hex.Matrix.memLattice` predicate, and transports the
executable squared-norm bound into `EuclideanSpace`. It depends on
[`hex-lll`](https://github.com/leanprover/hex-lll) and Mathlib.

# Quickstart

Add to your `lakefile.toml`:

```toml
[[require]]
name = "hex-lll-mathlib"
git = "https://github.com/leanprover/hex-lll-mathlib.git"
rev = "main"
```

```lean
import HexLLLMathlib

open HexLLLMathlib

-- The headline: the reduced first row is short relative to any lattice vector.
#check @lll_first_row_norm_sq_le_unconditional

-- The executable row lattice as a Mathlib `Submodule ℤ`, and `Hex.lll`
-- preserving it.
#check @latticeSubmodule
#check @lll_mem_latticeSubmodule_iff
```

# Verification

Every result builds without `sorry`.

**The short-vector guarantee.** For an independent basis `b`, any factor
`δ` with `121/400 < δ ≤ 1` (`121/400 = (11/20)²`, the public size-reduction
bound; see [`hex-lll`](https://github.com/leanprover/hex-lll) for why `11/20`), and
any nonzero lattice vector `x`, the first row
of `Hex.lll b δ …` has squared Euclidean norm at most
`(1 / (δ − 121/400))^(n−1)` times that of `x`:

```lean
theorem lll_first_row_norm_sq_le_unconditional
(b : Hex.Matrix Int n m) (δ : Rat)
(hδ : (121 / 400 : Rat) < δ) (hδ' : δ ≤ 1) (hn : 1 ≤ n)
(hind : b.independent)
(x : Fin m → ℤ) (hx : x ∈ latticeSubmodule b) (hx0 : x ≠ 0) :
‖intRowToEuclidean
(Hex.Matrix.row (Hex.lll b δ hδ hδ' hn hind)
⟨0, Nat.lt_of_lt_of_le Nat.zero_lt_one hn⟩)‖ ^ 2 ≤
(((1 / (δ - 121 / 400)) ^ (n - 1) : Rat) : ℝ) *
‖intVectorToEuclidean x‖ ^ 2
```

The bound is on the *squared* norm, so on length itself the factor is its
square root: the reduced first row is no longer than
`(1 / (δ − 121/400))^((n−1)/2)` times any nonzero lattice vector. Because the
statement quantifies over every nonzero `x ∈ latticeSubmodule b`, instantiating
`x` at a shortest nonzero lattice vector reads off the classical conclusion:
`Hex.lll` finds a vector at most `(1 / (δ − 121/400))^((n−1)/2)` times the
length of the shortest. At `δ = 3/4` that base is `400/179 ≈ 2.235`, so the
length factor is about `1.057^(n−1)`.

The result holds regardless of which path the dispatched `Hex.lll` took, since
the native and certified-external paths establish the same `(δ, 11/20)`-reduced
and same-lattice post-condition the bound consumes. The native entry
`Hex.lllNative` carries the stronger classical statement at the tighter base
`1/(δ − 1/4)` (length factor `(1 / (δ − 1/4))^((n−1)/2)`, the classical LLL
bound) in `lllNative_first_row_norm_sq_le_unconditional`.

**Lattice preservation.** `Hex.lll` and `Hex.lllNative` leave the generated
submodule unchanged:

```lean
theorem lll_mem_latticeSubmodule_iff
(b : Hex.Matrix Int n m) (δ : Rat)
(hδ : (121 / 400 : Rat) < δ) (hδ' : δ ≤ 1) (hn : 1 ≤ n)
(hind : b.independent) (x : Fin m → ℤ) :
x ∈ latticeSubmodule (Hex.lll b δ hδ hδ' hn hind) ↔ x ∈ latticeSubmodule b
```

# Functionality

The bridge connects the executable surface of `hex-lll` to Mathlib's linear
algebra:

- `latticeSubmodule b`: the `Submodule ℤ (Fin m → ℤ)` generated by the rows of
an executable basis `b`, with `mem_latticeSubmodule_iff` and
`memLattice_iff_mem_latticeSubmodule` tying membership to the executable
`Hex.Matrix.memLattice`; `prefixSubmodule b t` is the submodule of the first
`t` rows.
- `intRowToEuclidean` and `intVectorToEuclidean` send integer rows and lattice
vectors into `EuclideanSpace ℝ (Fin m)`, with `norm_sq_intRowToEuclidean` and
`norm_sq_intVectorToEuclidean` relating the Euclidean norm to the executable
squared norm. Together with `HexMatrixMathlib.vectorEquiv` (the bijection
`Vector Int m ≃ (Fin m → ℤ)`) these turn the executable rational bound into
the Euclidean statement above.
- the short-vector capstones `lll_first_row_norm_sq_le_unconditional` and
`lllNative_first_row_norm_sq_le_unconditional`, and the lattice-preservation
transfer lemmas `lll_mem_latticeSubmodule_iff` and
`lllNative_mem_latticeSubmodule_iff`.
- the checker soundness theorems `lllReducedInt_sound`,
`lllReducedInterval_sound`, `lllReducedCheck_sound`, and `certCheck_sound`,
which entail the rational `Hex.isLLLReduced` predicate and the same-lattice
property from acceptance of the executable Bool checkers.

The executable algorithm, the rational short-vector bound, and the reducedness
theory live in [`hex-lll`](https://github.com/leanprover/hex-lll).

# Reference manual

The hex reference manual covers this library and its computational base at
.

# Contributing

Development happens in the [`hex-dev`](https://github.com/kim-em/hex-dev)
monorepo, not in this published mirror. Contributions are welcome as pull
requests to the `SPEC/` directory: describe the behaviour you want, and
leave the implementation to the maintainer.