Fixed-length vector and array interoperability #
Lean's Vector α n is an Array α together with a proof that the array has
exactly n entries. This module identifies that executable one-dimensional
storage with the row-major entries of a tensor of any finite shape.
The equivalence is not restricted to rank one. A scalar tensor corresponds to a vector of length one, a matrix corresponds to a vector whose length is the product of its two dimensions, and a shape containing a zero-length axis corresponds to the empty vector.
The equivalence between a tensor and its fixed-length row-major storage.
The vector contains one entry for every coordinate in shape. Converting
back uses row-major linearization to recover the original multidimensional
coordinate semantics.
Instances For
Reshape preserves the same row-major vector storage.
Only the proof-indexed vector length changes, so Vector.cast transports the
source vector along the equality between the source and target shape sizes.