“非严格的……积极发生”

时间:2019-02-02 16:20:15

标签: coq

我尝试定义以下类型

Inductive t : Type -> Type :=
  | I : t nat
  | F : forall A, (t nat -> t A) -> t A.

,我收到以下错误消息:

Non strictly positive occurrence of "t" in "forall A : Type, (t nat -> t A) -> t A".
  • 此错误是什么意思?
  • 是否有一种方法可以“修复”定义以使其有效?
  • 我在哪里可以了解到更多信息?

谢谢!

1 个答案:

答案 0 :(得分:4)

您可以在Coq参考手册中查找常见的错误消息:https://coq.inria.fr/distrib/current/refman/language/gallina-specification-language.html?highlight=positive#coq:exn.non-strictly-positive-occurrence-of-ident-in-type

本质上,如果一个构造包含功能(如sortTime(columnIndex, sortingAZ){ var rowArray = this.get('tableArr').slice(0); //gets array of arrays var that = this; rowArray.sort(function(a,b) { var time1 = that.formatTime(a[columnIndex]); //formats time into military time var time2 = that.formatTime(b[columnIndex]); return time1 - time2; }); ),它们不能提感应型被定义为一个参数的一部分(t nat -> t A)。

t nat

具有相关类型的认证编程(CPDT)中的本节通过一个简化示例说明了该问题:http://adam.chlipala.net/cpdt/html/Cpdt.InductiveTypes.html#lab30

如果可以定义类型

        vvvvvvvvvvvvvv argument
F : ... (t nat -> t A)               -> t A
                  ^ OK ("positive occurence")
         ^ Not OK ("negative occurence")

然后您可以定义函数

Inductive term : Set :=
| App : term -> term -> term
| Abs : (term -> term) -> term.

Definition uhoh (t : term) : term := match t with | Abs f => f t | _ => t end. 会发散。