TorchLean API

NN.Proofs.Tensor.Basic.BoundsNorms

Bounds and norm facts for dependent tensors.

The proofs use coordinate extensionality and finite sums. They therefore describe the mathematical tensor independently of its packed physical storage.

Sum distributes over elementwise addition.

theorem Spec.dot_comm {s : Shape} (a b : TorchLean.Tensor s) :
dot a b = dot b a

The dot product is symmetric.

theorem Spec.dot_add_left {s : Shape} (a b c : TorchLean.Tensor s) :
dot (a.addSpec b) c = dot a c + dot b c

Dot-product distributes over addition in the left argument.

theorem Spec.dot_scale_left {s : Shape} (a b : TorchLean.Tensor s) (k : ) :
dot (a.scaleSpec k) b = k * dot a b

Scaling a tensor scales its dot-product.

Shape preservation #

Elementwise addition does not change the statically tracked shape size.

Elementwise multiplication does not change the statically tracked shape size.

Uniform finite bounds #

theorem Spec.safediv_bound {s : Shape} (a b : TorchLean.Tensor s) (_i : Fin s.size) :
Context.defaultEpsilon > 0∃ (bound : ), (a.safedivSpec b).absSpec = TorchLean.Tensor.mapSpec (fun (value : ) => min value bound) (a.safedivSpec b).absSpec

A finite tensor admits a uniform bound, expressed by an idempotent minimum clamp.

Squared norm #

noncomputable def Spec.tensorNormSquared {s : Shape} (tensor : TorchLean.Tensor s) :

The squared Euclidean norm of all coordinates of a tensor.

Instances For

    A tensor squared norm is nonnegative.

    A tensor has zero squared norm exactly when every coordinate is zero.