English

Machine-Checked Arithmetic Bit Complexity of the Kannan-Bachem Smith Normal Form in Lean 4

Logic in Computer Science 2026-07-24 v1 Data Structures and Algorithms Symbolic Computation

Abstract

We formalize in Lean 4 the Kannan-Bachem Smith normal form algorithm for nonsingular square integer matrices. The program returns S,U,U1,V,V1S,U,U^{-1},V,V^{-1} and proves UAV=SUAV=S, U1SV1=AU^{-1}SV^{-1}=A, four inverse identities, the Smith divisibility conditions, and equality of SS with a canonical reference matrix. Stabilization terminates because each recursive pass strictly decreases the binary size of the active pivot; the outer algorithm recurses on the lower-right block. The computation also emits a flat trace of designated sign-magnitude arithmetic leaves. Branch conditions, quotients, Bezout data, and matrix entries are taken from the recorded primitive runs. Composite phases form their traces by concatenating the charge lists returned by the executed children. Verified self-delimiting codecs define the input and output sizes. Coefficient and work recurrences, closed by a kernel-checked polynomial-envelope calculus, give fixed polynomial bounds for both trace cost and the encoded length of the five output matrices. The theorem concerns these arithmetic primitives; structural operations and compiled Lean runtime are outside the model.

Cite

@article{arxiv.2607.22524,
  title  = {Machine-Checked Arithmetic Bit Complexity of the Kannan-Bachem Smith Normal Form in Lean 4},
  author = {Junye Ji},
  journal= {arXiv preprint arXiv:2607.22524},
  year   = {2026}
}

Comments

23 pages. Accompanying Lean 4 formalization: https://github.com/JJYYY-JJY/lean-normal-forms