Types Coq:道具与安装类型(n) 我想考虑下面的三个(相关的)COQ定义。< /P> Inductive nat1: Prop := | z1 : nat1 | s1 : nat1 -> nat1. Inductive nat2 : Set := | z2 : nat2 | s2 : nat2 -> nat2. Inductive nat3 : Type := | z3 : nat3 | s3 : nat3 -> nat3.

Types Coq:道具与安装类型(n) 我想考虑下面的三个(相关的)COQ定义。< /P> Inductive nat1: Prop := | z1 : nat1 | s1 : nat1 -> nat1. Inductive nat2 : Set := | z2 : nat2 | s2 : nat2 -> nat2. Inductive nat3 : Type := | z3 : nat3 | s3 : nat3 -> nat3.,types,functional-programming,coq,Types,Functional Programming,Coq,这三种类型都给出了证明命题成立的归纳原则 nat1_ind : forall P : Prop, P -> (nat1 -> P -> P) -> nat1 -> P nat2_ind : forall P : nat2 -> Prop, P z2 -> (forall n : nat2, P n -> P (s2 n)) -> forall n : nat2, P n nat3_ind : f

这三种类型都给出了证明命题成立的归纳原则

nat1_ind
     : forall P : Prop, P -> (nat1 -> P -> P) -> nat1 -> P

nat2_ind
     : forall P : nat2 -> Prop,
       P z2 -> (forall n : nat2, P n -> P (s2 n)) -> forall n : nat2, P n

nat3_ind
     : forall P : nat3 -> Prop,
       P z3 -> (forall n : nat3, P n -> P (s3 n)) -> forall n : nat3, P n
集合和类型版本还包含集合和类型定义的归纳原则(分别为rec和rect)。这是我对道具和布景之间区别的了解程度;道具的诱导力较弱

我也读过,Prop是非指示性的,Set是谓词的,但这似乎是一个属性,而不是一个定义性质


虽然集合和道具之间的一些实际(道德?)差异是明确的,但集合和道具之间的确切定义差异以及它们在类型宇宙中的位置尚不清楚(对集合和道具进行检查会给出类型(*(集合)+1*)),我不确定该如何解释这个…

Type:Type
是不一致的

带有排除中间的非指示性
意味着证明无关,因此带有证明相关性的非指示性
,例如
真假
,反驳排除中间,直觉主义不应该这样做

因此,我们在
Prop
中保留不可预测性,而类型层次结构的其余部分为我们提供了可预测性

顺便说一下

forall P : nat1 -> Prop, P z1 -> (forall n : nat1, P n -> P (s1 n)) -> forall n : nat1, P n
这是可以证明的。不要问我Coq的好处是什么,它只是自动证明了其他较弱的归纳原理


还有,你读过了吗?

一小时后再读一读。这是因为Coq将假定同一
Prop
的两个证明对象相等。这是一条公理,被称为证明无关

它只是认为
Prop
(此处
p
)上的谓词实际上不需要将一些证据作为其参数(或假设)传递并删除

想想这个。由于每个
nat1
都是相同的,每当我们试图证明一些属性
P
,我们就可以抽象出一些
nat1
,同时使用公理将其重写为所需的属性。因此,Coq产生了归纳原理的“简化”版本

要生成“完整”版本,可以使用

Scheme nat1_ind_full := Induction for nat1 Sort Prop.

参考

谢谢您的回答。我希望对这些差异有一个更“低层次”的理论解释。例如,除了Set和Prop之外,Type0的居民是什么,这是唯一的区别。我发现这是一个很好的粗略的想法。但我仍然缺少一些细节。同样在霍特,他们谈论的是集合和命题,我想知道这是否是Coq中的Prop的作用。一个次要的观察:
nat1
没有定义
Prop
中的自然数——这是讨论过的。