Abstract
General refinement types allow types to be refined by predicates written in a general-purpose programming language, and can express function pre- and postconditions and data structure invariants. In this setting, with expressive and possibly verbose types, type reconstruction is particularly valuable, yet typeability is undecidable because it subsumes type checking. Using a generalized notion of type reconstruction, we present the first type reconstruction algorithm for a type system with base types refined by abitrary program terms. Our algorithm is a typeability-preserving transformation and defers type checking to a subsequent phase. The algorithm generates and solves a collection of implication constraints over refinement predicates, inferring maximally precise refinement predicates in a largely syntactic manner that is reminiscent of strongest postcondition calculation. Perhaps surprisingly, our notion of type reconstruction is decidable even though type checking is not.
Keywords
- Functional Programming
- Type Inference
- Type Check
- Shape Reconstruction
- Type Replacement
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.
Chapter PDF
References
Aiken, A., Wimmers, E.: Type inclusion constraints and type inference. In: Proceedings of the Conference on Functional Programming Languages and Computer Architecture, pp. 31–41 (1993)
Back, R.J.R.: A calculus of refinements for program derivations. Acta Informatica 25(6), 593–624 (1988)
Hoare, C.A.R.: An axiomatic basis for computer programming. Communications of the ACM 12, 576–580 (1969)
Cousot, P., Cousot, R.: Formal language, grammar, and set-constraint-based program analysis by abstract interpretation. In: Proceedings of the International Conference on Functional Programming and Computer Architecture, pp. 170–181 (1995)
Davies, R., Pfenning, F.: Intersection types and computational effects. In: Proceedings of the ACM International Conference on Functional Programming, pp. 198–208. ACM Press, New York (2000)
Denney, E.: Refinement types for specification. In: Proceedings of the IFIP International Conference on Programming Concepts and Methods. IFIP Conference Proceedings, vol. 125, pp. 148–166. Chapman and Hall, Boca Raton (1998)
Dijkstra, E.W.: A Discipline of Programming. Prentice-Hall, Englewood Cliffs (1976)
Dunfield, J.: Combining two forms of type refinements. Technical Report CMU-CS-02-182, CMU School of Computer Science, Pittsburgh, Penn. (2002)
Fähndrich, M., Aiken, A.: Making set-constraint based program analyses scale. Technical Report UCB/CSD-96-917, University of California at Berkeley (1996)
Flanagan, C.: Hybrid type checking. In: Proceedings of the ACM Symposium on Principles of Programming Languages, pp. 245–256 (2006)
Flanagan, C., Felleisen, M.: Componential set-based analysis. In: Proceedings of the ACM Conference on Programming Language Design and Implementation, pp. 235–248 (1997)
Floyd, R.W.: Assigning meaning to programs. In: Proceedings of the Symposium in Applied Mathematics: Mathematical Aspects of Computer Science, pp. 19–32 (1967)
Freeman, T., Pfenning, F.: Refinement types for ML. In: Proceedings of the ACM Conference on Programming Language Design and Implementation, pp. 268–277 (1991)
Fuh, Y., Mishra, P.: Type inference with subtypes. In: Proceedings of the European Symposium on Programming, pp. 155–175 (1988)
Gronski, J., et al.: Sage: Practical hybrid checking for expressive types and specifications. In: Proceedings of the Workshop on Scheme and Functional Programming, pp. 93–104 (2006)
Hayashi, S.: Logic of refinement types. In: Proceedings of the Workshop on Types for Proofs and Programs, pp. 157–172 (1993)
Heintze, N.: Set Based Program Analysis. PhD thesis, Carnegie Mellon University (1992)
Hoang, M., Mitchell, J.C.: Lower bounds on type inference with subtypes. In: Proceedings of the ACM Symposium on Principles of Programming Languages, pp. 176–185 (1995)
Knowles, K., Flanagan, C.: Type reconstruction for general refinement types (2007), http://www.soe.ucsc.edu/~cormac/papers/htr-full.pdf
Leino, K.R.M., Millstein, T., Saxe, J.B.: Generating error traces from verification-condition counterexamples. Science of Computer Programming 55(1-3), 209–226 (2005), doi:10.1016/j.scico.2004.05.016
Lincoln, P., Mitchell, J.C.: Algorithmic aspects of type inference with subtypes. In: Proceedings of the ACM Symposium on Principles of Programming Languages, pp. 293–304 (1992)
Mandelbaum, Y., Walker, D., Harper, R.: An effective theory of type refinements. In: Proceedings of the ACM International Conference on Functional Programming, Uppsala, Sweden, pp. 213–225. ACM Press, New York (2003), doi:10.1145/944705.944725
Mitchell, J.C.: Coercion and type inference. In: Proceedings of the ACM Symposium on Principles of Programming Languages, pp. 175–185 (1983)
Nanevski, A., Morrisett, G., Birkedal, L.: Polymorphism and separation in hoare type theory. In: Proceedings of the International Conference on Functional Programming, pp. 62–73 (2006)
Odersky, M., Sulzmann, M., Wehr, M.: Type inference with constrained types. Theory and Practice of Object Systems 5(1), 35–55 (1999)
Ou, X., et al.: Dynamic typing with dependent types. In: Proceedings of the IFIP International Conference on Theoretical Computer Science, pp. 437–450 (2004)
Pierce, B.C., Turner, D.N.: Local type inference. In: Proceedings of the ACM Symposium on Principles of Programming Languages, pp. 252–265 (1998)
Pottier, F.: Simplifying subtyping constraints. In: Proceedings of the ACM International Conference on Functional Programming, pp. 122–133. ACM Press, New York (1996)
Xi, H., Pfenning, F.: Dependent types in practical programming. In: Proceedings of the ACM Symposium on Principles of Programming Languages, pp. 214–227 (1999)
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 2007 Springer Berlin Heidelberg
About this paper
Cite this paper
Knowles, K., Flanagan, C. (2007). Type Reconstruction for General Refinement Types. In: De Nicola, R. (eds) Programming Languages and Systems. ESOP 2007. Lecture Notes in Computer Science, vol 4421. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-71316-6_34
Download citation
DOI: https://doi.org/10.1007/978-3-540-71316-6_34
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-71314-2
Online ISBN: 978-3-540-71316-6
eBook Packages: Computer ScienceComputer Science (R0)
