论文标题
扩展平等保护和经过验证的通用编程
Extensional equality preservation and verified generic programming
论文作者
论文摘要
在经过验证的通用编程中,不能利用具体数据类型的结构,而必须依靠精心选择的规格或抽象数据类型(ADT)。函子和单子是功能编程的许多应用的核心。这就提出了一个问题,即对经过验证的函数和单子的有用ADT可能会是什么样。许多重要单子的功能图保留了扩展平等。例如,如果$ f,g:a \ rightArrow b $在a,\ f \ x = g \ x $中的$ \ forall x \,则是$ \ forall x \,然后$ ap \ f:list \ a list \ a \ rightArrow list \ b $和$ map \ g $也是扩展相等的。这表明保存扩展平等可能是经过验证的通用编程的有用原理。我们通过一种极简主义的方法来探讨这种可能性:我们在Martin-Löf的强化类型理论中处理(缺乏)扩展平等,而无需扩展理论或使用成熟的setoids。也许令人惊讶的是,这种最小的方法非常有用。它允许人们得出单声道定律的简单通用证明,但也可以在动态系统和控制理论中验证,仿制药结果。反过来,这些结果避免了繁琐的代码重复和临时证明。因此,我们的工作是对务实,经过验证的通用编程的贡献。
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 \rightarrow B$ are extensionally equal, that is, $\forall x \in A, \ f \ x = g \ x$, then $map \ f : List \ A \rightarrow 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 towards pragmatic, verified generic programming.