Advertisement

Programming Language Foundations in Agda

  • Philip WadlerEmail author
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 11254)

Abstract

One of the leading textbooks for formal methods is Software Foundations (SF), written by Benjamin Pierce in collaboration with others, and based on Coq. After five years using SF in the classroom, I have come to the conclusion that Coq is not the best vehicle for this purpose, as too much of the course needs to focus on learning tactics for proof derivation, to the cost of learning programming language theory. Accordingly, I have written a new textbook, Programming Language Foundations in Agda (PLFA). PLFA covers much of the same ground as SF, although it is not a slavish imitation.

What did I learn from writing PLFA? First, that it is possible. One might expect that without proof tactics that the proofs become too long, but in fact proofs in PLFA are about the same length as those in SF. Proofs in Coq require an interactive environment to be understood, while proofs in Agda can be read on the page. Second, that constructive proofs of preservation and progress give immediate rise to a prototype evaluator. This fact is obvious in retrospect but it is not exploited in SF (which instead provides a separate normalise tactic) nor can I find it in the literature. Third, that using raw terms with a separate typing relation is far less perspicuous than using inherently-typed terms. SF uses the former presentation, while PLFA presents both; the former uses about 1.6 as many lines of Agda code as the latter, roughly the golden ratio.

The textbook is written as a literate Agda script, and can be found here: http://plfa.inf.ed.ac.uk.

Keywords

Agda Coq Lambda calculus Dependent types 

Notes

Acknowledgement

A special thank you to my coauthor, Wen Kokke. For inventing ideas on which PLFA is based, and for hand-holding, many thanks to Conor McBride, James McKinna, Ulf Norell, and Andreas Abel. For showing me how much more compact it is to avoid raw terms, thanks to David Darais. For inspiring my work by writing SF, thanks to Benjamin Pierce and his coauthors. For comments on a draft of this paper, an extra thank you to James McKinna, Ulf Norell, Andreas Abel, and Benjamin Pierce. This research was supported by EPSRC Programme Grant EP/K034413/1.

References

  1. Allais, G., Chapman, J., McBride, C., McKinna, J.: Type-and-scope safe programs and their proofs. In: Proceedings of the 6th ACM SIGPLAN Conference on Certified Programs and Proofs, pp. 195–207. ACM (2017)Google Scholar
  2. 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_32CrossRefGoogle Scholar
  3. Berger, U.: Program extraction from normalization proofs. In: Bezem, M., Groote, J.F. (eds.) TLCA 1993. LNCS, vol. 664, pp. 91–106. Springer, Heidelberg (1993).  https://doi.org/10.1007/BFb0037100CrossRefGoogle Scholar
  4. Bove, A., Capretta, V.: Nested general recursion and partiality in type theory. In: Boulton, R.J., Jackson, P.B. (eds.) TPHOLs 2001. LNCS, vol. 2152, pp. 121–125. Springer, Heidelberg (2001).  https://doi.org/10.1007/3-540-44755-5_10CrossRefzbMATHGoogle Scholar
  5. Bove, A., Dybjer, P., Norell, U.: A brief overview of agda – a functional language with dependent types. In: Berghofer, S., Nipkow, T., Urban, C., Wenzel, M. (eds.) TPHOLs 2009. LNCS, vol. 5674, pp. 73–78. Springer, Heidelberg (2009).  https://doi.org/10.1007/978-3-642-03359-9_6CrossRefGoogle Scholar
  6. Capretta, V.: General recursion via coinductive types. Log. Methods Comput. Sci. 1(2:1), 1–28 (2005)Google Scholar
  7. Chapman, J.M.: Type checking and normalisation. PhD thesis, University of Nottingham (2009)Google Scholar
  8. Dagand, P.-É., Scherer, G.: Normalization by realizability also evaluates. In: Vingt-sixièmes Journées Francophones des Langages Applicatifs (JFLA 2015) (2015)Google Scholar
  9. Danas, N., Nelson, T., Harrison, L., Krishnamurthi, S., Dougherty, D.J.: User studies of principled model finder output. In: Cimatti, A., Sirjani, M. (eds.) SEFM 2017. LNCS, vol. 10469, pp. 168–184. Springer, Cham (2017).  https://doi.org/10.1007/978-3-319-66197-1_11CrossRefGoogle Scholar
  10. Felleisen, M., Findler, R.B., Flatt, M.: Semantics engineering with PLT Redex. By Press (2009)Google Scholar
  11. Goguen, H., McKinna, J.: Candidates for substitution. Technical report, Laboratory for Foundations of Computer Science, University of Edinburgh (1997)Google Scholar
  12. Gonthier, G.: The four colour theorem: engineering of a formal proof. In: Kapur, D. (ed.) ASCM 2007. LNCS (LNAI), vol. 5081, pp. 333–333. Springer, Heidelberg (2008).  https://doi.org/10.1007/978-3-540-87827-8_28CrossRefGoogle Scholar
  13. Gonthier, G., et al.: A machine-checked proof of the odd order theorem. In: Blazy, S., Paulin-Mohring, C., Pichardie, D. (eds.) ITP 2013. LNCS, vol. 7998, pp. 163–179. Springer, Heidelberg (2013).  https://doi.org/10.1007/978-3-642-39634-2_14CrossRefGoogle Scholar
  14. Hales, T., et al.: A formal proof of the Kepler conjecture. In: Forum of Mathematics, Pi, vol. 5. Cambridge University Press (2017)Google Scholar
  15. Harper, R.: Practical Foundations for Programming Languages. Cambridge University Press (2016)Google Scholar
  16. Huet, G., Kahn, G., Paulin-Mohring, C.: The Coq proof assistant a tutorial. Rapport Technique, 178 (1997)Google Scholar
  17. Kästner, D., Leroy, X., Blazy, S., Schommer, B., Schmidt, M., Ferdinand, C.: Closing the gap-the formally verified optimizing compiler compcert. In: SSS 2017: Safety-critical Systems Symposium 2017, pp. 163–180. CreateSpace (2017)Google Scholar
  18. Kiselyov, O.: Formalizing languages, mechanizing type-soundess and other meta-theoretic proofs (2009, unpublished manuscript). http://okmij.org/ftp/formalizations/index.html
  19. Klein, G., et al.: sel4: formal verification of an OS kernel. In: Proceedings of the ACM SIGOPS 22nd Symposium on Operating Systems Principles, pp. 207–220. ACM (2009)Google Scholar
  20. Leroy, X.: Formal verification of a realistic compiler. Commun. ACM 52(7), 107–115 (2009)CrossRefGoogle Scholar
  21. McBride, C.: Type-preserving renaming and substitution (2005, unpublished manuscript). https://personal.cis.strath.ac.uk/conor.mcbride/ren-sub.pdf
  22. McBride, C.: Turing-completeness totally free. In: Hinze, R., Voigtländer, J. (eds.) MPC 2015. LNCS, vol. 9129, pp. 257–275. Springer, Cham (2015).  https://doi.org/10.1007/978-3-319-19797-5_13CrossRefGoogle Scholar
  23. O’Connor, L., et al.: Refinement through restraint: Bringing down the cost of verification. In: ICFP, pp. 89–102 (2016)Google Scholar
  24. Pierce, B.C.: Types and Programming Languages. MIT press (2002)Google Scholar
  25. Pierce, B.C.: Lambda, the ultimate TA. In: ICFP, pp. 121–122 (2009)Google Scholar
  26. Pierce, B.C.: Software foundations (2010). http://www.cis.upenn.edu/bcpierce/sf/current/index.html
  27. Plotkin, G.D.: LCF considered as a programming language. Theoret. Comput. Sci. 5(3), 223–255 (1977)MathSciNetCrossRefGoogle Scholar
  28. Roşu, G., Şerbănuţă, T.F.: An overview of the K semantic framework. J. Log. Algebr. Program. 79(6), 397–434 (2010)MathSciNetCrossRefGoogle Scholar
  29. Stump, A.: Verified Functional Programming in Agda. Morgan & Claypool (2016)Google Scholar
  30. Wright, A.K., Felleisen, M.: A syntactic approach to type soundness. Inf. Comput. 115(1), 38–94 (1994)MathSciNetCrossRefGoogle Scholar

Copyright information

© Springer Nature Switzerland AG 2018

Authors and Affiliations

  1. 1.University of EdinburghEdinburghUK

Personalised recommendations