A Simple and Practical Linear Algebra Library Interface with Static Size Checking
Akinori Abe, Eijiro Sumii

TL;DR
This paper introduces a practical linear algebra library interface that uses generative phantom types in ML to ensure dimension consistency at compile time, reducing runtime errors in matrix operations.
Contribution
It presents a simple, practical approach using standard ML features to statically verify matrix dimension consistency, avoiding complex dependent types.
Findings
Ported a machine learning library to the new interface with minimal manual changes.
Most porting modifications were mechanical, indicating ease of adoption.
The approach effectively prevents dimension errors at compile time.
Abstract
Linear algebra is a major field of numerical computation and is widely applied. Most linear algebra libraries (in most programming languages) do not statically guarantee consistency of the dimensions of vectors and matrices, causing runtime errors. While advanced type systems--specifically, dependent types on natural numbers--can ensure consistency among the sizes of collections such as lists and arrays, such type systems generally require non-trivial changes to existing languages and application programs, or tricky type-level programming. We have developed a linear algebra library interface that verifies the consistency (with respect to dimensions) of matrix operations by means of generative phantom types, implemented via fairly standard ML types and module system. To evaluate its usability, we ported to it a practical machine learning library from a traditional linear algebra…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsLogic, programming, and type systems · Parallel Computing and Optimization Techniques · Advanced Database Systems and Queries
