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.
Supplemental Material
Available for Download
Supplemental movie, appendix, image and software files for, Polymorphic Manifest Contracts, Revised and Resolved
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Luca Cardelli. 1986. A Polymorphic λ-Calculus with Type:Type. Technical Report 10. DEC Systems Research Center, Palo Alto, CA.Google Scholar
- James Cheney and Ralf Hinze. 2003. First-Class Phantom Types. Technical Report. Cornell University, Ithaca, NY.Google Scholar
- 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 Scholar
Digital Library
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Cormac Flanagan. 2006. Hybrid type checking. In Proceedings of the Symposium on Principles of Programming Languages (POPL’06). 245--256. Google Scholar
Digital Library
- Matthew Flatt and PLT. 2010. Reference: Racket. Technical Report PLT-TR-2010-1. PLT Design. http://racket-lang.org/tr1/.Google Scholar
- 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 Scholar
Digital Library
- Michael Greenberg. 2013. Manifest Contracts. Ph.D. Dissertation. University of Pennsylvania, Philadelphia, PA. Google Scholar
Digital Library
- Michael Greenberg. 2015a. Combining Manifest Contracts with State. Retrieved January 18, 2017, from http://www.cs.pomona.edu/∼michael/papers/hope2015.pdf.Google Scholar
- Michael Greenberg. 2015b. Space-efficient manifest contracts. In Proceedings of the Symposium on Principles of Programming Languages (POPL’15). 181--194. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- 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 Scholar
- Dan Grossman, Greg Morrisett, and Steve Zdancewic. 2000. Syntactic type abstraction. ACM Transactions on Programming Languages and Systems 22, 6, 1037--1080. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- Robert Harper, Furio Honsell, and Gordon Plotkin. 1993. A framework for defining logics. Journal of the 40, 1, 143--184. Google Scholar
Digital Library
- Fritz Henglein. 1992. Dynamic typing. In Proceedings of the European Symposium on Programming (ESOP’92). 233--253. Google Scholar
Digital Library
- David Herman, Aaron Tomb, and Cormac Flanagan. 2010. Space-efficient gradual typing. Higher-Order and Symbolic Computation 23, 2, 167--189. Google Scholar
Digital Library
- C. A. R. Hoare. 1969. An axiomatic basis for computer programming. Communications of the ACM 12, 10, 576--580. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Kenneth Knowles. 2014. Executable Refinement Types. Ph.D. Dissertation. University of California, Santa Cruz.Google Scholar
- 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 Scholar
Digital Library
- Kenneth Knowles and Cormac Flanagan. 2010. Hybrid type checking. ACM Transactions on Programming Languages and Systems 32, 2, 6:1--6:34. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- James H. Morris Jr. 1973. Types are not sets. In Proceedings of the Symposium on Principles of Programming Languages (POPL’73). 120--124. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- Benjamin Pierce and Eijiro Sumii. 2000. Relating cryptography and polymorphism. Unpublished Manuscript. http://www.cis.upenn.edu/∼bcpierce/papers/infohide.ps.Google Scholar
- Andrew M. Pitts. 2000. Parametric polymorphism and operational equivalence. Mathematical Structures in Computer Science 10, 3, 321--359. Google Scholar
Digital Library
- John C. Reynolds. 1983. Types, abstraction and parametric polymorphism. In Proceedings of the IFIP Congress. 513--523.Google Scholar
- 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 Scholar
Digital Library
- 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 Scholar
- 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 Scholar
Digital Library
- Jeremy G. Siek and Walid Taha. 2006. Gradual typing for functional languages. In Proceedings of the Scheme and Functional Programming Workshop.Google Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Philip Wadler. 1989. Theorems for free! In Proceedings of the Conference on Functional Programming and Computer Architecture (FPCA’89). 347--359. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- Andrew K. Wright and Matthias Felleisen. 1994. A syntactic approach to type soundness. Information and Computation 115, 1, 38--94. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
Index Terms
Polymorphic Manifest Contracts, Revised and Resolved
Recommendations
Contracts made manifest
POPL '10: Proceedings of the 37th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languagesSince Findler and Felleisen introduced higher-order contracts , many variants have been proposed. Broadly, these fall into two groups: some follow Findler and Felleisen in using latent contracts, purely dynamic checks that are transparent to the type ...
Polymorphic contracts
ESOP'11/ETAPS'11: Proceedings of the 20th European conference on Programming languages and systems: part of the joint European conferences on theory and practice of softwareManifest contracts track precise properties by refining types with predicates--e.g., {x:Int | x > 0} denotes the positive integers. Contracts and polymorphism make a natural combination: programmers can give strong contracts to abstract types, precisely ...
Stateful manifest contracts
POPL '17: Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming LanguagesThis paper studies hybrid contract verification for an imperative higher-order language based on a so-called manifest contract system. In manifest contract systems, contracts are part of static types and contract verification is hybrid in the sense that ...






Comments