Quickstart: Proving Small TorchLean Facts #
Many TorchLean guarantees are ordinary Lean theorems. These examples cover:
- compile-time guarantees from shape-indexed tensor types, and
- ordinary mathematical lemmas about the public API, and
- derivative formulas checked against mathlib with
autograd, and - convergence of a quadratic's gradient-descent iteration with
converges.
The deeper proof libraries live under NN.Proofs.*, NN.Verification.*, and NN.MLTheory.*.
A tensor's shape is part of its type.
If this definition compiles, Lean has already checked that the literal has exactly two entries and
therefore has type Tensor Float [2]. The commented shape mismatch below is the kind of bug Lean
catches before runtime:
-- def badTensor : Tensor Float [3] := [1.0, 2.0]
Instances For
ReLU fixes every nonnegative real number.
ReLU clamps nonpositive real inputs to zero.
A new function can reuse the same rules. Registration lets later proofs use its derivative
without unfolding it. local keeps this tutorial's rule out of other modules' search sets.
A smooth penalty combining a quadratic term with an exponential.
Instances For
Prove the new function's rule before registering it for composition.
For the loss x² / 2, the gradient is x. Proving that derivative is one task;
proving that repeated gradient steps reach zero is another. Here the step size must lie in (0, 2).
These are exact-real statements, not claims about rounded runtime iterates.