Published October 21, 2026 | Version v1

A mechanized calculus for index notation with automatic contraction

Authors/Creators

Description

Tensor expressions in index notation, where a repeated index name denotes a summation, are ubiquitous in physics software, but the elaboration of such expressions into explicit sums is rarely verified. We present a small calculus for index notation over a finite index range, with named, variance-tagged indices, and prove in Lean 4 that every well-typed expression transforms covariantly under a change of basis. On top of this core we define a surface language in which a product contracts its repeated names automatically, a translation into the core that introduces explicit contractions and fresh renamings, and an algorithm that infers the set of contracted names from the free indices of the factors. We prove that the translation preserves typing and denotation, that the algorithm is sound and complete with respect to the typing discipline (the contracted set is unique), and that covariance holds for surface expressions. The development is about 1450 lines, uses only the Lean core library, and is intended as the formal core of the tensor fragment of the language PyAct-tensor; the implementation of that language is not itself verified.

Files

epiarticle.pdf

Files (2.2 MB)

Name Size
md5:99c32aca7b9196c9e04c2cfabed9b405
2.2 MB Preview Download
md5:cf4c803fd7fdb858661fdfcb682c36ee
23.5 kB Preview Download

Additional details

Software

Repository URL
https://zenodo.org/records/23533336
Programming language
Lean
Development Status
Active