A Calculus for Units of Measure with Conversion

📅 2026-09-28
📈 Citations: 0
✨ Influential: 0
📄 PDF
🤖 AI Summary
This study addresses the lack of conversion support in existing typed unit calculi and the absence of scale-invariance guarantees in practical languages by proposing the ΛS calculus. This method is the first to integrate unit conversion into a rigorous type system, supporting quantification and vector linear mappings while precisely delineating the boundaries of scale invariance. It formally proves global invariance for expressions without constant terms and local invariance for those involving conversions. The entire framework is formally verified in Lean 4, yielding verified decision procedures and checkers alongside native binary compilation for evaluation. Furthermore, this work establishes a consistency-checking method for unit declarations, extracts precise conversion factors, and proves both an erasure theorem and the Buckingham π theorem for dimensional analysis with n variables.
📝 Abstract
Programs that compute with physical quantities often need to convert between units of measurement, and as the Mars Climate Orbiter showed, these conversions can be a rich source of errors. Meanwhile, typed unit calculi, our most rigorous formalisms for checking physical units in a program, have excluded unit conversions. Through this exclusion, they have established a powerful property: well-typed programs are invariant under rescaling (no program can depend on how big a meter is). But losing the ability to convert between units is a significant cost. In contrast, practical languages provide conversion but no invariance theorem. We present $Λ_S$, a typed lambda calculus with conversion, quantification over units and dimensions, and vectors and linear maps with per-component units, and we determine exactly how much invariance survives conversion. For terms without unit constants we prove two abstraction theorems: (i) a convert-free term is invariant under every rescaling; (ii) a term with conversions is invariant under every rescaling that scales all units of one dimension by the same factor. The condition in (ii) cannot be weakened: under any other rescaling, some conversion of a nonzero value is not invariant. For first-order programs, a verified decision procedure returns one of three verdicts: it certifies that no error in the declared conversion factors can change the program's answer, names the accumulated ratio through which such an error would scale it, or declines. A verified checker decides whether unit declarations are consistent and determine every conversion factor, and extracts each factor exactly. We also prove adequacy, erasure, and the $n$-variable Pi theorem of dimensional analysis with conversion. Every theorem is mechanized in Lean 4, and the evaluator compiles to a native binary.
Problem

Research questions and friction points this paper is trying to address.

units of measure
unit conversion
type systems
scaling invariance
dimensional analysis
Innovation

Methods, ideas, or system contributions that make the work stand out.

typed lambda calculus
units of measure
unit conversion
rescaling invariance
mechanized verification