Advertisement

Efficient Mendler-Style Lambda-Encodings in Cedille

  • Denis Firsov
  • Richard Blair
  • Aaron Stump
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 10895)

Abstract

It is common to model inductive datatypes as least fixed points of functors. We show that within the Cedille type theory we can relax functoriality constraints and generically derive an induction principle for Mendler-style lambda-encoded inductive datatypes, which arise as least fixed points of covariant schemes where the morphism lifting is defined only on identities. Additionally, we implement a destructor for these lambda-encodings that runs in constant-time. As a result, we can define lambda-encoded natural numbers with an induction principle and a constant-time predecessor function so that the normal form of a numeral requires only linear space. The paper also includes several more advanced examples.

Keywords

Type theory Lambda-encodings Cedille Induction principle Predecessor function Inductive datatypes 

Notes

Acknowledgments

The first author is thankful to Anna, Albert, and Eldar for all the joy and support. Authors are thankful to Larry Diehl for proof reading and numerous grammatical adjustments. We gratefully acknowledge NSF support under award 1524519, and DoD support under award FA9550-16-1-0082 (MURI program).

References

  1. 1.
    Geuvers, H.: Induction is not derivable in second order dependent type theory. In: Abramsky, S. (ed.) TLCA 2001. LNCS, vol. 2044, pp. 166–181. Springer, Heidelberg (2001).  https://doi.org/10.1007/3-540-45413-6_16CrossRefGoogle Scholar
  2. 2.
    Stump, A.: The calculus of dependent lambda eliminations. J. Funct. Program. 27, e14 (2017)MathSciNetCrossRefGoogle Scholar
  3. 3.
    Firsov, D., Stump, A.: Generic derivation of induction for impredicative encodings in cedille. In: Proceedings of the 7th ACM SIGPLAN International Conference on Certified Programs and Proofs, CPP 2018, New York, NY, USA, pp. 215–227. ACM (2018)Google Scholar
  4. 4.
    Parigot, M.: On the representation of data in lambda-calculus. In: Börger, E., Büning, H.K., Richter, M.M. (eds.) CSL 1989. LNCS, vol. 440, pp. 309–321. Springer, Heidelberg (1990).  https://doi.org/10.1007/3-540-52753-2_47CrossRefGoogle Scholar
  5. 5.
    Parigot, M.: Programming with proofs: a second order type theory. In: Ganzinger, H. (ed.) ESOP 1988. LNCS, vol. 300, pp. 145–159. Springer, Heidelberg (1988).  https://doi.org/10.1007/3-540-19027-9_10CrossRefGoogle Scholar
  6. 6.
    Stump, A., Fu, P.: Efficiency of lambda-encodings in total type theory. J. Funct. Program. 26, e3 (2016)MathSciNetCrossRefGoogle Scholar
  7. 7.
    Stump, A.: From realizability to induction via dependent intersection. Ann. Pure Appl. Logic 169, 637–655 (2018)MathSciNetCrossRefGoogle Scholar
  8. 8.
    Wells, J.B.: Typability and type checking in system F are equivalent and undecidable. Ann. Pure Appl. Logic 98(1–3), 111–156 (1999)MathSciNetCrossRefGoogle Scholar
  9. 9.
    Kopylov, A.: Dependent intersection: a new way of defining records in type theory. In: 18th IEEE Symposium on Logic in Computer Science (LICS), pp. 86–95 (2003)Google Scholar
  10. 10.
    Miquel, A.: The implicit calculus of constructions extending pure type systems with an intersection type binder and subtyping. In: Abramsky, S. (ed.) TLCA 2001. LNCS, vol. 2044, pp. 344–359. Springer, Heidelberg (2001).  https://doi.org/10.1007/3-540-45413-6_27CrossRefMATHGoogle Scholar
  11. 11.
    Diehl, L., Firsov, D., Stump, A.: Generic zero-cost reuse for dependent types. CoRR abs/1803.08150 (2018)Google Scholar
  12. 12.
    Uustalu, T., Vene, V.: Mendler-style inductive types, categorically. Nordic J. Comput. 6(3), 343–361 (1999)MathSciNetMATHGoogle Scholar
  13. 13.
    Wadler, P.: Recursive types for free! (1990)Google Scholar
  14. 14.
    Coquand, T., Paulin, C.: Inductively defined types. In: Martin-Löf, P., Mints, G. (eds.) COLOG 1988. LNCS, vol. 417, pp. 50–66. Springer, Heidelberg (1990).  https://doi.org/10.1007/3-540-52335-9_47CrossRefGoogle Scholar
  15. 15.
    Pfenning, F., Paulin-Mohring, C.: Inductively defined types in the Calculus of Constructions. In: Main, M., Melton, A., Mislove, M., Schmidt, D. (eds.) MFPS 1989. LNCS, vol. 442, pp. 209–228. Springer, New York (1990)CrossRefGoogle Scholar
  16. 16.
    Swierstra, W.: Data types à la carte. J. Funct. Program. 18(4), 423–436 (2008)MathSciNetCrossRefGoogle Scholar
  17. 17.
    Delaware, B., d. S. Oliveira, B.C., Schrijvers, T.: Meta-theory à la carte. In: Proceedings of the 40th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2013, New York, NY, USA, pp. 207–218. ACM (2013)Google Scholar
  18. 18.
    Torrini, P.: Modular dependent induction in Coq, Mendler-style. In: Blanchette, J.C., Merz, S. (eds.) ITP 2016. LNCS, vol. 9807, pp. 409–424. Springer, Cham (2016).  https://doi.org/10.1007/978-3-319-43144-4_25CrossRefGoogle Scholar
  19. 19.
    Traytel, D., Popescu, A., Blanchette, J.C.: Foundational, compositional (Co)datatypes for higher-order logic: category theory applied to theorem proving. In: Proceedings of the 27th Annual IEEE Symposium on Logic in Computer Science, LICS 2012, Dubrovnik, Croatia, 25–28 June 2012, pp. 596–605. IEEE Computer Society (2012)Google Scholar
  20. 20.
    Biendarra, J., et al.: Foundational (Co)datatypes and (Co)recursion for higher-order logic. In: Dixon, C., Finger, M. (eds.) FroCoS 2017. LNCS (LNAI), vol. 10483, pp. 3–21. Springer, Cham (2017)CrossRefGoogle Scholar

Copyright information

© Springer International Publishing AG, part of Springer Nature 2018

Authors and Affiliations

  1. 1.Department of Computer ScienceThe University of IowaIowa CityUSA

Personalised recommendations