Inferring Physical Units in B Models

  • Sebastian Krings
  • Michael Leuschel
Part of the Lecture Notes in Computer Science book series (LNCS, volume 8137)


Most state-based formal methods, like B, Event-B or Z, provide support for static typing. However, these methods and the associated tools lack support for annotating variables with (physical) units of measurement. There is thus no obvious way to reason about correct or incorrect usage of such units. In this paper we present a technique that analyses the usage of physical units throughout a B machine, infers missing units and notifies the user of incorrectly handled units. The technique combines abstract interpretation with classical animation and model checking and has been integrated into the ProB validation tool, both for classical B and for Event-B. It provides source-level feedback about errors detected in the models. The plugin uses a combination of abstract interpretation and constraint solving techniques. We provide an empirical evaluation of our technique, and demonstrate that it scales up to real-life industrial models.


B-Method Event-B Physical Units Model Checking Abstract Interpretation 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Abrial, J.-R.: The B-Book: Assigning Programs to Meanings. Cambridge University Press (1996)Google Scholar
  2. 2.
    Abrial, J.-R.: Modeling in Event-B: System and Software Engineering. Cambridge University Press (2010)Google Scholar
  3. 3.
    Abrial, J.-R., Butler, M., Hallerstede, S., Voisin, L.: An open extensible tool environment for Event-B. In: Liu, Z., Kleinberg, R.D. (eds.) ICFEM 2006. LNCS, vol. 4260, pp. 588–605. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  4. 4.
    Abrial, J.-R., Su, W., Zhu, H.: Formalizing hybrid systems with Event-B. In: Derrick, J., Fitzgerald, J., Gnesi, S., Khurshid, S., Leuschel, M., Reeves, S., Riccobene, E. (eds.) ABZ 2012. LNCS, vol. 7316, pp. 178–193. Springer, Heidelberg (2012)CrossRefGoogle Scholar
  5. 5.
    Anand, M., Lee, I., Pappas, G., Sokolsky, O.: Unit & dynamic typing in hybrid systems modeling with CHARON. In: Computer Aided Control System Design, pp. 56–61. IEEE (2006)Google Scholar
  6. 6.
    Back, R.-J., Seceleanu, C.C., Westerholm, J.: Symbolic simulation of hybrid systems. In: Proceedings APSEC 2002, pp. 147–155. IEEE Computer Society (2002)Google Scholar
  7. 7.
    Barrett, C., Stump, A., Tinelli, C.: The SMT-LIB Standard: Version 2.0. Technical report, Department of Computer Science, University of Iowa (2010),
  8. 8.
    Cousot, P., Cousot, R.: Abstract interpretation: A unified lattice model for static analysis of programs by construction or approximation of fixpoints. In: Proceedings POPL 1977, pp. 238–252. ACM (1977)Google Scholar
  9. 9.
    Cunis, R.: A package for handling units of measure in Lisp. ACM SIGPLAN Lisp Pointers 5, 21–25 (1992)CrossRefGoogle Scholar
  10. 10.
    Hayes, I.J., Mahony, B.P.: Using units of measurement in formal specifications. Formal Aspects of Computing 7 (1994)Google Scholar
  11. 11.
    Jiang, L., Su, Z.: Osprey: a practical type system for validating dimensional unit correctness of C programs. In: Proceedings ICSE 2006, pp. 262–271. ACM (2006)Google Scholar
  12. 12.
    Kennedy, A.: Types for units-of-measure: Theory and practice. In: Horváth, Z., Plasmeijer, R., Zsók, V. (eds.) CEFP 2009. LNCS, vol. 6299, pp. 268–305. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  13. 13.
    Lamport, L., Paulson, L.C.: Should your specification language be typed. ACM Trans. Program. Lang. Syst. 21(3), 502–526 (1999)CrossRefGoogle Scholar
  14. 14.
    Leuschel, M., Butler, M.: ProB: A model checker for B. In: Araki, K., Gnesi, S., Mandrioli, D. (eds.) FME 2003. LNCS, vol. 2805, pp. 855–874. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  15. 15.
    Leuschel, M., Butler, M.: ProB: an automated analysis toolset for the B method. Int. J. Softw. Tools Technol. Transf. 10(2), 185–203 (2008)CrossRefGoogle Scholar
  16. 16.
    Modelica Association. The Modelica Language Specification version 3.0 (2007)Google Scholar
  17. 17.
    Owre, S., Saha, I., Shankar, N.: Automatic dimensional analysis of cyber-physical systems. In: Giannakopoulou, D., Méry, D. (eds.) FM 2012. LNCS, vol. 7436, pp. 356–371. Springer, Heidelberg (2012)CrossRefGoogle Scholar
  18. 18.
    Platzer, A.: Logical Analysis of Hybrid Systems: Proving Theorems for Complex Dynamics. Springer (2010)Google Scholar
  19. 19.
    Roy, P., Shankar, N.: SimCheck: An expressive type system for Simulink. In: Proceedings NFM 2010, pp. 149–160. NASA (2010)Google Scholar
  20. 20.
    Thompson, A., Taylor, B.N.: The International System of Units (SI). Nist Special Publication (2008)Google Scholar
  21. 21.
    Umrigar, Z.: Fully static dimensional analysis with C++. ACM SIGPLAN Notices 29, 135–139 (1994)CrossRefGoogle Scholar
  22. 22.
    van Delft, A.: A Java extension with support for dimensions. Software: Practice and Experience 29(7), 605–616 (1999)CrossRefGoogle Scholar
  23. 23.
    Wand, M., O’Keefe, P.: Automatic dimensional inference. In: Computational Logic: Essays in Honor of Alan Robinson, pp. 479–483 (1991)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2013

Authors and Affiliations

  • Sebastian Krings
    • 1
  • Michael Leuschel
    • 1
  1. 1.Institut für InformatikUniversität DüsseldorfDüsseldorfGermany

Personalised recommendations