# Aaron Gotwalt

> [Blog](/blog/) / [Projects](/projects/) / [Work](/work/) | [llms.txt](/llms.txt)

---

## rules_lean4

Date: 2026-12-02

Bazel rules for Lean 4: one module per target, with Mathlib straight from its cache.

---

At [Positivesum](https://www.positivesum.ai) we write models of our software in [Lean](https://lean-lang.org) and prove them correct. The models generate golden tests - contracts that our implementations in other languages have to pass.

Lean sits in the middle of our build, beside everything else, so we wanted [Bazel](https://bazel.build) to build it. rules_lean4 is the ruleset we wrote for that. Every Lean file is its own build target, the Lean release is a hermetic toolchain, and [Mathlib](https://github.com/leanprover-community/mathlib4) arrives prebuilt from its own cache, so none of it is ever compiled.

```bash
bazel build //proofs/...                 # type-check every module
bazel test //proofs/...                  # and replay each through the kernel
bazel build //proofs/Foo/Order:Lattice   # one module and what it imports
bazel run //proofs:main                  # an executable, compiled and linked
```

It's in the Bazel Central Registry as [`positivesum_rules_lean4`](https://registry.bazel.build/modules/positivesum_rules_lean4), and the [README](https://github.com/positivesum-ai/rules_lean4#readme) covers the rest.
