skip to main content

A reasonably gradual type theory

Published:31 August 2022Publication History
Skip Abstract Section

Abstract

Gradualizing the Calculus of Inductive Constructions (CIC) involves dealing with subtle tensions between normalization, graduality, and conservativity with respect to CIC. Recently, GCIC has been proposed as a parametrized gradual type theory that admits three variants, each sacrificing one of these properties. For devising a gradual proof assistant based on CIC, normalization and conservativity with respect to CIC are key, but the tension with graduality needs to be addressed. Additionally, several challenges remain: (1) The presence of two wildcard terms at any type---the error and unknown terms---enables trivial proofs of any theorem, jeopardizing the use of a gradual type theory in a proof assistant; (2) Supporting general indexed inductive families, most prominently equality, is an open problem; (3) Theoretical accounts of gradual typing and graduality so far do not support handling type mismatches detected during reduction; (4) Precision and graduality are external notions not amenable to reasoning within a gradual type theory. All these issues manifest primally in CastCIC, the cast calculus used to define GCIC. In this work, we present an extension of CastCIC called GRIP. GRIP is a reasonably gradual type theory that addresses the issues above, featuring internal precision and general exception handling. By adopting a novel interpretation of the unknown term that carefully accounts for universe levels, GRIP satisfies graduality for a large and well-defined class of terms, in addition to being normalizing and a conservative extension of CIC. Internal precision supports reasoning about graduality within GRIP itself, for instance to characterize gradual exception-handling terms, and supports gradual subset types. We develop the metatheory of GRIP using a model formalized in Coq, and provide a prototype implementation of GRIP in Agda.

References

  1. Andreas Abel and Gabriel Scherer. 2012. On Irrelevance and Algorithmic Equality in Predicative Type Theory. Logical Methods in Computer Science, Volume 8, Issue 1 (2012), 3, https://doi.org/10.2168/LMCS-8(1:29)2012 Google ScholarGoogle ScholarCross RefCross Ref
  2. Thorsten Altenkirch, Neil Ghani, Peter G. Hancock, Conor McBride, and Peter Morris. 2015. Indexed containers. J. Funct. Program., 25 (2015), https://doi.org/10.1017/S095679681500009X Google ScholarGoogle Scholar
  3. Thorsten Altenkirch, Conor McBride, and Wouter Swierstra. 2007. Observational equality, now!. In Proceedings of the Workshop on Programming Languages meets Program Verification (PLPV 2007). 57–68. https://doi.org/10.1145/1292597.1292608 Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Jean-Philippe Bernardy, Patrik Jansson, and Ross Paterson. 2012. Proofs for free: Parametricity for dependent types. Journal of Functional Programming, 22, 2 (2012), March, 107–152. https://doi.org/10.1017/S0956796812000056 Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. 2016. Proceedings of the 43rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 2016), Rastislav Bodík and Rupak Majumdar (Eds.). ACM Press, St Petersburg, FL, USA. isbn:978-1-4503-3549-2 https://doi.org/10.1145/2837614 Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Simon Boulier, Pierre-Marie Pédrot, and Nicolas Tabareau. 2017. The next 700 syntactical models of type theory. In Proceedings of the 6th ACM SIGPLAN Conference on Certified Programs and Proofs, CPP 2017, Paris, France, January 16-17, 2017. 182–194. https://doi.org/10.1145/3018610.3018620 Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. 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 2014). ACM Press, San Diego, CA, USA. 671–684. isbn:978-1-4503-2544-8 https://doi.org/10.1145/2535838.2535883 Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Cyril Cohen, Thierry Coquand, Simon Huber, and Anders Mörtberg. 2017. Cubical Type Theory: A Constructive Interpretation of the Univalence Axiom. FLAP, 4, 10 (2017), 3127–3170. http://collegepublications.co.uk/ifcolog/?00019 Google ScholarGoogle Scholar
  9. Pierre-Évariste Dagand, Nicolas Tabareau, and Éric Tanter. 2018. Foundations of Dependent Interoperability. Journal of Functional Programming, 28 (2018), 9:1–9:44. https://doi.org/10.1017/S0956796818000011 Google ScholarGoogle ScholarCross RefCross Ref
  10. Richard A. Eisenberg. 2016. Dependent Types in Haskell: Theory and Practice. arxiv:1610.07978. Google ScholarGoogle Scholar
  11. Joseph Eremondi, Ronald Garcia, and Éric Tanter. 2022. Propositional Equality for Gradual Dependently-Typed Programming. Proceedings of the ACM on Programming Languages, 6, ICFP (2022), Sept., https://doi.org/10.1145/3547627 Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Joseph Eremondi, Éric Tanter, and Ronald Garcia. 2019. Approximate Normalization for Gradual Dependent Types. 88:1–88:30. https://doi.org/10.1145/3341692 Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Ronald Garcia, Alison M. Clark, and Éric Tanter. 2016. Abstracting Gradual Typing. 429–442. isbn:978-1-4503-3549-2 https://doi.org/10.1145/2837614 See erratum: https://www.cs.ubc.ca/ rxg/agt-erratum.pdf. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Gaëtan Gilbert, Jesper Cockx, Matthieu Sozeau, and Nicolas Tabareau. 2019. Definitional Proof-Irrelevance without K. Proceedings of the ACM on Programming Languages, 3, POPL (2019), Jan., 1–28. https://doi.org/10.1145/3290316 Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. 2020. LICS ’20: 35th Annual ACM/IEEE Symposium on Logic in Computer Science, Saarbrücken, Germany, July 8-11, 2020, Holger Hermanns, Lijun Zhang, Naoki Kobayashi, and Dale Miller (Eds.). ACM Press. isbn:978-1-4503-7104-9 https://doi.org/10.1145/3373718 Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Jasper Hugunin. 2020. Why Not W? In 26th International Conference on Types for Proofs and Programs, TYPES 2020, March 2-5, 2020, University of Turin, Italy, Ugo de’Liguoro, Stefano Berardi, and Thorsten Altenkirch (Eds.) (LIPIcs, Vol. 188). Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 8:1–8:9. isbn:978-3-95977-182-5 https://doi.org/10.4230/LIPIcs.TYPES.2020.8 Google ScholarGoogle ScholarCross RefCross Ref
  17. 2019. Proceedings of the 24th ACM SIGPLAN Conference on Functional Programming (ICFP 2019). 3, ACM Press. Google ScholarGoogle Scholar
  18. Garrin Kimmell, Aaron Stump, Harley D. Eades III, Peng Fu, Tim Sheard, Stephanie Weirich, Chris Casinghino, Vilhelm Sjöberg, Nathan Collins, and Ki Yung Ahn. 2012. Equational reasoning about programs with general recursion and call-by-value semantics. In Proceedings of the 6th workshop on Programming Languages Meets Program Verification (PLPV 2012). ACM Press, 15–26. https://doi.org/10.1145/2103776.2103780 Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Kenneth Knowles and Cormac Flanagan. 2010. Hybrid type checking. ACM Transactions on Programming Languages and Systems, 32, 2 (2010), Jan., Article n.6. https://doi.org/10.1145/1111037.1111059 Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Bill Lawvere. 1970. Equality in hyperdoctrines and comprehension schema as an adjoint functor. In Proceedings of the AMS Symposium on Pure Mathematics XVII. 1–14. Google ScholarGoogle ScholarCross RefCross Ref
  21. 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. https://doi.org/10.1145/3009837.3009856 Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Meven Lennon-Bertrand, Kenji Maillard, Nicolas Tabareau, and Éric Tanter. 2022. Gradualizing the Calculus of Inductive Constructions. ACM Transactions on Programming Languages and Systems, 44, 2 (2022), June, https://doi.org/10.1145/3495528 Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Per Martin-Löf. 1971. An Intuitionistic Theory of Types. Unpublished manuscript. Google ScholarGoogle Scholar
  24. Max S. New and Amal Ahmed. 2018. Graduality from Embedding-Projection Pairs. In Proceedings of the 23rd ACM SIGPLAN Conference on Functional Programming (ICFP 2018). Proceedings of the ACM on Programming Languages, 2, 73:1–73:30. https://doi.org/10.1145/3236768 Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Peter-Michael Osera, Vilhelm Sjöberg, and Steve Zdancewic. 2012. Dependent Interoperability. In Proceedings of the 6th workshop on Programming Languages Meets Program Verification (PLPV 2012). ACM Press, 3–14. https://doi.org/10.1145/2103776.2103779 Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Xinming Ou, Gang Tan, Yitzhak Mandelbaum, and David Walker. 2004. Dynamic Typing with Dependent Types. In Proceedings of the IFIP International Conference on Theoretical Computer Science. 437–450. https://doi.org/10.1007/1-4020-8141-3_34 Google ScholarGoogle ScholarCross RefCross Ref
  27. Pierre-Marie Pédrot and Nicolas Tabareau. 2017. An effectful way to eliminate addiction to dependence. In 32nd Annual ACM/IEEE Symposium on Logic in Computer Science, LICS 2017, Reykjavik, Iceland, June 20-23, 2017. IEEE Computer Society, 1–12. https://doi.org/10.1109/LICS.2017.8005113 Google ScholarGoogle ScholarCross RefCross Ref
  28. Pierre-Marie Pédrot and Nicolas Tabareau. 2018. Failure is Not an Option - An Exceptional Type Theory. In Proceedings of the 27th European Symposium on Programming Languages and Systems (ESOP 2018), Amal Ahmed (Ed.) (Lecture Notes in Computer Science, Vol. 10801). Springer-Verlag, Thessaloniki, Greece. 245–271. https://doi.org/10.1007/978-3-319-89884-1_9 Google ScholarGoogle ScholarCross RefCross Ref
  29. Pierre-Marie Pédrot and Nicolas Tabareau. 2020. The fire triangle: how to mix substitution, dependent elimination, and effects. Proceedings of the ACM on Programming Languages, 4, POPL (2020), Jan., 58:1–58:28. https://doi.org/10.1145/3371126 Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Pierre-Marie Pédrot, Nicolas Tabareau, Hans Fehrmann, and Éric Tanter. 2019. A Reasonably Exceptional Type Theory. 108:1–108:29. https://doi.org/10.1145/3341712 Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Loïc Pujet and Nicolas Tabareau. 2022. Observational Equality: Now For Good. Proceedings of the ACM on Programming Languages, 6, POPL (2022), Jan., https://doi.org/10.1145/3498693 Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Emily Riehl and Michael Shulman. 2017. A type theory for synthetic ∞-categories. Higher Structures, 1 (2017), 147–223 (78). issn:2209-0606 Google ScholarGoogle ScholarCross RefCross Ref
  33. Patrick Maxim Rondon, Ming Kawaguchi, and Ranjit Jhala. 2008. Liquid types. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2008), Rajiv Gupta and Saman P. Amarasinghe (Eds.). ACM Press, 159–169. https://doi.org/10.1145/1375581.1375602 Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Christian Sattler and Andrea Vezzosi. 2020. Partial Univalence in n-truncated Type Theory. 807–819. isbn:978-1-4503-7104-9 https://doi.org/10.1145/3373718.3394759 Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Jeremy Siek and Walid Taha. 2006. Gradual Typing for Functional Languages. In Proceedings of the Scheme and Functional Programming Workshop. 81–92. Google ScholarGoogle Scholar
  36. Jeremy 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 2010). ACM Press, Madrid, Spain. 365–376. https://doi.org/10.1145/1706299.1706342 Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. 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), Vol. 32). Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, Asilomar, California, USA. 274–293. https://doi.org/10.4230/LIPIcs.SNAPL.2015.274 Google ScholarGoogle ScholarCross RefCross Ref
  38. Aaron Stump, Vilhelm Sjöberg, and Stephanie Weirich. 2010. Termination Casts: A Flexible Approach to Termination with General Recursion. In Proceedings Workshop on Partiality and Recursion in Interactive Theorem Provers (PAR 2010). 76–93. https://doi.org/10.29007/3w36 Google ScholarGoogle ScholarCross RefCross Ref
  39. Nikhil Swamy, Catalin Hritcu, Chantal Keller, Aseem Rastogi, Antoine Delignat-Lavaud, Simon Forest, Karthikeyan Bhargavan, Cédric Fournet, Pierre-Yves Strub, Markulf Kohlweiss, Jean Karim Zinzindohoue, and Santiago Zanella Béguelin. 2016. Dependent types and multi-effects in F^⋆. 256–270. isbn:978-1-4503-3549-2 https://doi.org/10.1145/2837614 Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. M. Takahashi. 1995. Parallel Reductions in λ -Calculus. Information and Computation, 118, 1 (1995), 120 – 127. issn:0890-5401 https://doi.org/10.1006/inco.1995.1057 Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. Éric Tanter and Nicolas Tabareau. 2015. Gradual Certified Programming in Coq. In Proceedings of the 11th ACM Dynamic Languages Symposium (DLS 2015). ACM Press, Pittsburgh, PA, USA. 26–40. https://doi.org/10.1145/2816707.2816710 Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. The Coq Development Team. 2020. The Coq proof assistant reference manual. https://coq.inria.fr/refman/ Version 8.12. Google ScholarGoogle Scholar
  43. Andrea Vezzosi, Anders Mörtberg, and Andreas Abel. 2019. Cubical Agda: A Dependently Typed Programming Language with Univalence and Higher Inductive Types. Proc. ACM Program. Lang., 3, ICFP (2019), Article 87, July, 29 pages. https://doi.org/10.1145/3341691 Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. Philip Wadler and Robert Bruce Findler. 2009. Well-Typed Programs Can’t Be Blamed. In Proceedings of the 18th European Symposium on Programming Languages and Systems (ESOP 2009), Giuseppe Castagna (Ed.) (Lecture Notes in Computer Science, Vol. 5502). Springer-Verlag, York, UK. 1–16. https://doi.org/10.1007/978-3-642-00590-9_1 Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. Matthew Z. Weaver and Daniel R. Licata. 2020. A Constructive Model of Directed Univalence in Bicubical Sets. 915–928. isbn:978-1-4503-7104-9 https://doi.org/10.1145/3373718.3394794 Google ScholarGoogle ScholarDigital LibraryDigital Library
  46. Hongwei Xi and Frank Pfenning. 1998. Eliminating array bound checking through dependent types. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI ’98). ACM Press, 249–257. https://doi.org/10.1145/277650.277732 Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. A reasonably gradual type theory

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader
        About Cookies On This Site

        We use cookies to ensure that we give you the best experience on our website.

        Learn more

        Got it!