{"id":51369439,"url":"https://github.com/leanprover/hex-lll-mathlib","last_synced_at":"2026-07-03T05:01:56.460Z","repository":{"id":367258690,"uuid":"1279169221","full_name":"leanprover/hex-lll-mathlib","owner":"leanprover","description":"Mathlib correspondence proofs for hex-lll","archived":false,"fork":false,"pushed_at":"2026-07-02T00:54:44.000Z","size":295,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-07-02T02:25:27.548Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://kim-em.github.io/hex-dev/find/?domain=Verso.Genre.Manual.section\u0026name=hex-lll","language":"Lean","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leanprover.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-06-24T12:43:00.000Z","updated_at":"2026-07-02T00:54:49.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/leanprover/hex-lll-mathlib","commit_stats":null,"previous_names":["kim-em/hex-lll-mathlib","leanprover/hex-lll-mathlib"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/leanprover/hex-lll-mathlib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leanprover%2Fhex-lll-mathlib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leanprover%2Fhex-lll-mathlib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leanprover%2Fhex-lll-mathlib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leanprover%2Fhex-lll-mathlib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leanprover","download_url":"https://codeload.github.com/leanprover/hex-lll-mathlib/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leanprover%2Fhex-lll-mathlib/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35072845,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-03T02:00:05.635Z","response_time":110,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-07-03T05:00:44.215Z","updated_at":"2026-07-03T05:01:56.439Z","avatar_url":"https://github.com/leanprover.png","language":"Lean","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hex-lll-mathlib\n\nPart of [`hex`](https://github.com/kim-em/hex-dev), a computer algebra\nlibrary for Lean 4. The aim is fast executable code, fully verified, built\nwith spec-driven development.\n\n`hex-lll-mathlib` is the Mathlib bridge for\n[`hex-lll`](https://github.com/leanprover/hex-lll). Its headline result is the LLL\nshort-vector guarantee, stated in Mathlib's Euclidean norm: for an independent\ninteger basis, the executable `Hex.lll` returns a first row that is short\nrelative to *every* nonzero lattice vector, and so in particular relative to\nthe actual shortest one. To state it the bridge models the integer row lattice\nof an executable `Hex.Matrix` as a `Submodule ℤ`, identifies that submodule\nwith the executable `Hex.Matrix.memLattice` predicate, and transports the\nexecutable squared-norm bound into `EuclideanSpace`. It depends on\n[`hex-lll`](https://github.com/leanprover/hex-lll) and Mathlib.\n\n# Quickstart\n\nAdd to your `lakefile.toml`:\n\n```toml\n[[require]]\nname = \"hex-lll-mathlib\"\ngit = \"https://github.com/leanprover/hex-lll-mathlib.git\"\nrev = \"main\"\n```\n\n```lean\nimport HexLLLMathlib\n\nopen HexLLLMathlib\n\n-- The headline: the reduced first row is short relative to any lattice vector.\n#check @lll_first_row_norm_sq_le_unconditional\n\n-- The executable row lattice as a Mathlib `Submodule ℤ`, and `Hex.lll`\n-- preserving it.\n#check @latticeSubmodule\n#check @lll_mem_latticeSubmodule_iff\n```\n\n# Verification\n\nEvery result builds without `sorry`.\n\n**The short-vector guarantee.** For an independent basis `b`, any factor\n`δ` with `121/400 \u003c δ ≤ 1` (`121/400 = (11/20)²`, the public size-reduction\nbound; see [`hex-lll`](https://github.com/leanprover/hex-lll) for why `11/20`), and\nany nonzero lattice vector `x`, the first row\nof `Hex.lll b δ …` has squared Euclidean norm at most\n`(1 / (δ − 121/400))^(n−1)` times that of `x`:\n\n```lean\ntheorem lll_first_row_norm_sq_le_unconditional\n    (b : Hex.Matrix Int n m) (δ : Rat)\n    (hδ : (121 / 400 : Rat) \u003c δ) (hδ' : δ ≤ 1) (hn : 1 ≤ n)\n    (hind : b.independent)\n    (x : Fin m → ℤ) (hx : x ∈ latticeSubmodule b) (hx0 : x ≠ 0) :\n    ‖intRowToEuclidean\n        (Hex.Matrix.row (Hex.lll b δ hδ hδ' hn hind)\n          ⟨0, Nat.lt_of_lt_of_le Nat.zero_lt_one hn⟩)‖ ^ 2 ≤\n      (((1 / (δ - 121 / 400)) ^ (n - 1) : Rat) : ℝ) *\n        ‖intVectorToEuclidean x‖ ^ 2\n```\n\nThe bound is on the *squared* norm, so on length itself the factor is its\nsquare root: the reduced first row is no longer than\n`(1 / (δ − 121/400))^((n−1)/2)` times any nonzero lattice vector. Because the\nstatement quantifies over every nonzero `x ∈ latticeSubmodule b`, instantiating\n`x` at a shortest nonzero lattice vector reads off the classical conclusion:\n`Hex.lll` finds a vector at most `(1 / (δ − 121/400))^((n−1)/2)` times the\nlength of the shortest. At `δ = 3/4` that base is `400/179 ≈ 2.235`, so the\nlength factor is about `1.057^(n−1)`.\n\nThe result holds regardless of which path the dispatched `Hex.lll` took, since\nthe native and certified-external paths establish the same `(δ, 11/20)`-reduced\nand same-lattice post-condition the bound consumes. The native entry\n`Hex.lllNative` carries the stronger classical statement at the tighter base\n`1/(δ − 1/4)` (length factor `(1 / (δ − 1/4))^((n−1)/2)`, the classical LLL\nbound) in `lllNative_first_row_norm_sq_le_unconditional`.\n\n**Lattice preservation.** `Hex.lll` and `Hex.lllNative` leave the generated\nsubmodule unchanged:\n\n```lean\ntheorem lll_mem_latticeSubmodule_iff\n    (b : Hex.Matrix Int n m) (δ : Rat)\n    (hδ : (121 / 400 : Rat) \u003c δ) (hδ' : δ ≤ 1) (hn : 1 ≤ n)\n    (hind : b.independent) (x : Fin m → ℤ) :\n    x ∈ latticeSubmodule (Hex.lll b δ hδ hδ' hn hind) ↔ x ∈ latticeSubmodule b\n```\n\n# Functionality\n\nThe bridge connects the executable surface of `hex-lll` to Mathlib's linear\nalgebra:\n\n- `latticeSubmodule b`: the `Submodule ℤ (Fin m → ℤ)` generated by the rows of\n  an executable basis `b`, with `mem_latticeSubmodule_iff` and\n  `memLattice_iff_mem_latticeSubmodule` tying membership to the executable\n  `Hex.Matrix.memLattice`; `prefixSubmodule b t` is the submodule of the first\n  `t` rows.\n- `intRowToEuclidean` and `intVectorToEuclidean` send integer rows and lattice\n  vectors into `EuclideanSpace ℝ (Fin m)`, with `norm_sq_intRowToEuclidean` and\n  `norm_sq_intVectorToEuclidean` relating the Euclidean norm to the executable\n  squared norm. Together with `HexMatrixMathlib.vectorEquiv` (the bijection\n  `Vector Int m ≃ (Fin m → ℤ)`) these turn the executable rational bound into\n  the Euclidean statement above.\n- the short-vector capstones `lll_first_row_norm_sq_le_unconditional` and\n  `lllNative_first_row_norm_sq_le_unconditional`, and the lattice-preservation\n  transfer lemmas `lll_mem_latticeSubmodule_iff` and\n  `lllNative_mem_latticeSubmodule_iff`.\n- the checker soundness theorems `lllReducedInt_sound`,\n  `lllReducedInterval_sound`, `lllReducedCheck_sound`, and `certCheck_sound`,\n  which entail the rational `Hex.isLLLReduced` predicate and the same-lattice\n  property from acceptance of the executable Bool checkers.\n\nThe executable algorithm, the rational short-vector bound, and the reducedness\ntheory live in [`hex-lll`](https://github.com/leanprover/hex-lll).\n\n# Reference manual\n\nThe hex reference manual covers this library and its computational base at\n\u003chttps://kim-em.github.io/hex-dev/find/?domain=Verso.Genre.Manual.section\u0026name=hex-lll\u003e.\n\n# Contributing\n\nDevelopment happens in the [`hex-dev`](https://github.com/kim-em/hex-dev)\nmonorepo, not in this published mirror. Contributions are welcome as pull\nrequests to the `SPEC/` directory: describe the behaviour you want, and\nleave the implementation to the maintainer.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleanprover%2Fhex-lll-mathlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleanprover%2Fhex-lll-mathlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleanprover%2Fhex-lll-mathlib/lists"}