arXiv:2611.19505cs.PLNov 2026

Manuscript Offprint

arXiv:2611.19505

Formalizing einsum\mathsf{einsum} with Named Tensor Notation

Yafei Yang, Chung-chieh Shan

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Einstein notation (einsum\mathsf{einsum}) is a widely adopted tensor operation that has proven useful in areas such as machine learning and quantum computing. But it had no formal semantics until recently, and its properties had no mechanized verification. We formalize the denotational semantics of a language of tensors (multi-dimensional arrays) that supports einsum\mathsf{einsum} and repeated tensors (expand\mathsf{expand}). With this semantics, we verify equational rewriting rules about einsum\mathsf{einsum} and expand\mathsf{expand} that improve the performance of tensor computation. Whereas typical languages use unnamed tensors, whose shape is a sequence of natural numbers, we found it advantageous for mechanization to use named tensors, whose shape is a finite map from names to natural numbers. To our knowledge, this is the first time that the semantics and rewriting rules of einsum\mathsf{einsum} are mechanized in a proof assistant. Our solution is agnostic to proof assistants; we have implemented it in Lean and partially in Agda.

A PDF page turning into lines of clean text

Preparing the full text

It will appear here by itself. You can read the abstract meanwhile.