当前位置: X-MOL 学术J. Funct. Program. › 论文详情
Our official English website, www.x-mol.net, welcomes your feedback! (Note: you will need to create a separate account there.)
Extensional equality preservation and verified generic programming
Journal of Functional Programming ( IF 1.1 ) Pub Date : 2021-10-21 , DOI: 10.1017/s0956796821000204
NICOLA BOTTA 1 , NURIA BREDE 2 , PATRIK JANSSON 3 , TIM RICHTER 4
Affiliation  

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.

中文翻译:

外延等式保存和验证的泛型编程

在经过验证的泛型编程中,不能利用具体数据类型的结构,而必须依赖精心挑选规范集或抽象数据类型 (ADT)。Functor 和 monad 是函数式编程的许多应用程序的核心。这就提出了一个问题,即对于经过验证的函子和单子来说,有用的 ADT 会是什么样子。许多重要单子的功能映射保留了外延平等。例如,如果 $$f,g \, : \, A \, \to \, B$$ 外延相等,即 $$\forall x \in A$$ , $$f \, x = g \, x$$ , 然后 $$map \, f \, : \, List \, A \to List \, B$$ $$地图\,g$$ 也是外延相等的。这表明保持外延平等在经过验证的泛型编程中可能是一个有用的原则。我们用一种极简主义的方法来探索这种可能性:我们在 Martin-Löf 的内涵类型理论中处理(缺乏)外延平等,而不扩展理论或使用成熟的 setoid。也许令人惊讶的是,这种最小的方法被证明是非常有用的。它允许人们推导出一元定律的简单通用证明,但也可以在动力系统和控制理论中得到验证的通用结果。反过来,这些结果避免了繁琐的代码重复和临时证明。因此,我们的工作是对实用的、经过验证的通用编程的贡献。
更新日期:2021-10-21
down
wechat
bug