Hostname: page-component-586b7cd67f-r5fsc Total loading time: 0 Render date: 2024-11-25T19:17:35.208Z Has data issue: false hasContentIssue false

Extensional equality preservation and verified generic programming

Published online by Cambridge University Press:  21 October 2021

NICOLA BOTTA
Affiliation:
Potsdam Institute for Climate Impact Research, Potsdam, Germany, Chalmers University of Technology, Göteborg, Sweden (e-mail: [email protected])
NURIA BREDE
Affiliation:
Potsdam Institute for Climate Impact Research, Potsdam, Germany (e-mail: [email protected])
PATRIK JANSSON
Affiliation:
Chalmers University of Technology and University of Gothenburg, Göteborg, Sweden (e-mail: [email protected])
TIM RICHTER
Affiliation:
Potsdam University, Potsdam, Germany (e-mail: [email protected])
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

In verified generic programming, one cannot exploit the structure of concrete data types but has to rely on well chosen sets of specifications or abstract data types (ADTs). Functors and monads are at the core of many applications of functional programming. This raises the question of what useful ADTs for verified functors and monads could look like. The functorial map of many important monads preserves extensional equality. For instance, if $$f,g \, : \, A \, \to \, B$$ are extensionally equal, that is, $$\forall x \in A$$ , $$f \, x = g \, x$$ , then $$map \, f \, : \, List \, A \to List \, B$$ and $$map \, g$$ are also extensionally equal. This suggests that preservation of extensional equality could be a useful principle in verified generic programming. We explore this possibility with a minimalist approach: we deal with (the lack of) extensional equality in Martin-Löf’s intensional type theories without extending the theories or using full-fledged setoids. Perhaps surprisingly, this minimal approach turns out to be extremely useful. It allows one to derive simple generic proofs of monadic laws but also verified, generic results in dynamical systems and control theory. In turn, these results avoid tedious code duplication and ad-hoc proofs. Thus, our work is a contribution toward pragmatic, verified generic programming.

Type
Research Article
Creative Commons
Creative Common License - CCCreative Common License - BY
This is an Open Access article, distributed under the terms of the Creative Commons Attribution licence (http://creativecommons.org/licenses/by/4.0/), which permits unrestricted re-use, distribution, and reproduction in any medium, provided the original work is properly cited.
Copyright
© The Author(s), 2021. Published by Cambridge University Press

References

Altenkirch, T. (2017) From setoid hell to homotopy heaven? Available at: https://www.cs.nott.ac.uk/ psztxa/talks/types-17-hell.pdfGoogle Scholar
Arvidsson, A., Johansson, M. & Touche, R. (2019) Proving type class laws for Haskell. In Trends in Functional Programming, Van Horn, D. & Hughes, J. (eds). Springer, pp. 61–74.CrossRefGoogle Scholar
Bellman, R. (1957) Dynamic Programming. Princeton University Press.Google ScholarPubMed
Bird, R. (2014) Thinking Functionally with Haskell. Cambridge University Press.CrossRefGoogle Scholar
Bird, R. S. & de Moor, O. (1997) Algebra of Programming . Prentice Hall International Series in Computer Science. Prentice Hall.Google Scholar
Bishop, E. (1967) Foundations of Constructive Analysis. McGraw-Hill.Google Scholar
Blanqui, F., et al. (2020) CoLoR: A Coq Library on Rewriting and termination (Version 1.8.0). Available at: https://github.com/fblanqui/color Google Scholar
Botta, N., Jansson, P. & Ionescu, C. (2017) Contributions to a computational theory of policy advice and avoidability. J. Funct. Program. 27, 152.CrossRefGoogle Scholar
Boulier, S., Pédrot, P.-M. & Tabareau, N. (2017) The next 700 syntactical models of type theory. In ACM SIGPLAN Conference on Certified Programs and Proofs, CPP 2017. ACM, pp. 182–194.CrossRefGoogle Scholar
Brady, E. (2017) Type-Driven Development in Idris. Manning Publications Co.Google Scholar
Brede, N. & Botta, N. (2021) On the Correctness of Monadic Backward Induction. Submitted to Journal of Functional Programming, Available at: https://arxiv.org/abs/2008.02143Google Scholar
Carette, J. & Hu, J. Z. S. (2021) A new Categories library for Agda (Version 0.1.5). https://github.com/agda/agda-categories Google Scholar
Carette, J., Farmer, W. M. & Kohlhase, M. (2014) Realms: A structure for consolidating knowledge about mathematical theories. Intell. Comput. Math. 252266.CrossRefGoogle Scholar
Cohen, C., Coquand, T., Huber, S. & Mörtberg, A. (2018) Cubical type theory: A constructive interpretation of the univalence axiom. In Proc. TYPES 2015. Leibniz International Proceedings in Informatics (LIPIcs) 69, pp. 5:1–5:34. Schloss Dagstuhl – Leibniz-Zentrum für Informatik.Google Scholar
Danielsson, N. A., Hughes, J., Jansson, P. & Gibbons, J. (2006) Fast and loose reasoning is morally correct. ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 2006) pp. 206217. ACM.Google Scholar
De Moor, O. (1995) A generic program for sequential decision processes. In PLILPS 1995 Symposium on Programming Languages: Implementations, Logics and Programs. Springer, pp. 1–23.CrossRefGoogle Scholar
Erwig, M. and Kollmansberger, S. (2006) FUNCTIONAL PEARLS: Probabilistic functional programming in Haskell. J. Funct. Program. 16(1), 2134.CrossRefGoogle Scholar
Giry, M. (1981) A categorial approach to probability theory. In Categorical Aspects of Topology and Analysis, Banaschewski, B. (ed). Lecture Notes in Mathematics 915. Springer, pp. 68–85.Google Scholar
Gnesi, S., Montanari, U. and Martelli, A. (1981) Dynamic programming as graph searching: An algebraic approach. J. ACM 28(4), 737751.CrossRefGoogle Scholar
Hofmann, M. (1995 ) Extensional Concepts in Intensional Type Theory. PhD thesis, University of Edinburgh.Google Scholar
Hofmann, M. & Streicher, T. (1994) The groupoid model refutes uniqueness of identity proofs. In Proc. Symposium on Logic in Computer Science (LICS 1994), pp. 208–212.CrossRefGoogle Scholar
Hu, J. Z. S. & Carette, J. (2021) Formalizing category theory in Agda. In ACM SIGPLAN Conference on Certified Programs and Proofs, CPP 2021, pp. 327–342.CrossRefGoogle Scholar
Huet, G. & Saïbi, A. (2000) Constructive category theory. In Proof, Language, and Interaction. Essays in Honor of Robin Milnor, Plotkin, G., Stirling, C. & Tofte, M. (eds). MIT, pp. 239–275.Google Scholar
Ionescu, C. (2009) Vulnerability Modelling and Monadic Dynamical Systems. PhD thesis, Freie Universität Berlin.Google Scholar
Ionescu, C. & Jansson, P. (2013) Testing versus proving in climate impact research. In Proc. TYPES 2011. Leibniz International Proceedings in Informatics (LIPIcs) 19. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, pp. 41–54.Google Scholar
Jansson, P. & Jeuring, J. (2002) Polytypic data conversion programs. Sci. Comput. Program. 43(1), 3575.CrossRefGoogle Scholar
JetBrains Research. (2021) Arend Theorem Prover (Version 1.6.0). Available at: https://arend-lang.github.io/ Google Scholar
Jeuring, J., Jansson, P. & Amaral, C. (2012) Testing type class laws. In Proceedings of the 2012 Haskell Symposium. ACM, pp. 49–60.CrossRefGoogle Scholar
Kuznetsov, Y. A. (1998) Elements of Applied Bifurcation Theory. 2nd ed. Springer.Google Scholar
Manes, E. G. (1976) Algebraic Theories. Springer.Google Scholar
Martin-Löf, P. & Sambin, G. (1984) Intuitionistic Type Theory, vol. 9. Bibliopolis Naples.Google Scholar
McBride, C. & Paterson, R. (2008) Applicative programming with effects. J. Funct. Program. 18(1), 113.Google Scholar
Megacz, A. (2011) Category Theory in Coq (Coq-Categories). Available at: http://www.megacz.com/berkeley/coq-categories/ Google Scholar
Mu, S.-C., Ko, H.-S. & Jansson, P. (2009) Algebra of programming in Agda: dependent types for relational program derivation. J. Funct. Program 19(5), 545579.CrossRefGoogle Scholar
Nordström, B., Petersson, K. & Smith, J. M. (1990) Programming in Martin-Löf’s type theory . International Series of Monographs on Computer Science, vol. 200. Oxford University Press.Google Scholar
Norell, U. (2007) Towards a Practical Programming Language Based on Dependent Type theory. PhD thesis, Chalmers University of Technology.Google Scholar
Peyton Jones, S., Tolmach, A. & Hoare, T. (2001) Playing by the rules: Rewriting as a practical optimisation technique in GHC. In 2001 Haskell Workshop, pp. 203–233. ACM SIGPLAN.Google Scholar
Pierce, B. C. (1991) Basic Category Theory for Computer Scientists . Foundations of Computing Series. MIT.Google Scholar
Sozeau, M. (2010) A new look at generalized rewriting in type theory. J. Formal. Reason. 2(1), 4162.Google Scholar
Spitters, B. & Semeria, V. M. (2017) Coq Repository at Nijmegen (Version 1.2.0). Available at: https://github.com/coq-community/corn Google Scholar
Streicher, T. (1991) Semantics of Type Theory - Correctness, Completeness and Independence Results. Progress in Theoretical Computer Science. Birkhäuser.Google Scholar
Streicher, T. (1993) Investigations into Intensional Type Theory. Habilitiation Thesis, Ludwig-Maximilians-Universität München.Google Scholar
Streicher, T. (2003) Category Theory and Categorical Logic. Lecture Notes, Technische Universität Darmstadt. Available at: https://www2.mathematik.tu-darmstadt.de/ streicher/CTCL.pdf.Google Scholar
The Coq Development Team. (2021) The Coq Proof Assistant (Version 8.13.0). Available at: https://doi.org/10.5281/zenodo.4501022 CrossRefGoogle Scholar
The Idris Community. (2020) Documentation for the Idris Language. Available at: http://docs.idris-lang.org/en/latest/ Google Scholar
The Univalent Foundations Program. (2013) Homotopy Type Theory: Univalent Foundations of Mathematics. Available at: https://homotopytypetheory.org/book Google Scholar
Thomas, R. & Arnol’d, V. (2012) Catastrophe Theory. Springer.Google Scholar
Vezzosi, A., Mörtberg, A. & Abel, A. (2021) Cubical Agda: A dependently typed programming language with univalence and higher inductive types. J. Funct. Program. 31, e8.CrossRefGoogle Scholar
Voevodsky, V., Ahrens, B., Grayson, D., et al.. (2021) UniMath — A Computer-Checked Library of Univalent mathematics. Available at https://github.com/UniMath/UniMath Google Scholar
von Glehn, T. (2015) Polynomials and Models of Type Theory. PhD thesis, University of Cambridge.Google Scholar
Wadler, P. (1992) The essence of functional programming. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 1–14.CrossRefGoogle Scholar
Wiegley, J. (2018) Category Theory in Coq. Available from https://github.com/jwiegley/category-theory Google Scholar
Submit a response

Discussions

No Discussions have been published for this article.