Hostname: page-component-8448b6f56d-sxzjt Total loading time: 0 Render date: 2024-04-24T23:28:29.763Z Has data issue: false hasContentIssue false

Parametricity, type equality, and higher-order polymorphism

Published online by Cambridge University Press:  15 April 2010

DIMITRIOS VYTINIOTIS
Affiliation:
Microsoft Research Cambridge, 7 JJ Thomson Avenue, Cambridge CB3 0FBUK (e-mail: dimitris@microsoft.com)
STEPHANIE WEIRICH
Affiliation:
University of Pennsylvania, Department of Computer and Information Science, Levine Hall, 3330 Walnut St., Philadelphia PA 19104–6389, USA (e-mail: sweirich@cis.upenn.edu)
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

Propositions that express type equality are a frequent ingredient of modern functional programming – they can encode generic functions, dynamic types, and GADTs. Via the Curry–Howard correspondence, these propositions are ordinary types inhabited by proof terms, computed using runtime type representations. In this paper we show that two examples of type equality propositions actually do reflect type equality; they are only inhabited when their arguments are equal and their proofs are unique (up to equivalence.) We show this result in the context of a strongly normalizing language with higher-order polymorphism and primitive recursion over runtime-type representations by proving Reynolds's abstraction theorem. We then use this theorem to derive “free” theorems about equality types.

Type
Articles
Copyright
Copyright © Cambridge University Press 2010

References

Ahmed, A. J. (2006) Step-indexed syntactic logical relations for recursive and quantified types. In Proceedings of ESOP. Springer, pp. 6983.Google Scholar
Appel, A. W. & McAllester, D. (2001) An indexed model of recursive types for foundational proof-carrying code, ACM Trans. Program. Lang. Syst., 23 (5): 657683.CrossRefGoogle Scholar
Baars, A. I. & Swierstra, S. D. (2002) Typing dynamic typing. In ICFP '02: Proceedings of the 7th ACM SIGPLAN International Conference on Functional Programming. ACM, pp. 157166.CrossRefGoogle Scholar
Chen, C., Zhu, D. & Xi, H. (2004) Implementing cut elimination: A case study of simulating dependent types in Haskell. In Proceedings of the 6th International Symposium on Practical Aspects of Declarative Languages, Lecture Notes in Computer Science, vol. 3057. Springer-Verlag, pp. 239254.CrossRefGoogle Scholar
Cheney, J. & Hinze, R. (2002) A lightweight implementation of generics and dynamics. In Haskell '02: Proceedings of the 2002 ACM SIGPLAN Workshop on Haskell. ACM, pp. 90104.CrossRefGoogle Scholar
Cheney, J. & Hinze, R. (2003) In First-Class Phantom Types. CUCIS TR2003-1901. Cornell University.Google Scholar
Crary, K. & Harper, R. (2007) Syntactic logical relations for polymorphic and recursive types, Electr. Notes Theor. Comput. Sci., 172: 259299. Computation, Meaning, and Logic: Articles dedicated to Gordon Plotkin.CrossRefGoogle Scholar
Crary, K., Weirich, S. & Morrisett, G. (2002) Intensional polymorphism in type erasure semantics. J. Funct. Program., 12 (6): 567600.CrossRefGoogle Scholar
Crole, R. (1994) Categories for Types. Cambridge University Press.CrossRefGoogle Scholar
Danielsson, N. A., Hughes, J., Jansson, P. & Gibbons, J. (2006) Fast and loose reasoning is morally correct. In POPL '06: Conference record of the 33rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, vol. 41, ACM, pp. 206217.CrossRefGoogle Scholar
Gallier, J. H. (1990) On Girard's “Candidats de Reductibilité”. In Logic and Computer Science, Odifreddi, P. (ed.), The APIC Series 31. Academic Press, pp. 123203.Google Scholar
Girard, J.-Y. (1972) Interprétation fonctionelle et é limination des coupures de l'arithmétique d'ordre Supérieur. PhD thesis, Université Paris VII.Google Scholar
Harper, R. & Mitchell, J. C. (1999) Parametricity and variants of Girard's J operator, Inf. Process. Lett., 70 (1): 15.CrossRefGoogle Scholar
Harper, R. & Morrisett, G. (1995) Compiling polymorphism using intensional type analysis. In Twenty-Second ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. ACM, pp. 130141.Google Scholar
Harper, R. & Pfenning, F. (2005) On equivalence and canonical forms in the LF type theory, ACM Trans. Comput. Logic, 6 (1): 61101.CrossRefGoogle Scholar
Hinze, R. (2002) Polytypic values possess polykinded types, Sci. Comput. Program., 43 (2–3): 129159. MPC Special Issue.CrossRefGoogle Scholar
Johann, P. & Ghani, N. (2008) Foundations for structured programming with gadts. In POPL, Necula, G. C. & Wadler, P. (eds), ACM, pp. 297308.CrossRefGoogle Scholar
Johann, P. & Voigtländer, J. (2004) Free theorems in the presence of seq. In POPL '04: Proceedings of the 31st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. ACM, pp. 99110.CrossRefGoogle Scholar
Jones, S. P., Vytiniotis, D., Weirich, S. & Washburn, G. (2006) Simple unification-based type inference for GADTs. In ICFP '06: Proceedings of the Eleventh ACM SIGPLAN International Conference on Functional Programming. ACM, pp. 5061.CrossRefGoogle Scholar
Kiselyov, O., Lämmel, R. & Schupke, K. (2004) Strongly typed heterogeneous collections. In Haskell '04: Proceedings of the ACM SIGPLAN workshop on Haskell. ACM, pp. 96107.CrossRefGoogle Scholar
Kleene, S. C. (1967) Mathematical Logic. Wiley.Google Scholar
Kučan, J. (1997) Metatheorems about Convertibility in Typed Lambda Calculi: Applications to CPS Transform and Free Theorems. PhD thesis, Massachusetts Institute of Technology.Google Scholar
Meijer, E. & Hutton, G. (1995) Bananas in space: Extending fold and unfold to exponential types. In FPCA95: Conference on Functional Programming Languages and Computer Architecture. ACM, pp. 324333.Google Scholar
Melliès, P.-A. & Vouillon, J. (2005) Recursive polymorphic types and parametricity in an operational framework. In LICS '05: Proceedings of the 20th Annual IEEE Symposium on Logic in Computer Science (LICS' 05). IEEE Computer Society, pp. 8291.CrossRefGoogle Scholar
Neis, G., Dreyer, D. & Rossberg, A. (2009) Non-parametric parametricity. In ICFP '09: Proceedings of the 14th ACM SIGPLAN International Conference on Functional Programming. ACM, pp. 135148.CrossRefGoogle Scholar
Paulin-Mohring, C. (1993) Inductive definitions in the system Coq: Rules and properties. In International Conference on Typed Lambda Calculi and Applications, TLCA '93, Lecture Notes in Computer Science, vol. 664. Springer, pp. 328345.CrossRefGoogle Scholar
Pitts, A. M. (2000) Parametric polymorphism and operational equivalence, Math. Struct. Comput. Sci., 10: 321359.CrossRefGoogle Scholar
Pitts, A. M. (2005) Typed operational reasoning., In Chap. 7 of: Advanced Topics in Types and Programming Languages, Pierce, B. C. (ed), MIT Press, pp. 245289.Google Scholar
Plotkin, G. & Abadi, M. (1993) A logic for parametric polymorphism. In International Conference on Typed Lambda Calculi and Applications. Springer-Verlag, pp. 361375.CrossRefGoogle Scholar
Reynolds, J. C. (1983) Types, abstraction and parametric polymorphism. In Information Processing '83. Proceedings of the IFIP 9th World Computer Congress. North-Holland, pp. 513523.Google Scholar
Sheard, T. & Pasalic, E. (2004) Meta-programming with built-in type equality. In Proc 4th International Workshop on Logical Frameworks and Meta-languages (LFM'04), Cork. pp. 106–124.Google Scholar
Spławski, Z. & Urzyczyn, P. (1999) Type fixpoints: Iteration versus recursion. Fourth ACM SIGPLAN International Conference on Functional Programming. ACM, pp. 102113.CrossRefGoogle Scholar
Takeuti, I. (2001) The Theory of Parametricity in Lambda Cube (Towards new interaction between category theory and proof theory). Technical Report. Kyoto University Research Information Repository.Google Scholar
Voigtländer, J. (2009) Free theorems involving type constructor classes: functional pearl. In ICFP '09: Proceedings of the 14th ACM SIGPLAN International Conference on Functional Programming. ACM, pp. 173184.CrossRefGoogle Scholar
Vytiniotis, D. & Weirich, S. (2007) Free theorems and runtime type representations, Electron. Notes Theor. Comput. Sci., 173: 357373.CrossRefGoogle Scholar
Wadler, P. (1989) Theorems for free! In FPCA89: Conference on Functional Programming Languages and Computer Architecture. ACM, pp. 347359.Google Scholar
Washburn, G. & Weirich, S. (2005) Generalizing parametricity using information flow. In The Twentieth Annual IEEE Symposium on Logic in Computer Science (LICS 2005). Chicago, IL: IEEE Computer Society Press, pp. 6271.Google Scholar
Weirich, S. (2001) Encoding intensional type analysis. In 10th European Symposium on Programming, Sands, D. (ed), pp. 92–106.CrossRefGoogle Scholar
Weirich, S. (2004) Type-safe cast, J. Funct. Program. 14 (6): 681695.CrossRefGoogle Scholar
Xi, H., Chen, C. & Chen, G. (2003) Guarded recursive datatype constructors. In POPL. ACM, pp. 224235.CrossRefGoogle Scholar
Yang, Z. (1998) Encoding types in ML-like languages. In 1998 ACM SIGPLAN International Conference on Functional Programming. ACM SIGPLAN Notices 34, pp. 289–300.CrossRefGoogle Scholar
Submit a response

Discussions

No Discussions have been published for this article.