TorchLean API

NN.Tensor.Internal.Elab.Transform.Index

Certified transform index compilation #

This module compiles the flat-index function of a checked rearrangement or repeat while elaborating the surrounding expression. The generated program contains only the resulting row-major arithmetic; parser data, axis lookup, and checked-plan interpretation remain in erased correctness proofs.

Symbolic dimensions remain symbolic arithmetic in the generated expression; the returned theorem still identifies that program with the independent coordinate semantics.

Build function composition as an explicit lambda.

Generated index maps are executable programs. Lambda form exposes their stored composition without unfolding checked-plan definitions.

Instances For

    Estimate arithmetic complexity in a generated flat-index map.

    Only value-level arithmetic contributes to the estimate. Dependent bounds, types, and correctness proofs are deliberately ignored because they are erased before execution. Unrecognized expressions contribute zero; this is not a cost model for arbitrary functions. The estimate chooses between composing a shape-only chain and materializing its certified native result.

    Heuristic cost limit for fusing an inherited flat-index map.

    The weighted estimate reflects native arithmetic cost: quotient and remainder are more expensive than addition or multiplication. The threshold is independent of tensor rank and transformation kind. It is not a timing guarantee.

    Instances For

      Report whether an inherited flat-index map should remain fused.

      Instances For

        Compile a checked output-to-input flat projection.

        The executable result is specialized row-major arithmetic when the reflected plan reduces. Its proof connects that arithmetic directly to linearization of the plan's independent coordinate projection, without unfolding the checked plan's proof fields.

        Instances For