{"id":50614528,"url":"https://github.com/lean-dojo/torchlean","last_synced_at":"2026-06-06T07:02:23.998Z","repository":{"id":359011091,"uuid":"1235168970","full_name":"lean-dojo/TorchLean","owner":"lean-dojo","description":" TorchLean is the first unified Lean 4 framework for neural-network specification, execution, and verification. ","archived":false,"fork":false,"pushed_at":"2026-05-29T23:08:17.000Z","size":31787,"stargazers_count":63,"open_issues_count":0,"forks_count":7,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-30T01:09:08.729Z","etag":null,"topics":["ai4math","ai4science","lean4","neural-network","pytorch","scientific-computing","theorem-proving","verification"],"latest_commit_sha":null,"homepage":"https://lean-dojo.github.io/TorchLean/","language":"Lean","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lean-dojo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","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":null,"dco":null,"cla":null}},"created_at":"2026-05-11T04:32:07.000Z","updated_at":"2026-05-29T23:08:21.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/lean-dojo/TorchLean","commit_stats":null,"previous_names":["lean-dojo/torchlean"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/lean-dojo/TorchLean","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lean-dojo%2FTorchLean","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lean-dojo%2FTorchLean/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lean-dojo%2FTorchLean/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lean-dojo%2FTorchLean/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lean-dojo","download_url":"https://codeload.github.com/lean-dojo/TorchLean/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lean-dojo%2FTorchLean/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33972398,"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-06-06T02:00:07.033Z","response_time":107,"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":["ai4math","ai4science","lean4","neural-network","pytorch","scientific-computing","theorem-proving","verification"],"created_at":"2026-06-06T07:02:23.410Z","updated_at":"2026-06-06T07:02:23.989Z","avatar_url":"https://github.com/lean-dojo.png","language":"Lean","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  \u003cimg src=\"home_page/assets/media/brand/torchlean-logo.png\" alt=\"TorchLean logo\" width=\"88\" align=\"center\"\u003e\n  Formalizing Neural Networks in Lean\n\u003c/h1\u003e\n\nTorchLean is a Lean 4 framework for writing, running, inspecting, and verifying\nneural-network programs. It provides typed tensors and model APIs, a shared graph\nIR, runtime/autograd support, finite-precision semantics, certificate checkers,\nCUDA/runtime boundaries, and examples across modern ML and scientific ML.\n\n## Quickstart\n\n```bash\ngit clone https://github.com/lean-dojo/TorchLean.git\ncd TorchLean\nlake build\npython3 scripts/datasets/download_example_data.py --auto-mpg\nlake exe torchlean mlp --cpu --steps 10\nlake exe torchlean mlp --steps 10 --dtype float --backend eager\n\n# Optional CUDA run, if the CUDA toolkit and an NVIDIA GPU are available:\nlake build -K cuda=true\nlake exe -K cuda=true torchlean mlp --cuda --fast-kernels --steps 1000\n```\n\nThe first MLP command uses the executable IEEE-style Float32 path. The second\nuses Lean's builtin `Float` runtime path. The CUDA command uses the native GPU\nruntime path and checks that the CUDA backend is available; it is not a trusted\nproof boundary.\n\nTorchLean is pinned by `lean-toolchain` and currently builds with\n`leanprover/lean4:v4.30.0`.\n\n## First Things To Try\n\n```bash\nlake exe torchlean --help\nlake exe verify --help\nlake exe verify -- torchlean-ibp\n```\n\nFor the maintained example surface:\n\n```bash\nlake build NN.Examples.Zoo\n```\n\n## Documentation\n\n- Project site: \u003chttps://lean-dojo.github.io/TorchLean/\u003e\n- Guide: \u003chttps://lean-dojo.github.io/TorchLean/blueprint/\u003e\n- API reference: \u003chttps://lean-dojo.github.io/TorchLean/docs/\u003e\n- Updates and recent validation notes: \u003chttps://lean-dojo.github.io/TorchLean/updates/\u003e\n- Paper: [*TorchLean: Formalizing Neural Networks in Lean*](https://arxiv.org/abs/2602.22631)\n  (arXiv:2602.22631)\n\nDetailed tutorials, verification chapters, model walkthroughs, CUDA notes, and\nAPI-level reference material belong in the guide and generated docs rather than\nin this README.\n\n## Use TorchLean From Another Lean Project\n\nTorchLean is a normal Lake package. You can depend on the Git repository directly:\n\n```lean\nrequire TorchLean from git \"https://github.com/lean-dojo/TorchLean.git\" @ \"main\"\n```\n\nThen run:\n\n```bash\nlake update\nlake exe cache get\nlake build\n```\n\nMost downstream model and training files should start from the public facade:\n\n```lean\nimport NN.API.Public\n```\n\nUse the broader umbrella when you want the maintained specification, IR, proof,\nverification, examples, and widget surface:\n\n```lean\nimport NN.Library\n```\n\nFor local development against a checkout, use a path dependency instead:\n\n```lean\nrequire TorchLean from \"../TorchLean\"\n```\n\n## Repository Map\n\n- `NN/API`: public facade for model, tensor, data, and training workflows.\n- `NN/Spec`: mathematical tensor, layer, model, and dynamical-system definitions.\n- `NN/Runtime`: executable autograd, optimizers, training loops, CUDA boundary,\n  PyTorch import/export, and RL runtime support.\n- `NN/IR` and `NN/GraphSpec`: graph IR, graph semantics, and typed architecture\n  descriptions.\n- `NN/Proofs`: tensor algebra, autograd correctness, analytic derivatives,\n  runtime approximation, and bridge proofs.\n- `NN/Floats`: finite-precision models, IEEE-style executable semantics,\n  NeuralFloat formats, and error-bound infrastructure.\n- `NN/MLTheory`: learning theory, robustness, CROWN/LiRPA, generative objectives,\n  optimization theory, and related proof layers.\n- `NN/Verification`: certificate checkers and CLI workflows.\n- `NN/Examples`: quickstarts, model zoo commands, widgets, bundled verification assets,\n  and interoperability workflows.\n- `blueprint/TorchLeanBlueprint/Guide`: source for the public guide.\n- `home_page`: project website sources.\n\n## Correctness and Boundaries\n\nFor correctness claims, trust assumptions, and third-party tooling:\n\n- `TRUST_BOUNDARIES.md`\n- `AI_USAGE.md`\n- `THIRD_PARTY_NOTICES.md`\n- `CONTRIBUTING.md`\n\nLean proofs, executable checkers, Lake builds, tests, and explicit\ntrust-boundary documentation are the source of truth for what is proved,\nchecked, or assumed.\n\n## Citation\n\nFor the current paper BibTeX, use the citation metadata on arXiv:\n\n```bibtex\n@misc{george2026torchleanformalizingneuralnetworks,\n      title={TorchLean: Formalizing Neural Networks in Lean},\n      author={Robert Joseph George and Jennifer Cruden and Will Adkisson and Xiangru Zhong and Huan Zhang and Anima Anandkumar},\n      year={2026},\n      eprint={2602.22631},\n      archivePrefix={arXiv},\n      primaryClass={cs.MS},\n      url={https://arxiv.org/abs/2602.22631},\n}\n```\n\n## License\n\nTorchLean is released under the MIT License. See `LICENSE`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flean-dojo%2Ftorchlean","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flean-dojo%2Ftorchlean","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flean-dojo%2Ftorchlean/lists"}