skip to main content
Refinement types for ML
  • Author:
  • Tim Freeman
Publisher:
  • Carnegie Mellon University
  • Schenley Park Pittsburgh, PA
  • United States
Order Number:UMI Order No. GAX94-19722
Reflects downloads up to 06 Oct 2024Bibliometrics
Skip Abstract Section
Abstract

Programming computers is a notoriously error-prone process. It is the job of the programming language designer to make this process more reliable. One approach to this is to impose some sort of typing discipline on the programs. In doing this, the programming language designer is immediately faced with a tradeoff: if the type system is too simple, it cannot accurately express important properties of the program; if it is too expressive, then mechanically checking or inferring the types becomes impractical. This thesis describes a type system called refinement types, which is an example of a new way to make this tradeoff, as well as a potentially useful system in itself.

Refinement type inference requires programs to have types in two type systems: an expressive type inference system (intersection types with subtyping) and a relatively simple type system (basic polymorphic type inference). Refinement type inference inherits some properties from each of these: as in intersection types with subtyping, we can use the type system to do abstract interpretation; as in basic polymorphic type inference, refinement type inference is decidable (preliminary experiments suggest refinement type inference may be practical as well).

We have implemented refinement type inference for a subset of Standard ML to test these ideas. We have added new syntax, called rectype declarations, to allow the programmer to specify relevant domains for the abstract interpretation. A prototype implementation of refinement type inference can do some interesting case analysis for Standard ML programs; for example, if the programmer uses a rectype declaration to declare interest in whether a boolean expression is in conjunctive normal form (CNF), refinement type inference can efficiently prove that a function for converting boolean expressions to CNF does indeed always return a boolean expression in CNF. Rectype declarations and refinement type inference seem flexible and efficient enough to practically enforce many other useful program properties as well.

Cited By

  1. ACM
    Jafery K and Dunfield J (2017). Sums of uncertainty: refinements go gradual, ACM SIGPLAN Notices, 52:1, (804-817), Online publication date: 11-May-2017.
  2. ACM
    Jafery K and Dunfield J Sums of uncertainty: refinements go gradual Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages, (804-817)
  3. Lovas W and Pfenning F (2019). A Bidirectional Refinement Type System for LF, Electronic Notes in Theoretical Computer Science (ENTCS), 196, (113-128), Online publication date: 1-Jan-2008.
  4. Fluet M and Pucella R (2006). Practical Datatype Specializations with Phantom Types and Recursion Schemes, Electronic Notes in Theoretical Computer Science (ENTCS), 148:2, (211-237), Online publication date: 1-Mar-2006.
  5. ACM
    Dunfield J and Pfenning F (2004). Tridirectional typechecking, ACM SIGPLAN Notices, 39:1, (281-292), Online publication date: 1-Jan-2004.
  6. ACM
    Dunfield J and Pfenning F Tridirectional typechecking Proceedings of the 31st ACM SIGPLAN-SIGACT symposium on Principles of programming languages, (281-292)
  7. ACM
    Nordlander J (1998). Pragmatic subtyping in polymorphic languages, ACM SIGPLAN Notices, 34:1, (216-227), Online publication date: 1-Jan-1999.
  8. ACM
    Xi H and Pfenning F Eliminating array bound checking through dependent types Proceedings of the ACM SIGPLAN 1998 conference on Programming language design and implementation, (249-257)
  9. ACM
    Xi H and Pfenning F (1998). Eliminating array bound checking through dependent types, ACM SIGPLAN Notices, 33:5, (249-257), Online publication date: 1-May-1998.
  10. ACM
    Nordlander J Pragmatic subtyping in polymorphic languages Proceedings of the third ACM SIGPLAN international conference on Functional programming, (216-227)
  11. Kristoffersen B and Dahl O (2018). On introducing higher order functions in ABEL, Nordic Journal of Computing, 5:1, (50-69), Online publication date: 1-Mar-1998.
Contributors
  • Carnegie Mellon University
Please enable JavaScript to view thecomments powered by Disqus.

Recommendations