简体   繁体   English

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

[英]Coq: Prop versus Set in Type(n)

I want to consider the following three (related?) Coq definitions. 我想考虑以下三个(相关的?)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.

All three types give induction principles to prove a proposition holds. 这三种类型都给出了归纳原则来证明一个命题。

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

The set and type versions also contain induction principles for definitions over set and type (rec and rect respectively). set和type版本还包含set和type定义的归纳原则(分别为rec和rect)。 This is the extent of my knowledge about the difference between Prop and Set; 这是我对Prop和Set之间差异的了解程度; Prop has a weaker induction. Prop的诱导较弱。

I have also read that Prop is impredicative while Set is predicative, but this seems like a property rather than a defining quality. 我还读到,虽然Set是预测性的,但Prop是不可预测的,但这似乎是属性而不是定义的质量。

While some practical (moral?) differences between Set and Prop are clear, the exact, defining differences between Set and Prop, as well as where they fit into the universe of types is unclear (running check on Prop and Set gives Type (* (Set) + 1*)), and I'm not exactly sure how to interpret this... 虽然Set和Prop之间的一些实际(道德?)差异是明确的,但Set和Prop之间的确切定义差异以及它们适合类型范围的位置尚不清楚(运行检查Prop和Set给出类型(*(设置)+ 1 *)),我不确定如何解释这个...

Type : Type is inconsistent. Type : Type不一致。

Impredicative Set with excluded middle implies proof irrelevance, so impredicative Set with proof relevance, eg true <> false , refutes excluded middle, which intuitionism isn't supposed to do. 具有排除中间的Impredicative Set意味着证明不相关,因此具有证明相关性的impredicative Set ,例如true <> false ,驳斥被排除的中间,这是直觉主义不应该做的。

Therefore we leave impredicativity in Prop and the rest of the type hierarchy gives us predicativity. 因此,我们在Prop留下了不可信度,而类型层次结构的其余部分给我们带来了困境。

By the way, 顺便说说,

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

is provable. 是可证明的。 Don't ask me what's the benefit of Coq only automatically proving that other weaker induction principle... 不要问我Coq的好处是什么才能自动证明其他较弱的感应原理......

Also, have you read this chapter of CPDT ? 另外,你读过CPDT的这一章吗?

Just read about this in an hour. 请在一小时内阅读此内容。 This is because Coq will assume equality of two proof object of a same Prop . 这是因为Coq将假设同一Prop的两个证明对象相等。 This is an axiom and is called proof irrelevance. 这是一个公理,被称为证明不相关。

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

It just thinks a predicate over Prop (Here P ) doesn't really need to have some proof passed as its argument (or hypothesis) and removed it. 它只是认为关于Prop (这里是P )的谓词并不需要将一些证据作为其论证(或假设)传递并将其删除。

Consider this. 考虑一下。 Because of every nat1 are the same, whenever we try to proof some property P , we can just abstract over some nat1 , while use the axiom to rewrite it to required ones. 因为每个nat1是相同的,每当我们尝试证明某些属性P ,我们可以只抽象一些nat1 ,同时使用公理将其重写为必需的属性。 Thus Coq generated the "simplified" version of induction principle. 因此,Coq产生了感应原理的“简化”版本。

To generate the "full" version, you can use 要生成“完整”版本,您可以使用

Scheme nat1_ind_full := Induction for nat1 Sort Prop.

ref. REF。 Different induction principles for Prop and Type Prop和Type的不同归纳原则

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM