skip to main content
research-article

Space-Efficient Manifest Contracts

Published:14 January 2015Publication History
Skip Abstract Section

Abstract

The standard algorithm for higher-order contract checking can lead to unbounded space consumption and can destroy tail recursion, altering a program's asymptotic space complexity. While space efficiency for gradual types---contracts mediating untyped and typed code---is well studied, sound space efficiency for manifest contracts---contracts that check stronger properties than simple types, e.g., "is a natural'' instead of "is an integer''---remains an open problem.

We show how to achieve sound space efficiency for manifest contracts with strong predicate contracts. The essential trick is breaking the contract checking down into coercions: structured, blame-annotated lists of checks. By carefully preventing duplicate coercions from appearing, we can restore space efficiency while keeping the same observable behavior.

Skip Supplemental Material Section

Supplemental Material

References

  1. J. F. Belo, M. Greenberg, A. Igarashi, and B. C. Pierce. Polymorphic contracts. In European Symposium on Programming (ESOP), 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. G. M. Bierman, A. D. Gordon, C. Hri\ctcu, and D. Langworthy. Semantic subtyping with an SMT solver. In International Conference on Functional Programming (ICFP), 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. C. Dimoulas, R. Findler, and M. Felleisen. Option contracts. In OOPSLA, pages 475 -- 494, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. R. B. Findler. Contracts as pairs of projections. In Symposium on Logic Programming, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. R. B. Findler and M. Felleisen. Contracts for higher-order functions. In International Conference on Functional Programming (ICFP), 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. R. B. Findler, S.-Y. Guo, and A. Rogers. Lazy contract checking for immutable data structures. In Implementation and Application of Functional Languages, pages 111--128. 2008. 10.1007/978--3--540--85373--2_7. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. C. Flanagan. Hybrid type checking. In Principles of Programming Languages (POPL), 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. R. Garcia. Calculating threesomes, with blame. In International Conference on Functional Programming (ICFP), 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. M. Greenberg. Manifest Contracts. PhD thesis, University of Pennsylvania, November 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. M. Greenberg. Space-efficient manifest contracts, 2014. URL http://arxiv.org/abs/1410.2813. Technical report.Google ScholarGoogle Scholar
  11. M. Greenberg, B. C. Pierce, and S. Weirich. Contracts made manifest. In Principles of Programming Languages (POPL), 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. M. Greenberg, B. C. Pierce, and S. Weirich. Contracts made manifest. Journal of Functional Programming (JFP), 22 (3): 225--274, May 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. J. Gronski and C. Flanagan. Unifying hybrid types and contracts. In Trends in Functional Programming (TFP), 2007.Google ScholarGoogle Scholar
  14. F. Henglein. Dynamic typing: Syntax and proof theory. Sci. Comput. Program., 22 (3): 197--230, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. D. Herman, A. Tomb, and C. Flanagan. Space-efficient gradual typing. In Trends in Functional Programming (TFP), pages 404--419, 2007.Google ScholarGoogle Scholar
  16. D. Herman, A. Tomb, and C. Flanagan. Space-efficient gradual typing. Higher Order Symbol. Comput., 23 (2): 167--189, June 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. K. Knowles and C. Flanagan. Hybrid type checking. ACM Trans. Prog. Lang. Syst., 32: 6:1--6:34, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. K. Knowles, A. Tomb, J. Gronski, S. N. Freund, and C. Flanagan. Sage: Hybrid checking for flexible specifications. In Scheme and Functional Programming Workshop, 2006.Google ScholarGoogle Scholar
  19. E. Koukoutos and V. Kuncak. Checking data structure properties orders of magnitude faster. In Runtime Verification, pages 263--268. 2014. 10.1007/978--3--319--11164--3_22.Google ScholarGoogle ScholarCross RefCross Ref
  20. R. Lipton, October 2010. URL http://goo.gl/6Grgt0.Google ScholarGoogle Scholar
  21. R. Milner. A theory of type polymorphism in programming. Journal of Computer and System Sciences, 17: 348--375, Aug. 1978.Google ScholarGoogle ScholarCross RefCross Ref
  22. PLT. Racket contract system, 2013. URL http://pre.plt-scheme.org/docs/html/guide/contracts.html.Google ScholarGoogle Scholar
  23. A. Rastogi, A. Chaudhuri, and B. Hosmer. The ins and outs of gradual type inference. In Principles of Programming Languages (POPL), 2012. 10.1145/2103656.2103714. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. J. Siek, R. Garcia, and W. Taha. Exploring the design space of higher-order casts. In Programming Languages and Systems, volume 5502 of LNCS, pages 17--31. 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. J. Siek, P. Thiemann, and P. Wadler. Blame, coercion, and threesomes: Together again for the first time. Draft., 2014. URL http://homepages.inf.ed.ac.uk/wadler/topics/blame.html#coercions.Google ScholarGoogle Scholar
  26. J. G. Siek and R. Garcia. Interpretations of the gradually-typed lambda calculus. In Scheme and Functional Programming (SFP), 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. J. G. Siek and W. Taha. Gradual typing for functional languages. In Scheme and Functional Programming Workshop, September 2006.Google ScholarGoogle Scholar
  28. J. G. Siek and P. Wadler. Threesomes, with and without blame. In Principles of Programming Languages (POPL), pages 365--376, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. N. Swamy, M. Hicks, and G. M. Bierman. A theory of typed coercions and its applications. In International Conference on Functional Programming (ICFP), pages 329--340, 2009. ISBN 978--1--60558--332--7. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. S. Tobin-Hochstadt and M. Felleisen. Interlanguage migration: From scripts to programs. In OOPSLA, 2006. 10.1145/1176617.1176755. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. P. Wadler and R. B. Findler. Well-typed programs can't be blamed. In European Symposium on Programming (ESOP), 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. A. K. Wright and M. Felleisen. A syntactic approach to type soundness. Information and Computation, 115: 38--94, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Space-Efficient Manifest Contracts

    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

    Full Access

    • Published in

      cover image ACM SIGPLAN Notices
      ACM SIGPLAN Notices  Volume 50, Issue 1
      POPL '15
      January 2015
      682 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/2775051
      • Editor:
      • Andy Gill
      Issue’s Table of Contents
      • cover image ACM Conferences
        POPL '15: Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages
        January 2015
        716 pages
        ISBN:9781450333009
        DOI:10.1145/2676726

      Copyright © 2015 ACM

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 14 January 2015

      Check for updates

      Qualifiers

      • research-article

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader
    About Cookies On This Site

    We use cookies to ensure that we give you the best experience on our website.

    Learn more

    Got it!