Affiliation:
1. Massachusetts Institute of Technology, USA
2. Peking University, China
Abstract
We present TiML (Timed ML), an ML-like functional language with time-complexity annotations in types. It uses indexed types to express sizes of data structures and upper bounds on running time of functions; and refinement kinds to constrain these indices, expressing data-structure invariants and pre/post-conditions. Indexed types are flexible enough that TiML avoids a built-in notion of ≴size,≵ and the programmer can choose to index user-defined datatypes in any way that helps her analysis. TiML's distinguishing characteristic is supporting highly automated time-bound verification applicable to data structures with nontrivial invariants. The programmer provides type annotations, and the typechecker generates verification conditions that are discharged by an SMT solver. Type and index inference are supported to lower annotation burden, and, furthermore, big-O complexity can be inferred from recurrences generated during typechecking by a recurrence solver based on heuristic pattern matching (e.g. using the Master Theorem to handle divide-and-conquer-like recurrences). We have evaluated TiML's usability by implementing a broad suite of case-study modules, demonstrating that TiML, though lacking full automation and theoretical completeness, is versatile enough to verify worst-case and/or amortized complexities for algorithms and data structures like classic list operations, merge sort, Dijkstra's shortest-path algorithm, red-black trees, Braun trees, functional queues, and dynamic tables with bounds like
m
n
log
n
. The learning curve and annotation burden are reasonable, as we argue with empirical results on our case studies. We formalized TiML's type-soundness proof in Coq.
Funder
National Science Foundation
Defense Advanced Research Projects Agency
Publisher
Association for Computing Machinery (ACM)
Subject
Safety, Risk, Reliability and Quality,Software
Cited by
36 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献
1. Focusing on Refinement Typing;ACM Transactions on Programming Languages and Systems;2023-12-20
2. Inferring Complexity Bounds from Recurrence Relations;Proceedings of the 31st ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering;2023-11-30
3. Automatic Amortized Resource Analysis with Regular Recursive Types;2023 38th Annual ACM/IEEE Symposium on Logic in Computer Science (LICS);2023-06-26
4. Fine-Tuning Data Structures for Query Processing;Proceedings of the 21st ACM/IEEE International Symposium on Code Generation and Optimization;2023-02-17
5. For a Few Dollars More: Verified Fine-Grained Algorithm Analysis Down to LLVM;ACM Transactions on Programming Languages and Systems;2022-07-15