Abstract
System F, also known as the polymorphic \(\lambda \)-calculus, is a typed \(\lambda \)-calculus independently discovered by the logician Jean-Yves Girard and the computer scientist John Reynolds. We consider \(F_{\omega \mu }\), which adds higher-order kinds and iso-recursive types. We present the first complete, intrinsically typed, executable, formalisation of System \(F_{\omega \mu }\) that we are aware of. The work is motivated by verifying the core language of a smart contract system based on System \(F_{\omega \mu }\). The paper is a literate Agda script [14].
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
Notes
- 1.
The code in this paper is typeset in .
- 2.
We thank an anonymous reviewer for bringing this to our attention.
References
Abadi, M., Cardelli, L., Plotkin, G.: Types for the Scott numerals (1993)
Allais, G., Chapman, J., McBride, C., McKinna, J.: Type-and-scope safe programs and their proofs. In: Bertot, Y., Vafeiadis, V. (eds.) Proceedings of the 6th ACM SIGPLAN Conference on Certified Programs and Proofs (CPP 2017), pp. 195–207. ACM, New York (2017). https://doi.org/10.1145/3018610.3018613
Allais, G., McBride, C., Boutillier, P.: New equations for neutral terms. In: Weirich, S. (ed.) Proceedings of the 2013 ACM SIGPLAN Workshop on Dependently-typed Programming (DTP 2013), pp. 13–24. ACM, New York (2013). https://doi.org/10.1145/2502409.2502411
Altenkirch, T., Chapman, J., Uustalu, T.: Relative monads formalised. J. Formalized Reasoning 7(1), 1–43 (2014). https://doi.org/10.6092/issn.1972-5787/4389
Altenkirch, T., Chapman, J., Uustalu, T.: Monads need not be endofunctors. Logical Methods Comput. Sci. 11(1), 1–40 (2015). https://doi.org/10.2168/LMCS-11(1:3)2015
Altenkirch, T., Reus, B.: Monadic presentations of lambda terms using generalized inductive types. In: Flum, J., Rodriguez-Artalejo, M. (eds.) CSL 1999. LNCS, vol. 1683, pp. 453–468. Springer, Heidelberg (1999). https://doi.org/10.1007/3-540-48168-0_32
Amani, S., Bégel, M., Bortin, M., Staples, M.: Towards verifying ethereum smart contract bytecode in isabelle/HOL. In: Andronick, J., Felty, A. (eds.) Proceedings of the 7th ACM SIGPLAN International Conference on Certified Programs and Proofs (CPP 2018), pp. 66–77. ACM, New York (2018). https://doi.org/10.1145/3167084
Aydemir, B.E., et al.: Mechanized metatheory for the masses: the PoplMark challenge. In: Hurd, J., Melham, T. (eds.) TPHOLs 2005. LNCS, vol. 3603, pp. 50–65. Springer, Heidelberg (2005). https://doi.org/10.1007/11541868_4
Berger, U., Schwichtenberg, H.: An inverse of the evaluation functional for typed lambda-calculus. In: Kahn, G. (ed.) Proceedings of the Sixth Annual Symposium on Logic in Computer Science (LICS 1991), pp. 203–211. IEEE Computer Society Press (1991). https://doi.org/10.1109/LICS.1991.151645
Brown, M., Palsberg, J.: Breaking through the normalization barrier: a self-interpreter for F-omega. In: Majumdar, R. (ed.) Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2016, pp. 5–17. ACM, New York (2016). https://doi.org/10.1145/2837614.2837623
Cai, Y., Giarrusso, P.G., Ostermann, K.: System F-omega with equirecursive types for datatype-generic programming. In: Majumdar, R. (ed.) Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 2016), pp. 30–43. ACM, New York (2016). https://doi.org/10.1145/2837614.2837660
Chakravarty, M., et al.: Functional Blockchain Contracts. Technical report, IOHK (2019). https://iohk.io/research/papers/#KQL88VAR
Chapman, J.: Type checking and normalisation. Ph.D. thesis, University of Nottingham, UK (2009). http://eprints.nottingham.ac.uk/10824/
Chapman, J., Kireev, R., Nester, C., Wadler, P.: Literate Agda source of MPC 2019 paper (2019). https://github.com/input-output-hk/plutus/blob/f9f7aef94d9614b67c037337079ad89329889ffa/papers/system-f-in-agda/paper.lagda
Coquand, C.: A formalised proof of the soundness and completeness of a simply typed lambda-calculus with explicit substitutions. High. Order Symbolic Comput. 15(1), 57–90 (2002). https://doi.org/10.1023/A:1019964114625
Danielsson, N.A.: A formalisation of a dependently typed language as an inductive-recursive family. In: Altenkirch, T., McBride, C. (eds.) TYPES 2006. LNCS, vol. 4502, pp. 93–109. Springer, Heidelberg (2007). https://doi.org/10.1007/978-3-540-74464-1_7
van Doorn, F., Geuvers, H., Wiedijk, F.: Explicit convertibility proofs in pure type systems. In: Proceedings of the Eighth ACM SIGPLAN International Workshop on Logical Frameworks & Meta-languages: Theory & Practice, (LFMTP 2013), pp. 25–36. ACM, New York (2013). https://doi.org/10.1145/2503887.2503890
Dreyer, D.: Understanding and Evolving the ML Module System. Ph.D. thesis, Carnegie Mellon University (2005)
Dreyer, D.: A type system for recursive modules. In: Ramsey, N. (ed.) Proceedings of the 12th ACM SIGPLAN International Conference on Functional Programming (ICFP 2007), pp. 289–302. ACM, New York (2007). https://doi.org/10.1145/1291220.1291196
Dybjer, P.: A general formulation of simultaneous inductive-recursive definitions in type theory. J. Symbolic Logic 65(2), 525–549 (2000). http://www.jstor.org/stable/2586554
Grishchenko, I., Maffei, M., Schneidewind, C.: A semantic framework for the security analysis of ethereum smart contracts. In: Bauer, L., Küsters, R. (eds.) POST 2018. LNCS, vol. 10804, pp. 243–269. Springer, Cham (2018). https://doi.org/10.1007/978-3-319-89722-6_10
Harz, D., Knottenbelt, W.J.: Towards Safer Smart Contracts: A Survey of Languages and Verification Methods (2018). https://arxiv.org/abs/1809.09805
Hindley, J.R., Seldin, J.P.: Lambda-Calculus and Combinators: An Introduction. Cambridge University Press, Cambridge (2008)
Hirai, Y.: Defining the ethereum virtual machine for interactive theorem provers. In: Brenner, M., et al. (eds.) FC 2017. LNCS, vol. 10323, pp. 520–535. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-70278-0_33
Jung, A., Tiuryn, J.: A new characterization of lambda definability. In: Bezem, M., Groote, J.F. (eds.) TLCA 1993. LNCS, vol. 664, pp. 245–257. Springer, Heidelberg (1993). https://doi.org/10.1007/BFb0037110
Peyton Jones, M., Gkoumas, V., Kireev, R., MacKenzie, K., Nester, C., Wadler, P.: Unraveling recursion: compiling an IR with recursion to system F. In: Hutton, G. (ed.) MPC 2019. LNCS, vol. 11825, pp. 414–443. Springer, Cham (2019). https://doi.org/10.1007/978-3-030-33636-3_15
Kovács, A.: System F Omega. https://github.com/AndrasKovacs/system-f-omega
Martens, C., Crary, K.: LF in LF: mechanizing the metatheories of LF in Twelf. In: Proceedings of the Seventh International Workshop on Logical Frameworks and Meta-languages, Theory and Practice (LFMTP 2012), pp. 23–32. ACM, New York (2012). https://doi.org/10.1145/2364406.2364410
McBride, C.: Datatypes of datatypes. In: Summer School on Generic and Effectful Programming, St Anne’s College, Oxford (2015). https://www.cs.ox.ac.uk/projects/utgp/school/conor.pdf
Nomadic Labs: Michelson in Coq. Git Repository. https://gitlab.com/nomadic-labs/mi-cho-coq/
O’Connor, R.: Simplicity: a new language for blockchains. In: Bielova, N., Gaboardi, M. (eds.) Proceedings of the 2017 Workshop on Programming Languages and Analysis for Security (PLAS 2017), pp. 107–120. ACM, New York (2017). https://doi.org/10.1145/3139337.3139340
Park, D., Zhang, Y., Saxena, M., Daian, P., Roşu, G.: A formal verification tool for ethereum VM bytecode. In: Garcia, A., Pasareanu, C.S. (eds.) Proceedings of the 2018 26th ACM Join Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering (ESEC/FSE 2018), pp. 912–915. ACM, New York (2018). https://doi.org/10.1145/3236024.3264591
Pierce, B.C.: Types and Programming Languages. MIT Press, Cambridge (2002)
Pollack, R., Poll, E.: Typechecking in pure type systems. In: Informal Proceedings of Logical Frameworks 1992, pp. 271–288 (1992)
Reynolds, J.C.: What do types mean? - from intrinsic to extrinsic semantics. In: McIver, A., Morgan, C. (eds.) Programming Methodology. Monographs in Computer Science, pp. 309–327. Springer, New York (2003). https://doi.org/10.1007/978-0-387-21798-7_15
Wadler, P.: Programming language foundations in agda. In: Massoni, T., Mousavi, M.R. (eds.) SBMF 2018. LNCS, vol. 11254, pp. 56–73. Springer, Cham (2018). https://doi.org/10.1007/978-3-030-03044-5_5
Wadler, P., Kokke, W.: Programming Language Foundations in Agda. https://plfa.github.io/
Watkins, K., Cervesato, I., Pfenning, F., Walker, D.: Specifying properties of concurrent computations in CLF. In: Schürmann, C. (ed.) Proceedings of the Fourth International Workshop on Logical Frameworks and Meta-Languages (LFM 2004). ENTCS, vol. 199, pp. 67–87 (2008). https://doi.org/10.1016/j.entcs.2007.11.013
Acknowledgements
We thank the anonymous reviewers for their helpful comments and insightful constructive criticism. We thank IOHK for their support of this work. We thank our colleagues Marko Dimjaević, Kenneth MacKenzie, and Michael Peyton Jones for helpful comments on an multiple drafts. The first author would like to James McKinna for spending an afternoon explaining pure type systems and Guillaume Allais, Apostolis Xekoukoulotakis and Ulf Norell for help with diagnosing and fixing bugs that we encountered in Agda’s GHC backend in the course of writing this paper.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2019 Springer Nature Switzerland AG
About this paper
Cite this paper
Chapman, J., Kireev, R., Nester, C., Wadler, P. (2019). System F in Agda, for Fun and Profit. In: Hutton, G. (eds) Mathematics of Program Construction. MPC 2019. Lecture Notes in Computer Science(), vol 11825. Springer, Cham. https://doi.org/10.1007/978-3-030-33636-3_10
Download citation
DOI: https://doi.org/10.1007/978-3-030-33636-3_10
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-33635-6
Online ISBN: 978-3-030-33636-3
eBook Packages: Computer ScienceComputer Science (R0)