recursion - 为什么 Lean 强制递归类型参数出现在非递归类型参数之后?

标签 recursion functional-programming recursive-datastructures induction lean

以下定义被 Lean 拒绝:

inductive natlist
| nil : natlist
| cons: natlist → ℕ → natlist

错误消息“'natlist.cons'的arg #2不是递归的,但它发生在递归参数之后

正如预期的那样,以下定义被接受:

inductive natlist
| nil : natlist
| cons: ℕ → natlist → natlist

精益执行此命令的原因是什么?

最佳答案

Lean 的归纳类型实现基于 P. Dybjer (1994) 的“归纳族”论文:

Backhouse [Bac88] and Coquand and Paulin [COP90] allowed the inessential generalisation where recursive premises may precede non-recursive ones. I prefer to put all non-recursive premises before the recursive ones, since the former cannot depend on the latter here (but the situation changes in [Dyb92]). This restriction simplifies the presentation of the scheme and emphasises the relationship with the well-orderings.

请注意,最近的 commit删除了此限制,您的第一个定义现在可以使用。

关于recursion - 为什么 Lean 强制递归类型参数出现在非递归类型参数之后?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41775816/

相关文章:

list - 递归定义init函数

javascript - JavaScript 对象中的深度变化值

c# - 递归调用函数并不总是可能的

c++ - 递归调用而不是多次for循环调用C++

c - 在帕特里夏/基数树上插入单词时遇到问题

c++ - 递归地从双向链表 C++ 中删除偶数项

c++ - 为什么非递归方法比递归方法花费更多时间?

java - 我无法弄清楚扫雷递归算法

xml - 在内存中的 XQuery 中多次编辑同一个文档节点

haskell - 为无限 Stream 派生 Functor