Containers conveniently represent a wide class of inductive data types. Their derivatives compute representations of types of one-hole contexts, useful for implementing tree-traversal algorithms. In the category of containers and cartesian morphisms, derivatives of discrete containers (whose positions have decidable equality) satisfy a universal property. Working in Univalent Foundations, we extend the derivative operation to untruncated containers (whose shapes and positions are arbitrary types). We prove that this derivative, defined in terms of a set of isolated positions, satisfies an appropriate universal property in the wild category of untruncated containers and cartesian morphisms, as well as basic laws with respect to constants, sums and products. A chain rule exists, but is in general non-invertible. In fact, a globally invertible chain rule is inconsistent in the presence of non-set types, and equivalent to a classical principle when restricted to set-truncated containers. We derive a rule for derivatives of smallest fixed points from the chain rule, and characterize its invertibility. All of our results are formalized in Cubical Agda.
翻译:容器为广泛类别的归纳数据类型提供了便捷的表示方法。其导数可计算单孔上下文类型的表示形式,这对于实现树遍历算法非常有用。在容器与笛卡尔态射的范畴中,离散容器(其位置具有可判定相等性)的导数满足一个泛性质。基于单值基础理论,我们将导数运算推广至非截断容器(其形状与位置为任意类型)。我们证明,这个通过孤立位置集定义的导数,在非截断容器与笛卡尔态射构成的野生范畴中满足恰当的泛性质,同时满足关于常数、和与积的基本运算法则。链式法则存在,但通常不可逆。事实上,在非集合类型存在的情况下,全局可逆的链式法则将导致不一致性;当限制于集合截断容器时,该法则等价于一个经典原理。我们从链式法则推导出最小不动点导数的计算规则,并刻画其可逆性条件。本文所有结果均在Cubical Agda中完成形式化验证。