LibNDT: Towards a Formal Library on Spreadable Properties over Linked Nested Datatypes

Mathieu Montin
(Université de Lorraine, Loria, CNRS, Inria, France)
Amélie Ledein
(Université Paris-Saclay, ENS Paris-Saclay, LMF, CNRS, Inria, France)
Catherine Dubois
(ENSIIE, Samovar, IP Paris, France)

Nested datatypes have been widely studied in the past 25 years, both theoretically using category theory, and practically in programming languages such as Haskell. They consist in recursive polymorphic datatypes where the type parameter changes throughout the recursion. They have a variety of applications such as modelling memory or modelling constraints over regular datatypes without relying on dependent types. In this work, we focus on a specific subset of nested datatypes which we call Linked Nested DataTypes (LNDT). We show that some usual datatypes such has List and Maybe, as well as some well-known nested datatypes such as Nest and even Bush can be built as various instances of LNDT. We proceed by presenting LibNDT, a library, developed both in Agda and Coq, which focuses on the set of constructs that can be spread directly from the parameter on which a LNDT is built, to the LNDT itself. These spreadable elements are of two kinds, functions, such as folds and map, and properties, such as the congruence of map or the satisfaction of a given predicate for at least one, or all, elements of the structure. We make use of the dependent type system of both Coq and Agda to model the latter. This paper ends with a discussion about various interesting topics that were raised throughout our development such as the issue of termination, the comparison of our tools and the proof effort required to extend LibNDT with additional elements.

In Jeremy Gibbons and Max S. New: Proceedings Ninth Workshop on Mathematically Structured Functional Programming (MSFP 2022), Munich, Germany, 2nd April 2022, Electronic Proceedings in Theoretical Computer Science 360, pp. 27–44.
Published: 30th June 2022.

ArXived at: https://dx.doi.org/10.4204/EPTCS.360.2 bibtex PDF
References in reconstructed bibtex, XML and HTML format (approximated).
Comments and questions to: eptcs@eptcs.org
For website issues: webmaster@eptcs.org