skip to main content
10.1145/2628136.2628161acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article

Refinement types for Haskell

Published:19 August 2014Publication History

ABSTRACT

SMT-based checking of refinement types for call-by-value languages is a well-studied subject. Unfortunately, the classical translation of refinement types to verification conditions is unsound under lazy evaluation. When checking an expression, such systems implicitly assume that all the free variables in the expression are bound to values. This property is trivially guaranteed by eager, but does not hold under lazy, evaluation. Thus, to be sound and precise, a refinement type system for Haskell and the corresponding verification conditions must take into account which subset of binders actually reduces to values. We present a stratified type system that labels binders as potentially diverging or not, and that (circularly) uses refinement types to verify the labeling. We have implemented our system in LIQUIDHASKELL and present an experimental evaluation of our approach on more than 10,000 lines of widely used Haskell libraries. We show that LIQUIDHASKELL is able to prove 96% of all recursive functions terminating, while requiring a modest 1.7 lines of termination-annotations per 100 lines of code.

References

  1. L. Augustsson. Cayenne - a language with dependent types. In ICFP, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. G. Barthe, M. J. Frade, E. Giménez, L. Pinto, and T. Uustalu. Type-based termination of recursive definitions.. Mathematical Structures in Computer Science, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. J. F. Belo, M. Greenberg, A. Igarashi, and B. C. Pierce. Polymorphic contracts. In ESOP, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. J. Bengtson, K. Bhargavan, C. Fournet, A. D. Gordon, and S. Maffeis. Refinement types for secure implementations. ACM TOPLAS, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Y. Bertot and P. Castéran. Coq'Art: The Calculus of Inductive Constructions. Springer Verlag, 2004.Google ScholarGoogle Scholar
  6. A. Bradley and Z. Manna. The Calculus of Computation: Decision Procedures With Application To Verification. Springer-Verlag, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. E. Brady. Idris: general purpose programming with dependent types. In PLPV, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. V. Capretta. General recursion via coinductive types. Logical Methods in Computer Science, 2005.Google ScholarGoogle ScholarCross RefCross Ref
  9. C. Casinghino, V. Sjöberg, and S. Weirich. Combining proofs and programs in a dependently typed language. In POPL, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. R. L. Constable and S. F. Smith. Partial objects in constructive type theory. In LICS, 1987.Google ScholarGoogle Scholar
  11. L. de Moura and N. Bjãrner. Z3: An efficient SMT solver. 2008.Google ScholarGoogle Scholar
  12. D. Detlefs, G. Nelson, and J. B. Saxe. Simplify: a theorem prover for program checking. J. ACM, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. J. Dunfield. Refined typechecking with Stardust. In PLPV, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. C. Flanagan, K.R.M. Leino, M. Lillibridge, G. Nelson, J. B. Saxe, and R. Stata. Extended static checking for Java. In PLDI, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. J. Giesl, M. Raffelsieper, P. Schneider-Kamp, S. Swiderski, and R. Thiemann. Automated termination proofs for Haskell by term rewriting. TPLS, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. C. A. R. Hoare. Procedures and parameters: An axiomatic approach. In Symposium on Semantics of Algorithmic Languages. 1971.Google ScholarGoogle ScholarCross RefCross Ref
  17. J. Hughes, L. Pareto, and A. Sabry. Proving the correctness of reactive systems using sized types. In POPL, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. L. Jia, J. A. Vaughan, K. Mazurak, J. Zhao, L. Zarko, J. Schorr, and S. Zdancewic. Aura: a programming language for authorization and audit. In ICFP, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. N. D. Jones and N. Bohr. Termination analysis of the untyped lamba-calculus. In RTA, 2004.Google ScholarGoogle Scholar
  20. M. Kawaguchi, P. Rondon, and R. Jhala. Type-based data structure verification. In PLDI, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. K.W. Knowles and C. Flanagan. Hybrid type checking. ACM TOPLAS, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. G. Nelson. Techniques for program verification. Technical Report CSL81-10, Xerox Palo Alto Research Center, 1981.Google ScholarGoogle Scholar
  23. T. Nipkow. Hoare logics for recursive procedures and unbounded nondeterminism. In CSL, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. U. Norell. Towards a practical programming language based on dependent type theory. PhD thesis, Chalmers, 2007.Google ScholarGoogle Scholar
  25. S. R. Della Rocca and L. Paolini. The Parametric Lambda Calculus, A Metamodel for Computation. 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. P. Rondon, M. Kawaguchi, and R. Jhala. Liquid Types. In PLDI, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. J. Rushby, S. Owre, and N. Shankar. Subtypes for specifications: Predicate subtyping in pvs. IEEE TSE, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. D. Sereni and N. D. Jones. Termination analysis of higher-order functional programs. In APLAS, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. W. Sonnex, S. Drossopoulou, and S. Eisenbach. Zeno: An automated prover for properties of recursive data structures. In TACAS, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. M. Sulzmann, M. M. T. Chakravarty, S. L. Peyton-Jones, and K. Donnelly. System F with type equality coercions. In TLDI, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. N. Swamy, J. Chen, C. Fournet, P-Y. Strub, K. Bhargavan, and J. Yang. Secure distributed programming with value-dependent types. In ICFP, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. A. M. Turing. On computable numbers, with an application to the eintscheidungsproblem. In LMS, 1936.Google ScholarGoogle Scholar
  33. N. Vazou, P. Rondon, and R. Jhala. Abstract refinement types. In ESOP, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. N. Vazou, E. L. Seidel, and R. Jhala. Liquidhaskell: Experience with refinement types in the real world. In Haskell Symposium, 2014.Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. D. Vytiniotis, S. L. Peyton-Jones, K. Claessen, and D. Rosén. Halo: haskell to logic through denotational semantics. In POPL, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. H. Xi. Dependent types for program termination verification. In LICS, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. H. Xi and F. Pfenning. Eliminating array bound checking through dependent types. In PLDI, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. D. N. Xu, S. L. Peyton-Jones, and K. Claessen. Static contract checking for haskell. In POPL, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Refinement types for Haskell

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in
      • Published in

        cover image ACM Conferences
        ICFP '14: Proceedings of the 19th ACM SIGPLAN international conference on Functional programming
        August 2014
        390 pages
        ISBN:9781450328739
        DOI:10.1145/2628136

        Copyright © 2014 ACM

        Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 19 August 2014

        Permissions

        Request permissions about this article.

        Request Permissions

        Check for updates

        Qualifiers

        • research-article

        Acceptance Rates

        ICFP '14 Paper Acceptance Rate28of85submissions,33%Overall Acceptance Rate333of1,064submissions,31%

        Upcoming Conference

        ICFP '24

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader