Analysis of Modular Arithmetic

  • Markus Müller-Olm
  • Helmut Seidl
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3444)


We consider integer arithmetic modulo a power of 2 as provided by mainstream programming languages like Java or standard implementations of C. The difficulty here is that the ring ℤ m of integers modulo m = 2 w , w > 1, has zero divisors and thus cannot be embedded into a field. Not withstanding that, we present intra- and inter-procedural algorithms for inferring for every program point u, affine relations between program variables valid at u. Our algorithms are not only sound but also complete in that they detect all valid affine relations. Moreover, they run in time linear in the program size and polynomial in the number of program variables and can be implemented by using the same modular integer arithmetic as the target language to be analyzed.


  1. 1.
    Cousot, P., Halbwachs, N.: Automatic Discovery of Linear Restraints among Variables of a Program. In: 5th ACM Symp. on Principles of Programming Languages (POPL), pp. 84–97 (1978)Google Scholar
  2. 2.
    Gosling, J., Joy, B., Steele, G.: The Java Language Specification. Addison-Wesley, Reading (1996)zbMATHGoogle Scholar
  3. 3.
    Granger, P.: Static Analysis of Linear Congruence Equalities among Variables of a Program. In: Abramsky, S. (ed.) CAAP 1991 and TAPSOFT 1991. LNCS, vol. 493, pp. 169–192. Springer, Heidelberg (1991)Google Scholar
  4. 4.
    Gulwani, S., Necula, G.: Discovering Affine Equalities Using Random Interpretation. In: 30th ACM Symp. on Principles of Programming Languages (POPL), pp. 74–84 (2003)Google Scholar
  5. 5.
    Hafner, J., McCurley, K.: Asymptotically Fast Triangularization of Matrices over Rings. SIAM J. of Computing 20(6), 1068–1083 (1991)zbMATHCrossRefMathSciNetGoogle Scholar
  6. 6.
    Karr, M.: Affine Relationships Among Variables of a Program. Acta Informatica 6, 133–151 (1976)zbMATHCrossRefMathSciNetGoogle Scholar
  7. 7.
    Leroux, J.: Algorithmique de la Vérification des Systèmes à Compteurs: Approximation et Accélération. PhD thesis, Ecole Normale Supérieure de Cachan (2003)Google Scholar
  8. 8.
    Müller-Olm, M., Seidl, H.: A Note on Karr’s Algorithm. In: Díaz, J., Karhumäki, J., Lepistö, A., Sannella, D. (eds.) ICALP 2004. LNCS, vol. 3142, pp. 1016–1028. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  9. 9.
    Müller-Olm, M., Seidl, H.: Computing Polynomial Program Invariants. Information Processing Letters (IPL) 91(5), 233–244 (2004)zbMATHCrossRefGoogle Scholar
  10. 10.
    Müller-Olm, M., Seidl, H.: Interprocedural Analysis of Modular Arithmetic. Technical Report 789, Fachbereich Informatik, Universität Dortmund (2004)Google Scholar
  11. 11.
    Müller-Olm, M., Seidl, H.: Precise Interprocedural Analysis through Linear Algebra. In: 31st ACM Symp. on Principles of Programming Languages (POPL), pp. 330–341 (2004)Google Scholar
  12. 12.
    Reps, T., Schwoon, S., Jha, S.: Weighted Pushdown Systems and their Application to Interprocedural Dataflow Analysis. In: Cousot, R. (ed.) SAS 2003. LNCS, vol. 2694, pp. 189–213. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  13. 13.
    Storjohann, A.: Algorithms for Matrix Canonical Forms. PhD thesis, ETH Zürich, Diss. ETH No. 13922 (2000)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2005

Authors and Affiliations

  • Markus Müller-Olm
    • 1
  • Helmut Seidl
    • 2
  1. 1.Fachbereich Informatik, LS 5Universität DortmundDortmundGermany
  2. 2.Institut für Informatik, I2TU MünchenMünchenGermany

Personalised recommendations