{"id":51428403,"url":"https://github.com/leanprover/hex-matrix-mathlib","last_synced_at":"2026-07-05T03:00:30.342Z","repository":{"id":367491550,"uuid":"1279153600","full_name":"leanprover/hex-matrix-mathlib","owner":"leanprover","description":"Mathlib correspondence proofs for hex-matrix","archived":false,"fork":false,"pushed_at":"2026-07-03T21:57:47.000Z","size":228,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-07-03T23:27:16.175Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://kim-em.github.io/hex-dev/find/?domain=Verso.Genre.Manual.section\u0026name=hex-matrix-mathlib","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:26:10.000Z","updated_at":"2026-07-03T21:57:50.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/leanprover/hex-matrix-mathlib","commit_stats":null,"previous_names":["kim-em/hex-matrix-mathlib","leanprover/hex-matrix-mathlib"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/leanprover/hex-matrix-mathlib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leanprover%2Fhex-matrix-mathlib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leanprover%2Fhex-matrix-mathlib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leanprover%2Fhex-matrix-mathlib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leanprover%2Fhex-matrix-mathlib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leanprover","download_url":"https://codeload.github.com/leanprover/hex-matrix-mathlib/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leanprover%2Fhex-matrix-mathlib/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35141966,"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-05T02:00:06.290Z","response_time":100,"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-05T03:00:23.292Z","updated_at":"2026-07-05T03:00:30.320Z","avatar_url":"https://github.com/leanprover.png","language":"Lean","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hex-matrix-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-matrix-mathlib` is the Mathlib bridge for\n[`hex-matrix`](https://github.com/leanprover/hex-matrix). It identifies the\nexecutable dense matrices with Mathlib's function-based `Matrix`, so that\nMathlib's linear-algebra results transfer to the computable representation.\nThis library depends on Mathlib and on\n[`hex-matrix`](https://github.com/leanprover/hex-matrix).\n\n# Quickstart\n\nAdd to your `lakefile.toml`:\n\n```toml\n[[require]]\nname = \"hex-matrix-mathlib\"\ngit = \"https://github.com/leanprover/hex-matrix-mathlib.git\"\nrev = \"main\"\n```\n\n```lean\nimport HexMatrixMathlib\n\nopen Hex HexMatrixMathlib\n\n-- Every executable matrix corresponds to a Mathlib matrix with the same entries.\n#check @matrixEquiv      -- Hex.Matrix R n m ≃ Matrix (Fin n) (Fin m) R\n#check @matrixEquiv_apply -- matrixEquiv M i j = M[i][j]\n\n-- Elementary row operations become Mathlib's elementary matrices.\n#check @matrixEquiv_rowSwap -- left multiply by Matrix.swap\n#check @matrixEquiv_rowAdd  -- left multiply by Matrix.transvection\n\n-- The executable arithmetic is Mathlib's algebraic tower.\n#check @matrixRingEquiv  -- Hex.Matrix R n n ≃+* Matrix (Fin n) (Fin n) R\n```\n\n# Functionality\n\nThe proof-facing API connecting the two matrix worlds:\n\n- the equivalence `matrixEquiv : Hex.Matrix R n m ≃ Matrix (Fin n) (Fin m) R`\n  and its companion `vectorEquiv : Vector R n ≃ (Fin n → R)`;\n- the algebraic instances on `Hex.Matrix` whose operations are the executable\n  ones: `AddCommMonoid`, `AddCommGroup`, `Module`, `instSemiring`, `instRing`,\n  and `instAlgebra`, transported along `matrixEquiv`;\n- the bundled upgrades `matrixAddEquiv`, `matrixLinearEquiv`, `matrixRingEquiv`,\n  and `matrixAlgEquiv`;\n- the row-operation dictionary `matrixEquiv_rowSwap`, `matrixEquiv_rowScale`,\n  and `matrixEquiv_rowAdd`;\n- transfer lemmas for the container API: `matrixEquiv_transpose`,\n  `matrixEquiv_setRow`, `matrixEquiv_setCol`, `matrixEquiv_gramMatrix`,\n  `matrixEquiv_principalSubmatrix`, and the matrix-vector product\n  `vectorEquiv_mulVec`.\n\n# Verification\n\nThe correspondence is fully proven. The algebraic instances are transported\nacross `matrixEquiv`, so their laws are Mathlib's; the `@[simp, grind]`\ntransfer lemmas (`matrixEquiv_add`, `matrixEquiv_mul`, `matrixEquiv_one`,\n`matrixEquiv_smul`, and the rest) let `simp` and `grind` rewrite between the\ntwo representations.\n\nThe headline equivalence sends each matrix to the Mathlib matrix with the\nsame entries:\n\n```lean\ndef matrixEquiv : Hex.Matrix R n m ≃ Matrix (Fin n) (Fin m) R\n```\n\n```lean\ntheorem matrixEquiv_apply (M : Hex.Matrix R n m) (i : Fin n) (j : Fin m) :\n    matrixEquiv M i j = M[i][j]\n```\n\nThe elementary row operations correspond to Mathlib's elementary matrices.\nA swap is left multiplication by the permutation matrix `Matrix.swap`:\n\n```lean\ntheorem matrixEquiv_rowSwap (M : Hex.Matrix R n m) (i j : Fin n) :\n    matrixEquiv (Hex.Matrix.rowSwap M i j) = Matrix.swap R i j * matrixEquiv M\n```\n\nA row addition is left multiplication by `Matrix.transvection`:\n\n```lean\ntheorem matrixEquiv_rowAdd (M : Hex.Matrix R n m) (src dst : Fin n) (c : R) :\n    matrixEquiv (Hex.Matrix.rowAdd M src dst c) =\n      Matrix.transvection dst src c * matrixEquiv M\n```\n\nThe matrix-vector product transports to Mathlib's `Matrix.mulVec`:\n\n```lean\ntheorem vectorEquiv_mulVec [Semiring R] (M : Hex.Matrix R n m) (v : Vector R m) :\n    vectorEquiv (M * v) = (matrixEquiv M).mulVec (vectorEquiv v)\n```\n\nThe executable matrices and their operations live in\n[`hex-matrix`](https://github.com/leanprover/hex-matrix). The determinant, row\nreduction, and Bareiss correspondences build on this base in their own bridge\nlibraries.\n\n# Reference manual\n\nThe Mathlib correspondence section of the hex reference manual covers this library at\n\u003chttps://kim-em.github.io/hex-dev/find/?domain=Verso.Genre.Manual.section\u0026name=hex-matrix-mathlib\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-matrix-mathlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleanprover%2Fhex-matrix-mathlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleanprover%2Fhex-matrix-mathlib/lists"}