TorchLean API

NN.Examples.Quickstart.Proofs

Quickstart: Proving Small TorchLean Facts #

TorchLean examples are not only executable scripts. Many guarantees are ordinary Lean theorems: shape round-trips, typed tensor construction, activation identities, and later full verification statements.

The boundary where TorchLean becomes more than an executable ML library is:

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 really is a Vec 2. The commented shape-mismatch below is the kind of bug Lean catches before runtime:

-- def badVector : Tensor Float (shape![3]) := tensor! [1.0, 2.0]
Instances For

    Runtime dimension lists can still be related back to static TorchLean shapes.

    This is the compact theorem behind many JSON/CLI/data-loader paths: parse dimensions dynamically, then recover the precise Shape used by the typed tensor API.

    ReLU fixes every nonnegative real number.

    ReLU clamps nonpositive real inputs to zero.