为什么精益强制递归类型参数出现在非递归类型参数之后?

Why does Lean enforce recursive type arguments to appear after non-recursive ones?

以下定义被精益拒绝:

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

带有错误消息 "arg #2 of 'natlist.cons' is not recursive, but it occurs after recursive arguments"

并且按照预期接受以下定义:

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

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

归纳类型的精益实现基于 P. Dybjer (1994) 的 "Inductive families" 论文:

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 删除了此限制,您的第一个定义现在可以使用了。