{"id":50877342,"url":"https://github.com/pulseengine/rules_lean","last_synced_at":"2026-06-15T11:02:17.426Z","repository":{"id":344552272,"uuid":"1182031656","full_name":"pulseengine/rules_lean","owner":"pulseengine","description":"Bazel rules for Lean 4 and Mathlib","archived":false,"fork":false,"pushed_at":"2026-06-13T15:20:44.000Z","size":165,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-13T17:16:25.233Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Starlark","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pulseengine.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-03-15T00:15:30.000Z","updated_at":"2026-06-13T15:19:09.000Z","dependencies_parsed_at":"2026-03-15T19:01:46.418Z","dependency_job_id":null,"html_url":"https://github.com/pulseengine/rules_lean","commit_stats":null,"previous_names":["pulseengine/rules_lean"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pulseengine/rules_lean","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pulseengine%2Frules_lean","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pulseengine%2Frules_lean/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pulseengine%2Frules_lean/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pulseengine%2Frules_lean/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pulseengine","download_url":"https://codeload.github.com/pulseengine/rules_lean/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pulseengine%2Frules_lean/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34357285,"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-15T02:00:07.085Z","response_time":63,"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-06-15T11:02:16.761Z","updated_at":"2026-06-15T11:02:17.416Z","avatar_url":"https://github.com/pulseengine.png","language":"Starlark","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rules_lean\n\nBazel rules for building and verifying [Lean 4](https://lean-lang.org/) libraries and proofs,\nwith optional [Mathlib](https://github.com/leanprover-community/mathlib4) support.\n\n## Quick Start\n\nAdd to your `MODULE.bazel`:\n\n```starlark\nbazel_dep(name = \"rules_lean\", version = \"0.1.0\")\n\nlean = use_extension(\"@rules_lean//lean:extensions.bzl\", \"lean\")\nlean.toolchain(version = \"4.29.1\")\n\nuse_repo(lean, \"lean_toolchains\")\nregister_toolchains(\"@lean_toolchains//:all\")\n```\n\n### With Mathlib\n\n```starlark\nlean = use_extension(\"@rules_lean//lean:extensions.bzl\", \"lean\")\nlean.toolchain(version = \"4.29.1\")\nlean.mathlib(rev = \"v4.29.1\")\n\nuse_repo(lean, \"lean_toolchains\", \"mathlib\")\nregister_toolchains(\"@lean_toolchains//:all\")\n```\n\n## Usage\n\n```starlark\nload(\"@rules_lean//lean:defs.bzl\", \"lean_library\", \"lean_proof_test\")\n\n# Compile Lean sources and produce .olean files for downstream deps\nlean_library(\n    name = \"my_lib\",\n    srcs = [\n        \"MyLib/Basic.lean\",\n        \"MyLib/Defs.lean\",\n    ],\n)\n\n# Write proofs that depend on your library and/or Mathlib\nlean_library(\n    name = \"my_proofs\",\n    srcs = [\"Proofs/Correctness.lean\"],\n    deps = [\n        \":my_lib\",\n        \"@mathlib//:Mathlib\",\n    ],\n)\n\n# Verify proofs type-check (test target)\nlean_proof_test(\n    name = \"my_proofs_test\",\n    srcs = [\"Proofs/Correctness.lean\"],\n    deps = [\n        \":my_lib\",\n        \"@mathlib//:Mathlib\",\n    ],\n)\n```\n\n## Rules\n\n### `lean_library`\n\nCompiles Lean 4 `.lean` source files and produces `.olean` outputs.\n\n| Attribute     | Type          | Default | Description |\n|---------------|---------------|---------|-------------|\n| `srcs`        | label_list    | required | `.lean` source files, listed in compilation order |\n| `deps`        | label_list    | `[]`     | `lean_library` or `lean_prebuilt_library` targets |\n| `extra_flags` | string_list   | `[]`     | Additional flags passed to `lean` |\n\n### `lean_proof_test`\n\nTest rule that verifies `.lean` proofs type-check (proofs are valid).\nVerification happens at build time; the test reports success.\n\n| Attribute     | Type          | Default | Description |\n|---------------|---------------|---------|-------------|\n| `srcs`        | label_list    | required | `.lean` source files to verify |\n| `deps`        | label_list    | `[]`     | `lean_library` or `lean_prebuilt_library` targets |\n| `extra_flags` | string_list   | `[]`     | Additional flags passed to `lean` |\n\n### `lean_prebuilt_library`\n\nWraps pre-built `.olean` files (e.g. Mathlib) as a Lean dependency.\n\n| Attribute      | Type       | Default | Description |\n|----------------|------------|---------|-------------|\n| `srcs`         | label_list | required | Pre-built `.olean` and related files |\n| `path_marker`  | label      | `None`   | Marker file at the root of the `.olean` directory tree |\n\n## Toolchain Configuration\n\n### SHA-256 Verification\n\nFor reproducible builds, provide SHA-256 hashes per platform:\n\n```starlark\nlean.toolchain(\n    version = \"4.29.1\",\n    sha256 = {\n        \"darwin_aarch64\": \"abc123...\",\n        \"darwin_x86_64\": \"def456...\",\n        \"linux_x86_64\": \"789abc...\",\n        \"linux_aarch64\": \"012def...\",\n    },\n)\n```\n\nHashes can be obtained from the [Lean 4 releases page](https://github.com/leanprover/lean4/releases).\n\n## Supported Platforms\n\n| Platform            | Lean Artifact             |\n|---------------------|---------------------------|\n| macOS (Apple Silicon) | `darwin_aarch64`         |\n| macOS (Intel)        | `darwin_x86_64`          |\n| Linux (x86_64)      | `linux_x86_64`            |\n| Linux (aarch64)     | `linux_aarch64`           |\n\n## Aeneas Integration\n\n[Aeneas](https://github.com/AeneasVerif/aeneas) translates Rust programs (via\n[Charon](https://github.com/AeneasVerif/charon) LLBC intermediate representation)\ninto Lean 4 for formal verification.\n\n### Setup\n\n```starlark\naeneas = use_extension(\"@rules_lean//aeneas:extensions.bzl\", \"aeneas\")\naeneas.toolchain(\n    version = \"build-2026.03.14.003732-912707da86162a566cd8b01f137383ec411b31de\",\n    rev = \"912707da86162a566cd8b01f137383ec411b31de\",\n    lean_version = \"4.29.1\",\n)\n\nuse_repo(aeneas, \"aeneas_toolchains\", \"aeneas_lean_lib\")\nregister_toolchains(\"@aeneas_toolchains//:all\")\n```\n\n### Usage\n\n```starlark\nload(\"@rules_lean//aeneas:defs.bzl\", \"aeneas_translate\")\nload(\"@rules_lean//lean:defs.bzl\", \"lean_library\", \"lean_proof_test\")\n\n# Step 1: Translate LLBC (produced by Charon) to Lean\naeneas_translate(\n    name = \"my_crate_translated\",\n    srcs = [\"my_crate.llbc\"],\n)\n\n# Step 2: Compile the generated Lean code\nlean_library(\n    name = \"my_crate_compiled\",\n    srcs = [\":my_crate_translated\"],\n    deps = [\"@aeneas_lean_lib//:Aeneas\"],\n)\n\n# Step 3: Write and verify proofs\nlean_proof_test(\n    name = \"my_proofs_test\",\n    srcs = [\"MyProofs.lean\"],\n    deps = [\":my_crate_compiled\"],\n)\n```\n\n### `aeneas_translate`\n\nTranslates LLBC files to Lean 4 using Aeneas.\n\n| Attribute     | Type          | Default | Description |\n|---------------|---------------|---------|-------------|\n| `srcs`        | label_list    | required | `.llbc` files produced by Charon |\n| `extra_flags` | string_list   | `[]`     | Additional aeneas flags (e.g. `[\"-split-files\"]`) |\n\n## How It Works\n\n1. **Toolchain download**: `lean_release` downloads pre-built Lean 4 binaries from\n   GitHub releases for each supported platform.\n2. **Toolchain resolution**: Bazel's toolchain system selects the correct platform\n   binary at build time.\n3. **Compilation**: `lean_library` compiles `.lean` files to `.olean` using the\n   downloaded `lean` binary, with `LEAN_PATH` set to resolve imports from the\n   standard library, Mathlib, and other dependencies.\n4. **Mathlib**: `mathlib_repo` uses `lake` to fetch Mathlib and download pre-built\n   oleans, consolidating them into a single directory for import resolution.\n5. **Aeneas**: Downloads pre-built Aeneas binaries, builds the Lean support library,\n   and translates Rust LLBC to Lean 4 for verification.\n\n## License\n\nApache-2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpulseengine%2Frules_lean","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpulseengine%2Frules_lean","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpulseengine%2Frules_lean/lists"}