Conference Proceeding Article
Misuse of measurement units is a common source of errors in scientific applications, but standard type systems do not prevent such errors. Dimensional analysis in physics can be used to manually detect such errors in physical equations. It is, however, not feasible to perform such manual analysis for programs computing physical equations because of code complexity. In this paper, we present a type system to automatically detect potential errors involving measurement units. It is constraint-based: we model units as types and flow of units as constraints. However, standard type checking algorithms are not powerful enough to handle units because of their abelian group nature (e.g., being commutative, multiplicative, and associative). Our system combines techniques such as type inference and Gaussian Elimination to overcome this problem. We have implemented Osprey, a prototype of the system for C programs, and evaluated it on various test programs, including computational physics and mechanical engineering applications. Osprey discovered unknown errors in mature code; it is precise with few false positives; it is also efficient and scales to large programs---we have successfully used it to analyze programs with hundreds of thousands of lines of code.
Gaussian elimination, measurement units, dimensional analysis, constraint-based analysis, type systems
Software and Cyber-Physical Systems
ICSE '06: Proceedings of the 28th International Conference on Software Engineering: 20-28 May 2006, Shanghai, China
City or Country
JIANG, Lingxiao and SU, Zhendong.
Osprey: A practical type system for validating dimensional unit correctness of C programs. (2006). ICSE '06: Proceedings of the 28th International Conference on Software Engineering: 20-28 May 2006, Shanghai, China. 262-271. Research Collection School Of Information Systems.
Available at: http://ink.library.smu.edu.sg/sis_research/1331
Copyright Owner and License
Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 4.0 License.