Abstract
Dependent types help programmers write highly reliable code. However, this reliability comes at a cost: it can be challenging to write new prototypes in (or migrate old code to) dependently-typed programming languages. Gradual typing makes static type disciplines more flexible, so an appropriate notion of gradual dependent types could fruitfully lower this cost. However, dependent types raise unique challenges for gradual typing. Dependent typechecking involves the execution of program code, but gradually-typed code can signal runtime type errors or diverge. These runtime errors threaten the soundness guarantees that make dependent types so attractive, while divergence spoils the type-driven programming experience.
This paper presents GDTL, a gradual dependently-typed language that emphasizes pragmatic dependently-typed programming. GDTL fully embeds both an untyped and dependently-typed language, and allows for smooth transitions between the two. In addition to gradual types we introduce gradual terms, which allow the user to be imprecise in type indices and to omit proof terms; runtime checks ensure type safety. To account for nontermination and failure, we distinguish between compile-time normalization and run-time execution: compile-time normalization is approximate but total, while runtime execution is exact, but may fail or diverge. We prove that GDTL has decidable typechecking and satisfies all the expected properties of gradual languages. In particular, GDTL satisfies the static and dynamic gradual guarantees: reducing type precision preserves typedness, and altering type precision does not change program behavior outside of dynamic type failures. To prove these properties, we were led to establish a novel normalization gradual guarantee that captures the monotonicity of approximate normalization with respect to imprecision.
Supplemental Material
- Felipe Bañados Schwerter, Ronald Garcia, and Éric Tanter. 2016. Gradual Type-and-Effect Systems. Journal of Functional Programming 26 (Sept. 2016), 19:1–19:69.Google Scholar
- Yves Bertot and Pierre Castéran. 2004. Interactive Theorem Proving and Program Development. Springer-Verlag. Google Scholar
Digital Library
- Edwin Brady. 2013. Idris, a general-purpose dependently typed programming language: Design and implementation. Journal of Functional Programming 23, 5 (2013), 552–593.Google Scholar
Cross Ref
- Edwin Brady, Conor McBride, and James McKinna. 2003. Inductive Families Need Not Store Their Indices. In Types for Proofs and Programs, International Workshop, TYPES 2003, Torino, Italy, April 30 - May 4, 2003, Revised Selected Papers (Lecture Notes in Computer Science), Stefano Berardi, Mario Coppo, and Ferruccio Damiani (Eds.), Vol. 3085. Springer, 115–129.Google Scholar
- Chris Casinghino, Vilhelm Sjöberg, and Stephanie Weirich. 2014. Combining Proofs and Programs in a Dependently Typed Language. In Proceedings of the 41st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’14). ACM, New York, NY, USA, 33–45. Google Scholar
Digital Library
- Iliano Cervesato and Frank Pfenning. 2003. A Linear Spine Calculus. Journal of Logic and Computation 13, 5 (2003), 639–688.Google Scholar
Cross Ref
- Chiyan Chen and Hongwei Xi. 2005. Combining Programming with Theorem Proving. In Proceedings of the Tenth ACM SIGPLAN International Conference on Functional Programming (ICFP ’05). ACM, New York, NY, USA, 66–77. Google Scholar
Digital Library
- Adam Chlipala. 2013. Certified Programming with Dependent Types: A Pragmatic Introduction to the Coq Proof Assistant. The MIT Press. Google Scholar
Digital Library
- T. Coquand. 1986. An analysis of Girard’s paradox. Technical Report RR-0531. INRIA. https://hal.inria.fr/inria- 00076023Google Scholar
- Thierry Coquand and Gérard Huet. 1988. The calculus of constructions. Information and Computation 76, 2 (1988), 95 – 120. Google Scholar
Digital Library
- Pierre-Evariste Dagand, Nicolas Tabareau, and Éric Tanter. 2016. Partial Type Equivalences for Verified Dependent Interoperability. In Proceedings of the 21st ACM SIGPLAN Conference on Functional Programming (ICFP 2016). ACM Press, Nara, Japan, 298–310. Google Scholar
Digital Library
- Pierre-Évariste Dagand, Nicolas Tabareau, and Éric Tanter. 2018. Foundations of dependent interoperability. Journal of Functional Programming 28 (2018), e9.Google Scholar
Cross Ref
- Nachum Dershowitz and Zohar Manna. 1979. Proving termination with multiset orderings. In Automata, Languages and Programming, Hermann A. Maurer (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg, 188–202. Google Scholar
Digital Library
- Harley Eades and Aaron Stump. 2010. Hereditary substitution for stratified system F. In International Workshop on ProofSearch in Type Theories, PST T, Vol. 10.Google Scholar
- Richard A. Eisenberg. 2016. Dependent Types in Haskell: Theory and Practice. arXiv: cs.PL/1610.07978Google Scholar
- Joseph Eremondi. 2019. Github Repository: GDTL-artifact. https://github.com/JoeyEremondi/GDTL- artifact/ .Google Scholar
- Joseph Eremondi, Éric Tanter, and Ronald Garcia. 2019. Approximate Normalization for Gradual Dependent Types. arXiv: 1906.06469 Google Scholar
Digital Library
- Luminous Fennell and Peter Thiemann. 2013. Gradual Security Typing with References. In Proceedings of the 26th Computer Security Foundations Symposium (CSF). 224–239. Google Scholar
Digital Library
- Ronald Garcia, Alison M. Clark, and Éric Tanter. 2016. Abstracting Gradual Typing. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’16). ACM, New York, NY, USA, 429–442. Google Scholar
Digital Library
- Jean-Yves Girard. 1972. Interprétation fonctionelle et élimination des coupures de l’arithmétique d’ordre supérieur. Ph.D. Dissertation. PhD thesis, Université Paris VII.Google Scholar
- Ben Greenman and Matthias Felleisen. 2018. A Spectrum of Type Soundness and Performance. Proc. ACM Program. Lang. 2, ICFP, Article 71 (July 2018), 32 pages. Google Scholar
Digital Library
- Robert Harper, Furio Honsell, and Gordon Plotkin. 1993. A Framework for Defining Logics. J. ACM 40, 1 (Jan. 1993), 143–184. Google Scholar
Digital Library
- Robert Harper and Daniel R. Licata. 2007. Mechanizing metatheory in a logical framework. Journal of Functional Programming 17, 4-5 (2007), 613–673. Google Scholar
Digital Library
- Atsushi Igarashi, Peter Thiemann, Vasco T. Vasconcelos, and Philip Wadler. 2017. Gradual Session Types. Proceedings of the ACM on Programming Languages 1, ICFP (Sept. 2017), 38:1–38:28. Google Scholar
Digital Library
- Limin Jia, Jeffrey A. Vaughan, Karl Mazurak, Jianzhou Zhao, Luke Zarko, Joseph Schorr, and Steve Zdancewic. 2008. AURA: a programming language for authorization and audit. In Proceeding of the 13th ACM SIGPLAN international conference on Functional programming, ICFP 2008, Victoria, BC, Canada, September 20-28, 2008, James Hook and Peter Thiemann (Eds.). ACM, 27–38. Google Scholar
Digital Library
- Nico Lehmann and Éric Tanter. 2017. Gradual Refinement Types. In Proceedings of the 44th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 2017). ACM Press, Paris, France, 775–788. Google Scholar
Digital Library
- Andres Löh, Conor McBride, and Wouter Swierstra. 2010. A Tutorial Implementation of a Dependently Typed Lambda Calculus. Fundam. Inf. 102, 2 (April 2010), 177–207. Google Scholar
Digital Library
- Cyprien Mangin and Matthieu Sozeau. 2015. Equations for Hereditary Substitution in Leivant’s Predicative System F: A Case Study. CoRR abs/1508.00455 (2015). arXiv: 1508.00455 http://arxiv.org/abs/1508.00455Google Scholar
- Aleksandar Nanevski, Frank Pfenning, and Brigitte Pientka. 2008. Contextual Modal Type Theory. ACM Trans. Comput. Logic 9, 3, Article 23 (June 2008), 49 pages. Google Scholar
Digital Library
- Phúc C. Nguy ˜ ên, Thomas Gilray, Sam Tobin-Hochstadt, and David Van Horn. 2019. Size-change Termination As a Contract: Dynamically and Statically Enforcing Termination for Higher-order Programs. In Proceedings of the 40th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2019). ACM, New York, NY, USA, 845–859. Google Scholar
Digital Library
- Ulf Norell. 2009. Dependently Typed Programming in Agda. In Proceedings of the 4th International Workshop on Types in Language Design and Implementation (TLDI ’09). ACM, New York, NY, USA, 1–2. Google Scholar
Digital Library
- Cyrus Omar, Ian Voysey, Ravi Chugh, and Matthew A. Hammer. 2019. Live functional programming with typed holes. PACMPL 3, POPL (2019), 14:1–14:32. https://dl.acm.org/citation.cfm?id=3290327 Google Scholar
Digital Library
- Peter-Michael Osera, Vilhelm Sjöberg, and Steve Zdancewic. 2012. Dependent Interoperability. In Proceedings of the Sixth Workshop on Programming Languages Meets Program Verification (PLPV ’12). ACM, New York, NY, USA, 3–14. Google Scholar
Digital Library
- Xinming Ou, Gang Tan, Yitzhak Mandelbaum, and David Walker. 2004. Dynamic Typing with Dependent Types. In Exploring New Frontiers of Theoretical Informatics, Jean-Jacques Levy, Ernst W. Mayr, and John C. Mitchell (Eds.). Springer US, Boston, MA, 437–450.Google Scholar
- Frank Pfenning. 2008. Church and Curry: Combining intrinsic and extrinisic typing. In Reasoning in Simple Type Theory – Festschrift in Honor of Peter B. Andrews on His 70th Birthday (Studies in Logic, Mathematical Logic and Foundations), Christoph Benzmüller, Chad Brown, Jörg Siekmann, and Richard Statman (Eds.). College Publications. http://www. collegepublications.co.uk/logic/mlf/?00010Google Scholar
- Brigitte Pientka and Joshua Dunfield. 2008. Programming with Proofs and Explicit Contexts. In Proceedings of the 10th International ACM SIGPLAN Conference on Principles and Practice of Declarative Programming (PPDP ’08). ACM, New York, NY, USA, 163–173. Google Scholar
Digital Library
- Benjamin C. Pierce and David N. Turner. 2000. Local Type Inference. ACM Trans. Program. Lang. Syst. 22, 1 (Jan. 2000), 1–44. Google Scholar
Digital Library
- Ilya Sergey and Dave Clarke. 2012. Gradual Ownership Types. In Proceedings of the 21st European Symposium on Programming Languages and Systems (ESOP 2012) (Lecture Notes in Computer Science), Helmut Seidl (Ed.), Vol. 7211. Springer-Verlag, Tallinn, Estonia, 579–599. Google Scholar
Digital Library
- Tim Sheard and Nathan Linger. 2007. Programming in Omega. In Central European Functional Programming School, Second Summer School, CEFP 2007, Cluj-Napoca, Romania, June 23-30, 2007, Revised Selected Lectures (Lecture Notes in Computer Science), Zoltán Horváth, Rinus Plasmeijer, Anna Soós, and Viktória Zsók (Eds.), Vol. 5161. Springer, 158–227.Google Scholar
- Jeremy G. Siek and Walid Taha. 2006. Gradual Typing for Functional Languages. In Scheme and Functional Programming Workshop. 81–92.Google Scholar
- Jeremy G. Siek, Michael M. Vitousek, Matteo Cimini, and John Tang Boyland. 2015. Refined Criteria for Gradual Typing. In 1st Summit on Advances in Programming Languages (SNAPL 2015) (Leibniz International Proceedings in Informatics (LIPIcs)), Thomas Ball, Rastislav Bodik, Shriram Krishnamurthi, Benjamin S. Lerner, and Greg Morrisett (Eds.), Vol. 32. Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, Dagstuhl, Germany, 274–293.Google Scholar
- Jeremy G. Siek and Philip Wadler. 2010. Threesomes, with and Without Blame. In Proceedings of the 37th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’10). ACM, New York, NY, USA, 365–376. Google Scholar
Digital Library
- Aaron Stump. 2017. The calculus of dependent lambda eliminations. Journal of Functional Programming 27 (2017), e14.Google Scholar
Cross Ref
- Nikhil Swamy, Cătălin Hriţcu, Chantal Keller, Aseem Rastogi, Antoine Delignat-Lavaud, Simon Forest, Karthikeyan Bhargavan, Cédric Fournet, Pierre-Yves Strub, Markulf Kohlweiss, Jean-Karim Zinzindohoué, and Santiago Zanella-Béguelin. 2016. Dependent Types and Multi-Monadic Effects in F*. In 43rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). ACM, 256–270. https://www.fstar- lang.org/papers/mumon/ Google Scholar
Digital Library
- Matías Toro, Ronald Garcia, and Éric Tanter. 2018a. Type-Driven Gradual Security with References. ACM Transactions on Programming Languages and Systems 40, 4 (Nov. 2018), 16:1–16:55. Google Scholar
Digital Library
- Matías Toro, Elizabeth Labrada, and Éric Tanter. 2018b. Gradual Parametricity, Revisited. arXiv: cs.PL/1807.04596Google Scholar
- Michael M. Vitousek, Cameron Swords, and Jeremy G. Siek. 2017. Big Types in Little Runtime: Open-world Soundness and Collaborative Blame for Gradual Type Systems. SIGPLAN Not. 52, 1 (Jan. 2017), 762–774.Google Scholar
Digital Library
- Philip Wadler and Robert Bruce Findler. 2009. Well-Typed Programs Can’t Be Blamed. In Programming Languages and Systems, Giuseppe Castagna (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg, 1–16. Google Scholar
Digital Library
- Kevin Watkins, Iliano Cervesato, Frank Pfenning, and David Walker. 2003. A Concurrent Logical Framework I: Judgments and Properties. Technical Report CMU-CS-02-101. https://www.cs.cmu.edu/~fp/papers/CMU- CS- 02- 101.pdf .Google Scholar
- Hongwei Xi and Frank Pfenning. 1999. Dependent Types in Practical Programming. In Proceedings of the 26th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’99). ACM, New York, NY, USA, 214–227. Google Scholar
Digital Library
Index Terms
Approximate normalization for gradual dependent types
Recommendations
Gradual session types
Session types are a rich type discipline, based on linear types, that lift the sort of safety claims that come with type systems to communications. However, web-based applications and micro services are often written in a mix of languages, with type ...
Propositional equality for gradual dependently typed programming
Gradual dependent types can help with the incremental adoption of dependently typed code by providing a principled semantics for imprecise types and proofs, where some parts have been omitted. Current theories of gradual dependent types, though, lack ...
Normalization by evaluation for sized dependent types
Sized types have been developed to make termination checking more perspicuous, more powerful, and more modular by integrating termination into type checking. In dependently-typed proof assistants where proofs by induction are just recursive functional ...






Comments