
# Sorts¶

::=Set|Prop|SProp|Type|Type @{ _ }|Type @{ universe }::=max ( )|universe_expr::=

The types of types are called sorts.

All sorts have a type and there is an infinite well-founded typing hierarchy of sorts whose base sorts are $$\SProp$$, $$\Prop$$ and $$\Set$$.

The sort $$\Prop$$ intends to be the type of logical propositions. If $$M$$ is a logical proposition then it denotes the class of terms representing proofs of $$M$$. An object $$m$$ belonging to $$M$$ witnesses the fact that $$M$$ is provable. An object of type $$\Prop$$ is called a proposition. We denote propositions by form. This constitutes a semantic subclass of the syntactic class term.

The sort $$\SProp$$ is like $$\Prop$$ but the propositions in $$\SProp$$ are known to have irrelevant proofs (all proofs are equal). Objects of type $$\SProp$$ are called strict propositions. See SProp (proof irrelevant propositions) for information about using $$\SProp$$, and [GCST19] for meta theoretical considerations.

The sort $$\Set$$ intends to be the type of small sets. This includes data types such as booleans and naturals, but also products, subsets, and function types over these data types. We denote specifications (program types) by specif. This constitutes a semantic subclass of the syntactic class term.

$$\SProp$$, $$\Prop$$ and $$\Set$$ themselves can be manipulated as ordinary terms. Consequently they also have a type. Because assuming simply that $$\Set$$ has type $$\Set$$ leads to an inconsistent theory [Coq86], the language of CIC has infinitely many sorts. There are, in addition to the base sorts, a hierarchy of universes $$\Type(i)$$ for any integer $$i ≥ 1$$.

Like $$\Set$$, all of the sorts $$\Type(i)$$ contain small sets such as booleans, natural numbers, as well as products, subsets and function types over small sets. But, unlike $$\Set$$, they also contain large sets, namely the sorts $$\Set$$ and $$\Type(j)$$ for $$j<i$$, and all products, subsets and function types over these sorts.

Formally, we call $$\Sort$$ the set of sorts which is defined by:

$\Sort \equiv \{\SProp,\Prop,\Set,\Type(i)\;|\; i~∈ ℕ\}$

Their properties, such as $$\Prop:\Type(1)$$, $$\Set:\Type(1)$$, and $$\Type(i):\Type(i+1)$$, are described in Subtyping rules.

The user does not have to mention explicitly the index $$i$$ when referring to the universe $$\Type(i)$$. One only writes Type. The system itself generates for each instance of Type a new index for the universe and checks that the constraints between these indexes can be solved. From the user point of view we consequently have $$\Type:\Type$$. We shall make precise in the typing rules the constraints between the indices.

Implementation issues In practice, the Type hierarchy is implemented using algebraic universes. An algebraic universe $$u$$ is either a variable (a qualified identifier with a number) or a successor of an algebraic universe (an expression $$u+1$$), or an upper bound of algebraic universes (an expression $$\max(u_1 ,...,u_n )$$), or the base universe (the expression $$0$$) which corresponds, in the arity of template polymorphic inductive types (see Section Well-formed inductive definitions), to the predicative sort $$\Set$$. A graph of constraints between the universe variables is maintained globally. To ensure the existence of a mapping of the universes to the positive integers, the graph of constraints must remain acyclic. Typing expressions that violate the acyclicity of the graph of constraints results in a Universe inconsistency error.