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.
翻译:在过去25年中,对内嵌数据类型进行了广泛的研究,既有理论上使用类别理论,也有实际使用Haskell等编程语言。这些数据类型包括循环式参数在整个循环中发生变化的递归多形态数据类型。它们有多种应用,例如对常规数据类型进行内存建模或建模限制,而不依赖依赖依赖类型。在这项工作中,我们侧重于一个嵌套数据类型的具体子组,我们称之为链接式数据类型(LNDT)。我们显示,有些通常的数据类型,例如清单和可能,以及一些众所周知的嵌套数据类型,如Nest甚至布什,可以作为LNDT的各种实例来构建。我们接下来要展示的是LibNDT,这是在Agda和Coq开发的一个图书馆,它侧重于从我们构建了LNDT的参数直接扩散到LNDT本身。这些可传播的元素有两种类型,功能,例如折叠和地图和地图,以及一些众所周知的数据类型,例如Nest甚至Bush等嵌套式数据类型数据类型,可以作为LNDT的各种实例。我们接着展示LNDT的一个图书馆结构,或者对Aleaddal-lidaldealate 的精度结构的精度结构的精度的精度结构的精度,以便我们在最后使用。