equality (definitional, propositional, computational, judgemental, extensional, intensional, decidable)
isomorphism, weak equivalence, homotopy equivalence, weak homotopy equivalence, equivalence in an (∞,1)-category
Examples.
natural deduction metalanguage, practical foundations
type theory (dependent, intensional, observational type theory, homotopy type theory)
computational trinitarianism = propositions as types +programs as proofs +relation type theory/category theory
everything is identical with itself (WdL §863)
no two things are like each other (WdL §903)
In intensional type theory under the propositions as types paradigm, an identity type (or equality type) is the incarnation of equality. That is, for any type $A$ and any terms $x,y:A$, the type $Id_A(x,y)$ is “the type of proofs that $x=y$” or “the type of reasons why $x=y$”.
To contrast with “computational” or definitional equality, sometimes inhabitation of an identity type is sometimes called propositional equality. The identity type $Id_A(x,y)$ is sometimes written $Eq_A(x,y)$ or just $(x=y)$, but in this article we reserve the latter for definitional equality.
In extensional type theory, such as that modeled in the internal logic of a 1-category, equality is an h-proposition, and hence each $Id_A(x,y)$ is a subsingleton. However, in the internal type theory of higher categories, such as the internal logic of an (∞,1)-topos, identity types represent path objects and are highly nontrivial. One speaks of homotopy type theory. In these cases, one may write for instance $Path_A(x,y)$ instead of $Id_A(x,y)$.
The definition of identity types was originally given in explicit form by Martin-Löf, in terms of introduction and elimination rules. Later, it was realized that this was a special case of the general notion of inductive type. We will discuss both formulations.
The rules for forming identity types and terms are as follows (expressed in sequent calculus). First the rule that defines the identity type itself, as a dependent type, in some context $\Gamma$.
Now the basic “introduction” rule, which says that everything is equal to itself in a canonical way.
To a category theorist, it might be more natural to call this $1_X$. The traditional notation $r(x)$ indicates that this is a canonical proof of the reflexivity of equality.
Then we have the “elimination” rule, which is easily the most subtle and powerful.
Ignore the presence of the additional context $\Delta$ for now; it is unnecessary if we also have dependent product types. The elimination rule then says that if:
then we can construct a canonically defined term $J(t;x,y,p):C(x,y,p)$ for any $x$, $y$, and $p:Id_A(x,y)$, by “transporting” the term $t$ along the proof of equality $p$. In homotopical or categorical models, this can be viewed as a “path-lifting” property, i.e. that the display maps are some sort of fibration. This can be made precise with the identity type weak factorization system?.
A particular case is when $C$ is a term representing a proposition according to the propositions-as-types philosophy. In this case, the elimination rule says that in order to prove a statement is true about all $x,y,p$, it suffices to prove it in the special case for $x,x,r(x)$.
Finally, we have the “computation” or β-reduction rule. This says that if we substitute along a reflexivity proof, nothing happens.
Note that the equality $=$ in the conclusion of the computation rule is definitional equality, not an instance of the identity/equality type itself.
These rules may seem a little ad-hoc, but they are actually a particular case of the general notion of inductive type.
Using inductive types the notion of identity types is encoded in a single line. In Coq notation we can say
Inductive id {A} : A -> A -> Type := idpath : forall x, id x x.
In other words, the identity type of $A$ is inductively generated by reflexivity, in the same way that the natural numbers are inductively generated by zero and successor. From this, the above introduction, elimination, and computation rules are all derived automatically.
This is the approach to identity types taken by practical work in homotopy type theory, which is usually implemented in Coq or Agda. See, for instance, Overture.v
An essentially equivalent way to give the definition, due to Paulin-Mohring, is
Inductive id {A} (x:A) : A -> Type := idpath : id x x.
The difference here is that now $x$ is a parameter of the inductive definition rather than an index. In other words, the first definition says “for each type $A$, we have an type $Id_A$ dependent on $A\times A$, inductively defined by a constructor $idpath$ which takes an element $x\colon A$ as input and yields output in $Id_A(x,x)$” while the second definition says “for each type $A$ and each element $x\colon A$, we have a type $Id_A(x)$ dependent on $A$, inductively defined by a constructor $idpath$ which takes no input and yields output in $Id_A(x)(x)$.” The two formulations can be proven equivalent, but sometimes one is more convenient than the other.
Almost all types in type theory can be given both β-reduction and η-reduction rules. $\beta$-reduction specifies what happens when we apply an eliminator to a term obtained by a constructor; $\eta$-reduction specifies the reverse. Above we have formulated only the $\beta$-reduction rule for identity types; the $\eta$-conversion rule would be the following:
This says that if $C$ is a type which we can use the eliminator $J$ to construct a term of, but we already have a term $t$ of that type, then if we restrict $t$ to reflexivity inputs and then apply $J$ to construct a term of type $C$, the result is the same as the term $t$ we started with. As in the $\beta$-reduction rule, the $=$ in the conclusion refers to definitional equality.
This $\eta$-conversion rule has some very strong consequences. For instance, suppose $x\colon A$, $y\colon A$, and $p\colon Id_A(x,y)$, and let $C \coloneqq A$. Then with $t=x$, the $\eta$-conversion rule tells us that $x = J(x[y/x,r(x)/p];x,y,p)$. And with $t=y$, the $\eta$-conversion rule tells us that $y = J(y[y/x,r(x)/p];x,y,p)$. But substituting $y$ for $x$ (and $r(x)$ for $p$) in the term $y$ simply yields the term $x$, which is the same as the result of substituting $y$ for $x$ and $r(x)$ for $p$ in the term $x$. Thus, we have
In other words, if $Id_A(x,y)$ is inhabited (that is, $x$ and $y$ are propositionally equal) then in fact $x$ and $y$ are definitionally equal. Moreover, by a similar argument we can show that
(Here we are eliminating into the type $C(x,y,p) \coloneqq Id_A(x,y)$. The term $r(x)$ may be regarded as belonging to this type, because we have already shown that $x$ and $y$ are definitionally equal.)
Thus, the definitional $\eta$-conversion rule for identity types implies that the type theory is extensional in a very strong sense. (This was observed already in (Streicher).) For this reason, in homotopy type theory we do not assume the $\eta$-conversion rule for identity types.
This sort of extensionality in type theory is also problematic for non-homotopical reasons: since type-checking in dependent type theory depends on definitional equality, but the above rule implies that definitional equality depends on inhabitation of identity types, this makes definitional equality and hence type-checking undecidable in the formal computational sense. Thus, $\eta$-conversion for identity types is often omitted (as in Coq).
On the other hand, it is possible to prove a propositional version of $\eta$-conversion using only the identity types as defined above without definitional $\eta$-conversion. In other words, given the hypotheses of the above $\eta$-conversion rule, we can construct a term belonging to the type
This has none of the bad consequences of definitional $\eta$-conversion, and in particular does not imply that the type theory is extensional. The argument that $p\colon Id_A(x,y)$ implies $x=y$ becomes the tautologous statement that if $p\colon Id_A(x,y)$ then $p\colon Id_A(x,y)$, while the subsequent argument that $p= r(x)$ fails because $x$ and $y$ are no longer definitionally equal, so $r(x)$ does not have type $Id_A(x,y)$. We can transport it along $p$ to obtain a term of this type, but then we obtain only that $p$ is equal to the transport of $r(x)$ along $p$, which is a perfectly intensional/homotopical statement.
We discuss the categorical semantics for identity types in the extensional case, and identity types in the categorical semantics of homotopy type theory in the intensional case.
In categorical models of extensional type theory, generally every morphism of the category is allowed to represent a dependent type, and the extensional identity types are represented by diagonal maps $A\to A\times A$.
By contrast, in models of intensional type theory, there is only a particular class of display maps or fibrations which are allowed to represent dependent types, and intensional identity types are represented by path objects $P A \to A \times A$.
Both of these cases apply in particular to models in the category of contexts of the type theory itself, i.e. the term model.
By the standard construction of mapping path spaces out of path space objects, the existence of identity types allows one to construct a weak factorization system.
Conversely, since any weak factorization system gives rise to path objects by factorization of diagonal maps, one may hope to construct a model of type theory with identity types in a category equipped with a WFS $(L,R)$. There are four obstacles in the way of such a construction.
In order to handle the additional context $\Delta$ in the explicit definition above, it turns out to be necessary to assume that $L$-maps are preserved by pullback along $R$-maps between $R$-objects. (Such a condition is also necessary in order to interpret type-theoretic dependent products in a locally cartesian closed category.)
This enables us to define identity types with their elimination and computation rules “locally”, i.e. for each type individually. However, every construction in type theory is stable under substitution. This means that if $y\colon Y\vdash A(y)\colon Type$ is a dependent type and $f\colon X\to Y$ is a morphism, then the identity type $x\colon X \vdash Id_{A(f(x))}(-,-)\colon Type$ is the same whether we first construct $Id_{A(y)}$ and then substitute $f(x)$ for $y$, or first substitute $f(x)$ for $y$ to obtain $A(f(x))$ and then construct its identity type. In order for this to hold up to isomorphism, we need to require that the WFS have stable path objects — a choice of path object data in each slice category which is preserved by pullback. In (Warren) it is shown that any simplicial model category in which the cofibrations are the monomorphisms can be equipped with stable path objects, while (Garner-van den Berg) it is shown that the presence of internal path-categories also suffices.
The eliminator term $J$ of identity types in type theory is also preserved by substitution. This imposes an additional coherence requirement which is tricky to obtain categorically. See the references by Warren and Garner-van den Berg for methods that ensure this, such as by invoking an algebraic weak factorization system. It can also be handled a la Voevodsky by using a (possibly univalent) universe.
Finally, substitution in type theory is strictly functorial/associative, whereas it is modeled categorically by pullback which is generally not strictly so. This is a general issue with the categorical interpretation of dependent type theory, not something specific to identity types. It can be resolved by passing to a split fibration which is equivalent to the codomain fibration, or by making use of a universe. See categorical model of dependent types.
Assume then that a category $\mathcal{C}$ with suitable WFSs has been chosen, for instance a type-theoretic model category. Then
The interpretation of a type $\vdash A : Type$ is as a fibrant object $[\vdash A : Type]$ which we will just write “$A$” for short.
type formation
The identity type $a, b : A \vdash Id_A(a,b) : Type$ is interpreted as the path space object fibration
term introduction
By definition of path space object, there exists a lift $\sigma$ in
By the universal property of the pullback this is equivalently a section of the pullback of the path space object along the diagonal morphism $(id,id) : A \to A \times A$.
Since $(id, id)^* A^I$ is the interpretation of the substitution
$a : A \vdash Id_A (a,a) : Type$ in this sense $\sigma$ is now the interpretation of a term $a : A \vdash r_A : Id_A (a,a)$.
term elemination
A type depending on an identity type
is interpreted as a fibration
The substitution $C(a,a,r_a)$ is interpreted by the pullback
Therefore a term $t : C(a,a,r_a)$ is interpreted as a section of this pullback
By the universal property of the pullback, this is equivalently a morphism $t$ in
The elimination rule says that given such $t$, there exists a compatible section of $C \to Id_A$. If we redraw the previous diagram as a square, then this section is a lift in that diagram
In particular, if $C$ itself is the pullback of a fibration $D \to B$ along a morphism $A^I \to B$, then $r$ has the left lifting property also against that fibration
So the term elimination rule says that the interpretaton $A \to A^I$ of $a : A \vdash r(a) : Id_A (a,a)$ has the left lifting property against all fibrations, hence that $A \to A^I$ is to be interpreted as an acyclic cofibration.
Some of the first work noticing the homotopical / higher-categorical interpretation of identity types (see below) focused on the fact that the tower of iterated identity types of a type has the structure of an internal algebraic ω-groupoid.
In retrospect, this is roughly an algebraic version of the standard fact that every object of a model category (or more generally a category of fibrant objects or a category with a weak factorization system) admits a simplicial resolution which is an internal Kan complex, i.e. a nonalgebraic $\infty$-groupoid. Note, however, that the first technical condition above (stability of $L$-maps under pullback along $R$-maps) seems to be necessary for the algebraic version of the result to go through.
A survey is in chapter 1 of
Extensionality and intensionality isses are studied in
Michael Warren, Homotopy theoretic aspects of constructive type theory, PhD thesis (2008) (pdf)
Steve Awodey and Michael Warren, Homotopy theoretic models of identity types, arXiv.
Nicola Gambino, Richard Garner, The identity type weak factorisation system, arXiv
Richard Garner, Benno van den Berg, Topological and simplicial models of identity types, arXiv.