{"id":51369442,"url":"https://github.com/leanprover/hex-gram-schmidt","last_synced_at":"2026-07-03T05:01:56.719Z","repository":{"id":367128068,"uuid":"1279153067","full_name":"leanprover/hex-gram-schmidt","owner":"leanprover","description":"Integer Gram-Schmidt orthogonalization for the hex project. Mathlib-free.","archived":false,"fork":false,"pushed_at":"2026-07-02T00:54:40.000Z","size":713,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-07-02T02:25:26.888Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://kim-em.github.io/hex-dev/find/?domain=Verso.Genre.Manual.section\u0026name=hex-gram-schmidt","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:25:37.000Z","updated_at":"2026-07-02T00:54:44.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/leanprover/hex-gram-schmidt","commit_stats":null,"previous_names":["kim-em/hex-gram-schmidt","leanprover/hex-gram-schmidt"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/leanprover/hex-gram-schmidt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leanprover%2Fhex-gram-schmidt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leanprover%2Fhex-gram-schmidt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leanprover%2Fhex-gram-schmidt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leanprover%2Fhex-gram-schmidt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leanprover","download_url":"https://codeload.github.com/leanprover/hex-gram-schmidt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leanprover%2Fhex-gram-schmidt/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:46.147Z","updated_at":"2026-07-03T05:01:56.662Z","avatar_url":"https://github.com/leanprover.png","language":"Lean","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hex-gram-schmidt\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-gram-schmidt` provides executable Gram-Schmidt orthogonalization for\ninteger and rational matrices: the orthogonal basis, the triangular\ncoefficient matrix, the leading Gram determinants, and the update formulas\nunder lattice row operations. The integer construction is fraction-free,\nrunning over [`hex-matrix`](https://github.com/leanprover/hex-matrix) and the\nBareiss determinant from [`hex-bareiss`](https://github.com/leanprover/hex-bareiss);\n[`hex-determinant`](https://github.com/leanprover/hex-determinant) and\n[`hex-row-reduce`](https://github.com/leanprover/hex-row-reduce) complete the\nmatrix toolkit it builds on. See\n[`hex-gram-schmidt-mathlib`](https://github.com/leanprover/hex-gram-schmidt-mathlib)\nfor the correspondence with Mathlib's `gramSchmidt`.\n\n# Quickstart\n\nAdd to your `lakefile.toml`:\n\n```toml\n[[require]]\nname = \"hex-gram-schmidt\"\ngit = \"https://github.com/leanprover/hex-gram-schmidt.git\"\nrev = \"main\"\n```\n\n```lean\nimport HexGramSchmidt\n\nopen Hex\n\n-- An integer basis, one lattice generator per row.\ndef B : Matrix Int 3 3 := Matrix.ofFn fun i j =\u003e if i = j then (2 : Int) else 1\n\n-- Leading Gram determinants dₖ and the integer scaled coefficients\n-- νᵢⱼ = dⱼ₊₁·μᵢⱼ come from a fraction-free Bareiss pass (no rational division).\n#check (GramSchmidt.Int.gramDet B 3 (by decide) : Nat)   -- 16\n#check (GramSchmidt.Int.gramDetVec B : Vector Nat 4)     -- #v[1, 6, 11, 16]\n#check (GramSchmidt.Int.scaledCoeffs B : Matrix Int 3 3) -- diagonal 6, 11, 16\n\n-- Lattice row operations are plain data transforms.\n#eval GramSchmidt.Int.sizeReduce B 0 2 1          -- row 2 ← row 2 − 1·row 0\n#eval GramSchmidt.Int.adjacentSwap B 1 (by decide)\n\n-- Rational input goes through GramSchmidt.Rat.\ndef C : Matrix Rat 2 2 := Matrix.ofFn fun i j =\u003e if i = j then ((1 : Rat) / 2) else 0\n#check (GramSchmidt.Rat.gramDet C 2 (by decide) : Rat)   -- 1/4\n```\n\n# Functionality\n\nThe integer construction `GramSchmidt.Int`:\n\n- `gramDet` and `gramDetVec`: the leading principal Gram determinants,\n  computed together in one Bareiss pass;\n- `scaledCoeffs`: the integer scaled coefficients νᵢⱼ = dⱼ₊₁·μᵢⱼ, with the\n  Gram determinants on the diagonal;\n- `sizeReduce` and `adjacentSwap`: the lattice row operations, with helpers\n  (`adjacentSwapDenom`, `adjacentSwapGramDetQuotient`, and friends) for their\n  exact-update formulas.\n\nThe rational construction `GramSchmidt.Rat` provides `gramDet`, and the\nproof-facing `basis` and `coeffs` (the orthogonal basis and the\nlower-unitriangular coefficient matrix) are available over both rings.\n\n# Verification\n\nThe orthogonalization theory is proven over the Mathlib-free integer and\nrational cores. The orthogonal basis, `basis_orthogonal`:\n\n```lean\ntheorem basis_orthogonal (b : Matrix Int n m)\n    (i j : Nat) (hi : i \u003c n) (hj : j \u003c n) (hij : i ≠ j) :\n    ((basis b).row ⟨i, hi⟩).dotProduct ((basis b).row ⟨j, hj⟩) = 0\n```\n\nis accompanied by the triangular decomposition `basis_decomposition`, the\ncoefficient laws `coeffs_diag` and `coeffs_upper`, the span equality\n`basis_span`, and the update laws for `sizeReduce` and `adjacentSwap`. The\nkey lattice estimate, `normSq_latticeVec_ge_min_basis_normSq`:\n\n```lean\ntheorem normSq_latticeVec_ge_min_basis_normSq\n    (b : Matrix Int n m) (_hli : independent b)\n    (v : Vector Int m) (hv : memLattice b v) (hv' : v ≠ 0) :\n    ∃ i : Fin n,\n      ((basis b).row i).normSq ≤ ((v.normSq : Int) : Rat)\n```\n\nbounds every nonzero lattice vector below by a basis norm.\n\nFacts that equate a Hex computational output with the Leibniz `det` of a\nmatrix go through Bareiss-Desnanot integrality, so they live in\n[`hex-gram-schmidt-mathlib`](https://github.com/leanprover/hex-gram-schmidt-mathlib),\nalong with the correspondence between `GramSchmidt.Int.basis` and Mathlib's\n`gramSchmidt`.\n\n# Reference manual\n\nThe hex reference manual covers this library at\n\u003chttps://kim-em.github.io/hex-dev/find/?domain=Verso.Genre.Manual.section\u0026name=hex-gram-schmidt\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-gram-schmidt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleanprover%2Fhex-gram-schmidt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleanprover%2Fhex-gram-schmidt/lists"}