skip to main content
research-article
Free Access

Polymorphic Manifest Contracts, Revised and Resolved

Published:06 February 2017Publication History
Skip Abstract Section

Abstract

Manifest contracts track precise program properties by refining types with predicates—for example, {x:Int∣ x > 0} denotes the positive integers. Contracts and polymorphism make a natural combination: programmers can give strong contracts to abstract types, precisely stating pre- and post conditions while hiding implementation details— for instance, an abstract type of stacks might specify that the pop operation has input type {x:α Stack ∣ not (empty x)}.

This article studies a polymorphic calculus with manifest contracts and establishes fundamental properties including type soundness and relational parametricity. Indeed, this is not the first work on polymorphic manifest contracts, but existing calculi are not very satisfactory. Gronski et al. developed the Sage language, which introduces polymorphism through the Type:Type discipline, but they do not study parametricity. Some authors of this article have produced two separate works: Belo et al. [2011] and Greenberg [2013] studied polymorphic manifest contracts and parametricity, but their calculi have metatheoretical problems in the type conversion relations. Indeed, they depend on a few conjectures, which turn out to be false. Our calculus is the first polymorphic manifest calculus with parametricity, depending on no conjectures—it resolves the issues in prior calculi with delayed substitution on casts.

Skip Supplemental Material Section

Supplemental Material

References

  1. Martín Abadi, Luca Cardelli, Pierre-Louis Curien, and Jean-Jacques Lévy. 1991. Explicit substitutions. Journal of Functional Programming 1, 4, 375--416.Google ScholarGoogle Scholar
  2. Martín Abadi, Luca Cardelli, Benjamin C. Pierce, and Gordon D. Plotkin. 1989. Dynamic typing in a statically-typed language. In Proceedings of the Symposium on Principles of Programming Languages (POPL’89). 213--227. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Amal Ahmed. 2006. Step-indexed syntactic logical relations for recursive and quantified types. In Proceedings of the European Symposium on Programming (ESOP’06). 69--83. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Amal Ahmed, Robert Bruce Findler, Jacob Matthews, and Philip Wadler. 2009. Blame for all. In Proceedings of the Workshop on Script-to-Program Evolution (STOP’09).Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Amal Ahmed, Robert Bruce Findler, Jeremy Siek, and Philip Wadler. 2011. Blame for all. In Proceedings of the Symposium on Principles of Programming Languages (POPL’11). 201--214.Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Hendrik Pieter Barendregt. 1992. Lambda calculi with types. In Handbook of Logic in Computer Science (Vol. 2), S. Abramsky, Dov M. Gabbay, and S. E. Maibaum (Eds.). Oxford University Press, Oxford, UK, 117--309. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. João Filipe Belo, Michael Greenberg, Atsushi Igarashi, and Benjamin C. Pierce. 2011. Polymorphic contracts. In Proceedings of the European Symposium on Programming (ESOP’11). 18--37. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Gavin M. Bierman, Andrew D. Gordon, Cătălin Hriţcu, and David Langworthy. 2010. Semantic subtyping with an SMT solver. In Proceedings of the 15th ACM SIGPLAN IInternational Conference on Functional Programming (ICFP’10). 105--116. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Luca Cardelli. 1986. A Polymorphic λ-Calculus with Type:Type. Technical Report 10. DEC Systems Research Center, Palo Alto, CA.Google ScholarGoogle Scholar
  10. James Cheney and Ralf Hinze. 2003. First-Class Phantom Types. Technical Report. Cornell University, Ithaca, NY.Google ScholarGoogle Scholar
  11. Ravi Chugh, David Herman, and Ranjit Jhala. 2012. Dependent types for Javascript. In Proceedings of the Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’12). 587--606. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Nicolaas G. de Bruijn. 1980. A survey of the project Automath. In To H. B. Curry: Essays on Combinatory Logic, Lambda Calculus, and Formalism, J. P. Seldin and J. R. Hindley (Eds.). Academic Press, Cambridge, MA, 579--606.Google ScholarGoogle Scholar
  13. Matthias Felleisen and Robert Hieb. 1992. The revised report on the syntactic theories of sequential control and state. Theoretical Computer Science 103, 2, 235--271. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Robert Bruce Findler and Matthias Felleisen. 2002. Contracts for higher-order functions. In Proceedings of the 7th ACM SIGPLAN International Conference on Functional Programming (ICFP’02). 48--59. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Cormac Flanagan. 2006. Hybrid type checking. In Proceedings of the Symposium on Principles of Programming Languages (POPL’06). 245--256. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Matthew Flatt and PLT. 2010. Reference: Racket. Technical Report PLT-TR-2010-1. PLT Design. http://racket-lang.org/tr1/.Google ScholarGoogle Scholar
  17. Tim Freeman and Frank Pfenning. 1991. Refinement types for ML. In Proceedings of the Conference on Programming Language Design and Implementation (PLDI’91). 268--277. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Michael Greenberg. 2013. Manifest Contracts. Ph.D. Dissertation. University of Pennsylvania, Philadelphia, PA. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Michael Greenberg. 2015a. Combining Manifest Contracts with State. Retrieved January 18, 2017, from http://www.cs.pomona.edu/∼michael/papers/hope2015.pdf.Google ScholarGoogle Scholar
  20. Michael Greenberg. 2015b. Space-efficient manifest contracts. In Proceedings of the Symposium on Principles of Programming Languages (POPL’15). 181--194. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Michael Greenberg, Benjamin C. Pierce, and Stephanie Weirich. 2010. Contracts made manifest. In Proceedings of the Symposium on Principles of Programming Languages (POPL’10). 353--364. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Jessica Gronski and Cormac Flanagan. 2007. Unifying hybrid types and contracts. In Proceedings of the Conference on Trends in Functional Programming (TFP’07). 54--70.Google ScholarGoogle Scholar
  23. Jessica Gronski, Kenneth Knowles, Aaron Tomb, Stephen N. Freund, and Cormac Flanagan. 2006. Sage: Hybrid checking for flexible specifications. In Proceedings of the Scheme and Functional Programming Workshop.Google ScholarGoogle Scholar
  24. Dan Grossman, Greg Morrisett, and Steve Zdancewic. 2000. Syntactic type abstraction. ACM Transactions on Programming Languages and Systems 22, 6, 1037--1080. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Arjun Guha, Jacob Matthews, Robert Bruce Findler, and Shriram Krishnamurthi. 2007. Relationally-parametric polymorphic contracts. In Proceedings of the Dynamic Languages Symposium (DLS’07). 29--40. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Robert Harper, Furio Honsell, and Gordon Plotkin. 1993. A framework for defining logics. Journal of the 40, 1, 143--184. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Fritz Henglein. 1992. Dynamic typing. In Proceedings of the European Symposium on Programming (ESOP’92). 233--253. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. David Herman, Aaron Tomb, and Cormac Flanagan. 2010. Space-efficient gradual typing. Higher-Order and Symbolic Computation 23, 2, 167--189. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. C. A. R. Hoare. 1969. An axiomatic basis for computer programming. Communications of the ACM 12, 10, 576--580. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Ranjit Jhala. 2014. Refinement types for Haskell. In Proceedings of the ACM SIGPLAN 2014 Workshop on Programming Languages Meets Program Verification (PLPV’14). ACM, New York, NY, 27--27. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Ming Kawaguchi, Patrick Maxim Rondon, and Ranjit Jhala. 2009. Type-based data structure verification. In Proceedings of the Conference on Programming Language Design and Implementation (PLDI’09). 304--315. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Andrew M. Kent, David Kempe, and Sam Tobin-Hochstadt. 2016. Occurrence typing modulo theories. In Proceedings of the Conference on Programming Language Design and Implementation (PLDI’16). 296--309. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Kenneth Knowles. 2014. Executable Refinement Types. Ph.D. Dissertation. University of California, Santa Cruz.Google ScholarGoogle Scholar
  34. Kenneth Knowles and Cormac Flanagan. 2009. Compositional reasoning and decidable checking for dependent contract types. In Proceedings of the 3rd Workshop on Programming Languages Meets Program Verification (PLPV’09). 27--38. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Kenneth Knowles and Cormac Flanagan. 2010. Hybrid type checking. ACM Transactions on Programming Languages and Systems 32, 2, 6:1--6:34. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Yitzhak Mandelbaum, David Walker, and Robert Harper. 2003. An effective theory of type refinements. In Proceedings of the 8th ACM SIGPLAN International Conference on Functional Programming (ICFP’03). 213--225. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Jacob Matthews and Amal Ahmed. 2008. Parametric polymorphism through run-time sealing or, theorems for low, low prices! In Proceedings of the European Symposium on Programming (ESOP’08). 16--31. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. John C. Mitchell and Gordon D. Plotkin. 1985. Abstract types have existential type. In Proceedings of the Symposium on Principles of Programming Languages (POPL’95). 37--51. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Scott Moore, Christos Dimoulas, Dan King, and Stephen Chong. 2014. SHILL: A secure shell scripting language. In Proceedings of the USENIX Symposium on Operating Systems Design and Implementation (OSDI’14). 183--199. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. James H. Morris Jr. 1973. Types are not sets. In Proceedings of the Symposium on Principles of Programming Languages (POPL’73). 120--124. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. Aleksandar Nanevski, Greg Morrisett, and Lars Birkedal. 2006. Polymorphism and separation in Hoare type theory. In Proceedings of the 11th ACM SIGPLAN International Conference on Functional Programming (ICFP’06). 62--73. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. Georg Neis, Derek Dreyer, and Andreas Rossberg. 2009. Non-parametric parametricity. In Proceedings of the 14th ACM SIGPLAN International Conference on Functional Programming (ICFP’09). 135--148. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. Phúc C. Nguyen, Sam Tobin-Hochstadt, and David Van Horn. 2014. Soft contract verification. In Proceedings of the 19th ACM SIGPLAN International Conference on Functional Programming (ICFP’14). ACM, New York, NY, 139--152. Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. Xinming Ou, Gang Tan, Yitzhak Mandelbaum, and David Walker. 2004. Dynamic typing with dependent types. In Proceedings of the IFIP Conference on Theoretical Computer Science (TCS’04). 437--450.Google ScholarGoogle ScholarCross RefCross Ref
  45. Christine Paulin-Mohring. 1993. Inductive definitions in the system Coq—rules and properties. In Proceedings of the International Conference on Typed Lambda Calculi and Applications (TLCA’93). 328--345. Google ScholarGoogle ScholarDigital LibraryDigital Library
  46. Benjamin Pierce and Eijiro Sumii. 2000. Relating cryptography and polymorphism. Unpublished Manuscript. http://www.cis.upenn.edu/∼bcpierce/papers/infohide.ps.Google ScholarGoogle Scholar
  47. Andrew M. Pitts. 2000. Parametric polymorphism and operational equivalence. Mathematical Structures in Computer Science 10, 3, 321--359. Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. John C. Reynolds. 1983. Types, abstraction and parametric polymorphism. In Proceedings of the IFIP Congress. 513--523.Google ScholarGoogle Scholar
  49. Patrick M. Rondon, Ming Kawaguchi, and Ranjit Jhala. 2008. Liquid types. In Proceedings of the Conference on Programming Language Design and Implementation (PLDI’08). 159--169. Google ScholarGoogle ScholarDigital LibraryDigital Library
  50. Taro Sekiyama and Atsushi Igarashi. 2012. Logical Relations for a Manifest Contract Calculus, Fixed (talk abstract and slides). Available at http://hope2012.mpi-sws.org/.Google ScholarGoogle Scholar
  51. Taro Sekiyama, Yuki Nishida, and Atsushi Igarashi. 2015. Manifest contracts for datatypes. In Proceedings of the Symposium on Principles of Programming Languages (POPL’15). 195--207. Google ScholarGoogle ScholarDigital LibraryDigital Library
  52. Jeremy G. Siek and Walid Taha. 2006. Gradual typing for functional languages. In Proceedings of the Scheme and Functional Programming Workshop.Google ScholarGoogle Scholar
  53. Asumu Takikawa, T. Stephen Strickland, Christos Dimoulas, Sam Tobin-Hochstadt, and Matthias Felleisen. 2012. Gradual typing for first-class classes. In Proceedings of the Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’12). 793--810. Google ScholarGoogle ScholarDigital LibraryDigital Library
  54. Sam Tobin-Hochstadt and Matthias Felleisen. 2006. Interlanguage migration: From scripts to programs. In Proceedings of the Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’06). 964--974. Google ScholarGoogle ScholarDigital LibraryDigital Library
  55. Sam Tobin-Hochstadt and Matthias Felleisen. 2010. Logical types for untyped languages. In Proceedings of the 15th ACM SIGPLAN International Conference on Functional Programming (ICFP’10). 117--128. Google ScholarGoogle ScholarDigital LibraryDigital Library
  56. Philip Wadler. 1989. Theorems for free! In Proceedings of the Conference on Functional Programming and Computer Architecture (FPCA’89). 347--359. Google ScholarGoogle ScholarDigital LibraryDigital Library
  57. Philip Wadler and Robert Bruce Findler. 2009. Well-typed programs can’t be blamed. In Proceedings of the European Symposium on Programming (ESOP’09). 1--16. Google ScholarGoogle ScholarDigital LibraryDigital Library
  58. Andrew K. Wright and Matthias Felleisen. 1994. A syntactic approach to type soundness. Information and Computation 115, 1, 38--94. Google ScholarGoogle ScholarDigital LibraryDigital Library
  59. Hongwei Xi, Chiyan Chen, and Gang Chen. 2003. Guarded recursive datatype constructors. In Proceedings of the Symposium on Principles of Programming Languages (POPL’03). 224--235. Google ScholarGoogle ScholarDigital LibraryDigital Library
  60. Hongwei Xi and Frank Pfenning. 1999. Dependent types in practical programming. In Proceedings of the Symposium on Principles of Programming Languages (POPL’99). 214--227. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Polymorphic Manifest Contracts, Revised and Resolved

              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

              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!