I'm still puzzled what the sort Set means in COQ. When do I use Set and when do I use Type?
In Hott a Set is defined as a type, where identity proofs are unique. But I think in Coq it has a different interpretation.
I'm still puzzled what the sort Set means in COQ. When do I use Set and when do I use Type?
In Hott a Set is defined as a type, where identity proofs are unique. But I think in Coq it has a different interpretation.
Set
means rather different things in Coq and HoTT.In Coq, every object has a type, including types themselves. Types of types are usually referred to as sorts, kinds or universes. In Coq, the (computationally relevant) universes are
Set
, andType_i
, wherei
ranges over natural numbers (0, 1, 2, 3, ...). We have the following inclusions:These universes are typed as follows:
Like in Hott, this stratification is needed to ensure logical consistency. As Antal pointed out,
Set
behaves mostly like the smallestType
, with one exception: it can be made impredicative when you invokecoqtop
with the-impredicative-set
option. Concretely, this means thatforall X : Set, A
is of typeSet
wheneverA
is. In contrast,forall X : Type_i, A
is of typeType_(i + 1)
, even whenA
has typeType_i
.The reason for this difference is that, due to logical paradoxes, only the lowest level of such a hierarchy can be made impredicative. You may then wonder then why
Set
is not made impredicative by default. This is because an impredicativeSet
is inconsistent with a strong form of the axiom of the excluded middle:What this axiom allows you to do is to write functions that can decide arbitrary propositions. Note that the
{P} + {~ P}
type lives inSet
, and notProp
. The usual form of the excluded middle,forall P : Prop, P \/ ~ P
, cannot be used in the same way, because things that live inProp
cannot be used in a computationally relevant way.In addition to Arthur's answer:
From the fact that
Set
is located at the bottom of the hierarchy,That means the following will fail:
with this error message:
As the message suggests, we can amend it by using
Type
:Reference: