Compact row-major rearrangement indices #
Natural-number encodings of checked coordinate maps and the transport lemmas needed to connect them to shape-indexed tensor semantics.
Decode a row-major linear index into one natural-number coordinate per axis.
The coordinates are intentionally unbounded. Bounds come from the checked
plan when this function is connected to Coord.unlinearize; keeping them out
of the computation makes reducible rearrangement certificates small.
Instances For
Compute the input linear index selected by a rearrangement of elementary axes.
This function is generic in the type used to identify axes. It is the compact
certificate language used by einops: checked plans whose dimensions reduce
become ordinary list, division, remainder, and multiplication calculations.
Instances For
Encoding an axis tuple gives the linear index of its coordinate representation.
Row-major decoding recovers every component of the corresponding axis tuple.
Linearizing a selected tuple is exactly the executable rearrangement index.
Swapping two row-major axes exchanges their coordinate contributions to the linear index.
Reshaping an unlinearized index is unlinearization after finite-index transport.
Transporting a coordinate across equal shapes preserves its linear-index value.
Coordinate transport commutes with row-major linearization.
Equiv.cast across equal shapes preserves the linear-index value.
Row-major linearization commutes with shape transport through Equiv.cast.
Ordinary dependent transport and Equiv.cast are the same operation.
Linearizing a composed coordinate map is unchanged when function composition is exposed as nested application.
This small bridge lets proof-producing simplifiers normalize a stored composition without reconstructing its dependent intermediate shape.