Skip to the content.

TorchLean brings tensor computation, machine learning, and formal verification together in Lean 4. The cool part is that Lean is both a functional programming language and a theorem prover, so you can write computations, build and train models, and prove mathematical properties in the same language. You can start with tensors and linear algebra, use the library for general numerical programming, or work directly with the specifications and proofs.

TorchLean overview: typed tensors, shared graph IR, autograd proofs, IEEE-754 semantics, certificate checking, PyTorch interoperability, CUDA providers, and model analysis.
From a typed model to execution, analysis, and proof.

A few highlights we’re excited about:

The guide walks through the library step by step. If you’d rather start by running something, try the examples.