Abstract
Flexible records are a powerful concept in type systems that form the basis of, for instance, objects in dynamically typed languages. One caveat of using flexible records is that a program may try to access a record field that does not exist. We present a type inference algorithm that checks for these runtime errors. The novelty of our algorithm is that it satisfies a clear notion of completeness: The inferred types are optimal in the sense that type annotations cannot increase the set of typeable programs. Under certain assumptions, our algorithm guarantees the following stronger property: it rejects a program if and only if it contains a path from an empty record to a field access on which the field has not been added. We derive this optimal algorithm by abstracting a semantics to types. The derived inference rules use a novel combination of type terms and Boolean functions that retains the simplicity of unification-based type inference but adds the ability of Boolean functions to express implications, thereby addressing the challenge of combining implications and types. By following our derivation method, we show how various operations such as record concatenation and branching if a field exists lead to Boolean satisfiability problems of different complexity. Analogously, we show that more expressive type systems give rise to SMT problems. On the practical side, we present an implementation of the select and update operations and give practical evidence that these are sufficient in real-world applications.
- J. Brauer, A. King, and J. Kriener. Existential Quantification as Incremental SAT. In G. Gopalakrishnan and S. Qadeer, editors, Computer Aided Verification, LNCS, page 16. Springer, July 2011. Google Scholar
Digital Library
- L. Cardelli and J. C. Mitchell. Operations on Records. In Mathematical Structures in Computer Science, volume 1, pages 3--48, 1991.Google Scholar
Cross Ref
- P. Cousot. Types as Abstract Interpretations. In Principles of Programming Languages, pages 316--331, Paris, France, Jan. 1997. ACM. invited paper. Google Scholar
Digital Library
- P. Cousot and R. Cousot. Static Determination of Dynamic Properties of Programs. In B. Robinet, editor, International Symposium on Programming, pages 106--130, Paris, France, Apr. 1976.Google Scholar
- P. Cousot and R. Cousot. Systematic Design of Program Analysis Frameworks. In Principles of Programming Languages, pages 269--282, San Antonio, Texas, USA, Jan. 1979. ACM. Google Scholar
Digital Library
- L. Damas and R. Milner. Principal Type-Schemes for Functional Programs. In Principles of Programming Languages, pages 207--212, Albuquerque, New Mexico, USA, 1982. ACM. Google Scholar
Digital Library
- W. F. Dowling and J. H. Gallier. Linear-Time Algorithms for Testing the Satisfiability of Propositional Horn Formulae. J. Log. Program., 1 (3):267--284, 1984.Google Scholar
Cross Ref
- R. Giacobazzi, F. Ranzato, and F. Scozzari. Making abstract interpretations complete. Journal of the ACM, 47(2):361--416, 2000. Google Scholar
Digital Library
- K. Glynn, P. J. Stuckey, and M. Sulzmann. Boolean Constraints for Binding-time Analysis. In Programs as Data Objects, number 2053 in LNCS, pages 39--62. Springer, 2001. Google Scholar
Digital Library
- R. Gori and G. Levi. An Experiment in Type Inference and Verification by Abstract Interpretation. In A. Cortesi, editor, Verification, Model Checking, and Abstract Interpretation, volume 2294 of LNCS, pages 237--241, Venice, Italy, Jan. 2002. Springer. Google Scholar
Digital Library
- A. Igarashi, B. C. Pierce, and P. Wadler. Featherweight Java: a minimal core calculus for Java and GJ. ACM Transactions on Programming Languages and Systems, 23(3):396--450, May 2001. Google Scholar
Digital Library
- T. Jim. What are principal typings and what are they good for? In Principles of Programming Languages, pages 42--53, St. Petersburg Beach, Florida, USA, 1996. ACM. Google Scholar
Digital Library
- A. Kfoury, J. Tiuryn, and P. Urzyczyn. The Undecidability of the Semi-unification Problem. Information and Computation, 102(1):83--101, 1993. Google Scholar
Digital Library
- J.-L. Lassez, M. J. Maher, and K. Marriott. Unification Revisited. In M. Boscarol, L. C. Aiello, and G. Levi, editors, Foundations of Logic and Functional Programming, volume 306 of LNCS, pages 67--113, Trento, Italy, Dec. 1986. Springer. Google Scholar
Digital Library
- R. Milner. A Theory of Type Polymorphism in Programming. Journal of Computer and System Sciences, 17(3):348--375, 1978.Google Scholar
Cross Ref
- A. Mycroft. Polymorphic Type Schemes and Recursive Definitions. In M. Paul and B. Robinet, editors, Symposium on Programming, volume 167 of LNCS, pages 217--228, Toulouse, France, Apr. 1984. Springer. Google Scholar
Digital Library
- M. Odersky, M. Sulzmann, and M. Wehr. Type Inference with Constrained Types. Theory and Practice of Object Systems, 5(1):35--55, Jan. 1999. ISSN 1074-3227. Google Scholar
Digital Library
- F. Pottier. A Versatile Constraint-Based Type Inference System. Nordic Journal of Computing, 7(4):312--347, Nov. 2000. Google Scholar
Digital Library
- D. Rémy. Type Inference for Records in a Natural Extension of ML. In C. A. Gunter and J. C. Mitchell, editors, Theoretical Aspects Of Object-Oriented Programming. Types, Semantics and Language Design. MIT Press, 1993. Google Scholar
Digital Library
- E. Robbins, A. King, and H. Jacob. Theory Propagation and Rational-Trees. In T. Schrijvers, editor, Principles and Practice of Declarative Programming, pages 193--204, Madrid, Spain, 2013. ACM. Google Scholar
Digital Library
- D. A. Schmidt. Comparing Completeness Properties of Static Analyses and Their Logics. In N. Kobayashi, editor, Asian Symposium on Programming Languages and Systems, volume 4279 of LNCS, pages 183--199, Sydney, Australia, Nov. 2006. Springer. Google Scholar
Digital Library
- T. Schrijvers, S. Peyton-Jones, M. Sulzmann, and D. Vytiniotis. Complete and Decidable Type Inference for GADTs. In International Conference on Functional programming, pages 341--352, Edinburgh, UK, Sept. 2009. ACM. Google Scholar
Digital Library
- A. Simon. Deriving a Complete Type Inference for Hindley-Milner and Vector Sizes using Expansion. Science of Computer Programming, 2014.Google Scholar
Digital Library
- A. Simon. Optimal Inference of Fields in Row-Polymorphic Records (proof appendix). Technical report, TU Munich, June 2014.Google Scholar
- A. Simon and J. Kranz. The GDSL toolkit: Generating Frontends for the Analysis of Machine Code. In Program Protection and Reverse Engineering Workshop, San Diego, California, USA, Jan. 2014. ACM. Google Scholar
Digital Library
- V. Simonet and F. Pottier. A Constraint-Based Approach to Guarded Algebraic Data Types. Transactions on Programming Languages and Systems, 29(1), Jan. 2007. Google Scholar
Digital Library
- D. Vytiniotis, S. L. Peyton Jones, and T. Schrijvers. Let Should not be Generalized. In A. Kennedy and N. Benton, editors, Types in Languages Design and Implementation, pages 39--50, Madrid, Spain, Jan. 2010. ACM. Google Scholar
Digital Library
- J. B. Wells. The Essence of Principal Typings. In P. Widmayer, F. T. Ruiz, R. M. Bueno, M. Hennessy, S. Eidenbenz, and R. Conejo, editors, Colloquium on Automata, Languages and Programming, volume 2380 of LNCS, pages 913--925, Malaga, Spain, July 2002. Springer. Google Scholar
Digital Library
Index Terms
Optimal inference of fields in row-polymorphic records
Recommendations
Optimal inference of fields in row-polymorphic records
PLDI '14: Proceedings of the 35th ACM SIGPLAN Conference on Programming Language Design and ImplementationFlexible records are a powerful concept in type systems that form the basis of, for instance, objects in dynamically typed languages. One caveat of using flexible records is that a program may try to access a record field that does not exist. We present ...
Deriving a complete type inference for Hindley-Milner and vector sizes using expansion
Type inference and program analysis both infer static properties about a program. Yet, they are constructed using very different techniques. We reconcile both approaches by deriving a type inference from a denotational semantics using abstract ...
Type checking and inference for polymorphic and existential types
CATS '09: Proceedings of the Fifteenth Australasian Symposium on Computing: The Australasian Theory - Volume 94This paper proves undecidability of type checking and type inference problems in some variants of typed lambda calculi with polymorphic and existential types. First, type inference in the domain-free polymorphic lambda calculus is proved to be ...







Comments