Coq:Prop与类型中的设置(n)

时间:2015-03-28 20:58:18

标签: types functional-programming coq

我想考虑以下三个(相关的?)Coq定义。

Inductive nat1: Prop :=
  | z1 : nat1
  | s1 : nat1 -> nat1.

Inductive nat2 : Set := 
  | z2 : nat2
  | s2 : nat2 -> nat2.

Inductive nat3 : Type :=
  | z3 : nat3
  | s3 : nat3 -> nat3.

这三种类型都给出了归纳原则来证明一个命题。

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

set和type版本还包含set和type定义的归纳原则(分别为rec和rect)。这是我对Prop和Set之间差异的了解程度; Prop的归纳较弱。

我还读到,虽然Set是预测性的,但Prop是不可预测的,但这似乎是属性而不是定义的质量。

虽然Set和Prop之间的一些实际(道德?)差异是明确的,但Set和Prop之间的确切定义差异以及它们适合类型范围的位置尚不清楚(运行检查Prop和Set给出类型(*(设置)+ 1 *)),我不确定如何解释这个......

2 个答案:

答案 0 :(得分:3)

Type : Type不一致。

带有排除中间位置的impredicative Set意味着证明不相关,因此具有证据相关性的不可预测Set,例如true <> false,驳斥被排除在外的中间人,直觉主义不应该这样做。

因此,我们在Prop中留下了不确定性,而其他类型层次结构给我们带来了困境。

顺便说一下,

forall P : nat1 -> Prop, P z1 -> (forall n : nat1, P n -> P (s1 n)) -> forall n : nat1, P n

是可证明的。不要问我Coq的好处是什么才能自动证明其他较弱的感应原理...

此外,您是否阅读过this chapter of CPDT

答案 1 :(得分:0)

一个小时之内就读完一遍。这是因为Coq将假定同一个Prop的两个证明对象相等。这是一个公理,称为证明无关紧要。

https://coq.inria.fr/library/Coq.Logic.ProofIrrelevance.html

它只是认为Prop(这里P)上的谓词实际上并不需要传递某些证据作为其论点(或假设)并将其删除。

考虑一下。因为每个nat1都是相同的,所以每当我们尝试证明某个属性P时,我们都可以抽象一些nat1,同时使用公理将其重写为必需的属性。因此,Coq生成了归纳原理的“简化”版本。

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

Scheme nat1_ind_full := Induction for nat1 Sort Prop.

参考Different induction principles for Prop and Type