A Machine-Checked Theory of Dynamic Time Warping in Lean 4
Abstract
Dynamic time warping (DTW) is a standard dissimilarity measure for time series. In practice, large-scale DTW search depends on two ingredients whose correctness is usually argued on paper: global path constraints such as the Sakoe-Chiba band, and cheap lower bounds such as LBKim and LBKeogh that prune candidates without false dismissals. We present a formalization of DTW in Lean 4 with mathlib, covering: warping paths and DTW as a minimum over them; correctness of the dynamic-programming recurrence; nonnegativity, symmetry and DTW(x,x)=0, with a machine-checked witness of the known failure of the triangle inequality; constrained and Sakoe-Chiba banded DTW; the LBKim, LBKimFL, LBYi and LBKeogh lower bounds, the last restated for an arbitrary global constraint; and an executable row-by-row implementation proved equal to the specification. The recurrence is proved once, for cell costs in an arbitrary linearly ordered additive commutative monoid. Instantiating it at the reals extended with a top element yields constrained DTW with no separate optimality proof. The development has no sorry, and every main theorem uses only Lean's standard axioms. To our knowledge it is the first formalization of DTW itself in a proof assistant. The mathematics is classical; the contribution is a checked, reusable development and the precision it forces.
Create a lesson
Metadata
- Categories
- eess.SP, cs.LO
- Comments
- 9 pages. Lean 4 + mathlib formalization; source code at https://github.com/harimaruthachalam/dtw-lean
Related papers
Extreme Value Theory for Peak Power in Discrete-Time Complex Gaussian Processes
Shared title terminologyeess.SPAdam Wunderlich
Simulation to Experiment Generalization in Reconstruction-Free Electrical Impedance Tomography: Machine Learning Predictions of Object Properties from Voltage Measurements
Shared title terminologyeess.SPYasna Hajikarimian, Zahra Karimi, Natalie Verdugo et al.
Globally Certifiable Fixed-Dynamics Inverse-Map Estimation For Post-Nonlinear VAR Models
Shared title terminologyeess.SPLuis M. Lopez-Ramos, Antonio G. Marques, Baltasar Beferull-Lozano
End-to-End SIP-OFDM Neural Transceiver with Dual-Axis Time-Frequency Token Mixing for High-Mobility MIMO Systems
Shared title terminologyeess.SPZhaoxu Wang, Zhen Gao, Ziwei Wan et al.
UVIndoorLoc-RTT&RSSI: A New Multi-Scenario Dataset for Wi-Fi Fine Time Measurements Indoor Localization Problems
Shared title terminologyeess.SPMiguel Matey-Sanz, Sara Martín-Frechina, Juan Carlos Santamaría-Pedrón et al.
Prototype and Real-Time Over-The-Air Evaluation of Millimeter Wave Integrated Sensing and Communication Transceiver at Edge
Shared title terminologyeess.SPJai Mangal, Antriksh Choudhary, Ahilan R et al.