Skip to main content
Log in

Calculating Sized Types

  • Published:
Higher-Order and Symbolic Computation

Abstract

Many program optimizations and analyses, such as array-bounds checking, termination analysis, etc., depend on knowing the size of a function's input and output. However, size information can be difficult to compute. Firstly, accurate size computation requires detecting a size relation between different inputs of a function. Secondly, different optimizations and analyses may require slightly different size information, and thus slightly different computation. Literature in size computation has mainly concentrated on size checking, instead of size inference. In this paper, we provide a generic framework on which different size variants can be expressed and computed. We also describe an effective algorithm for inferring, instead of checking, size information. Size information are expressed in terms of Presburger formulae, and our algorithm utilizes the Omega Calculator to compute as exact a size information as possible, within the linear arithmetic capability.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

References

  1. Benoy, F. and King, A. Inferring argument size relationships with CLP(R). In Logic Programming Synthesis and Transformation. Springer-Verlag, August 1997.

  2. Bossi, A., Cocco, N., and Fabris, M. Typed norms. In European Symposium on Programming '92. Lecture Notes in Computer Science, Vol. 582, Springer-Verlag, 1992, pp. 73–92.

  3. Brodsky, A. and Sagiv, Y. Inference of inequality constraints in logic programs. In Proceedings of the 10th ACM SIGACT-SIGMOD-SIGART Symposium on Principles of Database Systems. ACM Press, 1991, pp. 227–240.

  4. Chin, W.N. and Hagiya, M. A bounds inference method for vector-based memoisation. In 2nd ACM Intl. Conference on Functional Programming, Amsterdam, Holland, June 1997. ACM Press, pp. 176–187.

    Google Scholar 

  5. Chin, W.N., Khoo, S.C., and Xu, D.N. Deriving pre-conditions for array bound check elimination. In Proceedings of the Second Symposium on Programs as Data Objects, LNCS 2053, O. Danvy and A. Filinski (Eds.). 2001, pp. 2–24.

  6. Cooper, D.C. Programs for mechanical program verification. In Proceedings of the Sixth Annual Machine Intelligence Workshop, Edinburgh, Machine Intelligence, B. Meltzer and D. Michie (Eds.). Vol. 6, Edinburgh University Press, 1971, pp. 43–59.

    Google Scholar 

  7. Cousot, P. and Halbwachs, N. Automatic discovery of linear restraints among variables of a program. In Symposium on Principles of Programming Languages, 1978, ACM Press, pp. 84–96.

  8. De Schreye, D. and Decorte, S. Termination of logic programs: the never-ending story. Journal of Logic Programming, 19/20 (1994) 199–260.

    Google Scholar 

  9. Glenstrup, A.J. and Jones, N.D. BTA algorithms to ensure termination of off-line partial evaluation. In “Perspective of System Informatics”. Lecture Notes in Computer Science, Vol. 1110, Springer-Verlag, 1996.

  10. Halbwachs, N. About synchronous programming and abstract interpretation. Science of Computer Programming, Special Issue on SAS'94, 31(1) (1998).

  11. Halbwachs, N., Proy, Y.E., and Roumanoff, P. Verification of real-time systems using linear relation analysis. Formal Methods in System Design, 11(2) (1997) 157–185.

    Google Scholar 

  12. Henglein, F. Type inference with polymorphic recursion. ACM Transactions on Programming Languages and Systems, 15(2) (1993) 253–289.

    Google Scholar 

  13. Henkin, L., Monk, J.D., and Tarski, A. Cylindric Algebras: Part I. North-Holland, Amsterdam, 1971.

    Google Scholar 

  14. Hilbert, D. and Bernays, P. Grundlagen der Mathematik I. Springer-Verlag, Berlin, 1968.

    Google Scholar 

  15. Holst, C.K. Finiteness analysis. In 5th ACM Functional Programming Languages and Computer Architecture Conference, Cambridge, Massachusetts, August 1991. Lecture Notes in Computer Science,Vol. 523, Springer-Verlag, pp. 473–495.

    Google Scholar 

  16. Hughes, J., Pareto, L., and Sabry, A. Proving the correctness of reactive systems using sized types. In 23rd ACM Principles of Programming Languages Conference, January 1996. ACM Press, pp. 410–423.

  17. Jeannet, B., Halbwachs, N., and Raymond, P. Dynamic partitioning in analyses of numerical properties. In International Symposium on Static Analysis, SAS'99. Lecture Notes in Computer Science, Vol. 1694, Springer-Verlag, Berlin, 1999, pp. 39–50.

    Google Scholar 

  18. Kelly, P., Maslov, V., Pugh, W., Rosser, E., Shpeisman, T., and Wonnacott, D. The Omega library version 1.1.0 interface guide. University of Maryland, College Park, November 1996. http://www.cs.umd.edu/projects/omega

    Google Scholar 

  19. Kelly, P., Pugh, W., Rosser, E., and Shpeisman, T. Transitive closure of infinite graphs and its applications. Technical Report, UMIACS-TR–95–48, University of Maryland, College Park, April 1994.

    Google Scholar 

  20. King, A., Shen, K., and Benoy, F. Lower-bound time-complexity analysis of logic programs. In International Symposium on Logic Programming, November 1997, Jan Maluszynski (Ed.). MIT Press, Cambridge, MA, pp. 261–276.

    Google Scholar 

  21. Nishimura, S. Parametric polymorphic type inference in constraint form. In Second JSSST Workshop on Programming and Programming Languages, Japan, March 2000. pp. 38–49.

  22. Odersky, M., Sulzmann, M., and Wehr, M. Type inference with constrained types. Theory and Practice of Object Systems, 5(1) (1999) 35–55.

    Google Scholar 

  23. Plumer, L. Termination proofs for logic programs. In Lecture Notes in Artificial Intelligence, Vol. 446. Springer-Verlag, Berlin, 1990.

    Google Scholar 

  24. Pugh, W. The Omega test: a fast practical integer programming algorithm for dependence analysis. Communications of ACM, 8 (1992) 102–114.

    Google Scholar 

  25. Schrijver, A. Theory of Linear and Integer Programming. John Wiley & Sons, New York, 1986.

    Google Scholar 

  26. Sohn, K. and Van Gelder, A. Termination detection in logic programs using argument sizes (extended abstract). In Proceedings of the 10th ACM SIGACT-SIGMOD-SIGART Symposium on Principles of Database Systems, 1991, pp. 216–226.

  27. Speirs, C., Somogyi, Z., and Sondergaard, H. Termination analysis of Mercury. In Fourth International Symposium on Static Analysis, Paris, France, 1997. Lecture Notes in Computer Science, Vol. 1302, pp. 157–171.

    Google Scholar 

  28. Ullman, J.D. and Van Gelder, A. Efficient tests for top-down termination of logical rules. Journal of ACM, 35(2) (1998) 345–373.

    Google Scholar 

  29. Xi, H. and Pfenning, F. Eliminating array bound checking through dependent types. In ACM Conference on Programming Language Design and Implementation, June 1998. ACM Press, pp. 249–257.

  30. Xi, H. and Pfenning, F. Dependent types in practical programming. In Symposium on Principles of Programming Languages, January 1999. ACM Press, pp. 214–227.

Download references

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

About this article

Cite this article

Chin, WN., Khoo, SC. Calculating Sized Types. Higher-Order and Symbolic Computation 14, 261–300 (2001). https://doi.org/10.1023/A:1012996816178

Download citation

  • Issue Date:

  • DOI: https://doi.org/10.1023/A:1012996816178

Navigation