Vector tensors (Spec.Vec) #
TorchLean’s spec tensor type is shape-indexed:
Spec.Tensor α s
For many developments we need the special case “a length-n vector of scalars”, i.e.
Spec.Tensor α (.dim n .scalar).
This file packages that case up as Spec.Vec n α and provides basic, representation-agnostic
helpers:
- convert to/from functions
Fin n → α, - coordinate access, and
- total “update one coordinate” / “remove one coordinate” operations.
These utilities are used by learning-theory code (datasets as vectors of examples) and are also
generally handy for connecting tensor-shaped objects to Fin-indexed mathlib APIs.
References / analogies:
- This is the shape-indexed tensor analogue of the function type
Fin n -> α(a dependentPi), packaged so we can reuseTensorinfrastructure while still interoperating with mathlib'sFin-indexed APIs. - Lean core / mathlib building blocks used here:
Fin,Function.update, andFin.succAbove.
def
Spec.Vec.update
{n : ℕ}
{α : Type}
[DecidableEq (Fin n)]
(v : Vec n α)
(i : Fin n)
(a' : α)
:
Vec n α
Update one coordinate (total, using Fin indices).