1.12 Identity types
While the previous constructions can be seen as generalizations^{} of standard set theoretic constructions, our way of handling identity seems to be specific to type theory^{}. According to the propositionsastypes conception, the proposition^{} that two elements of the same type $a,b:A$ are equal must correspond to some type. Since this proposition depends on what $a$ and $b$ are, these equality types or identity types must be type families dependent on two copies of $A$.
We may write the family as ${\mathrm{\pi \x9d\x96\xa8\pi \x9d\x96\xbd}}_{A}:A\beta \x86\x92A\beta \x86\x92\mathrm{\pi \x9d\x92\xb0}$, so that ${\mathrm{\pi \x9d\x96\xa8\pi \x9d\x96\xbd}}_{A}\beta \x81\u2019(a,b)$ is the type representing the proposition of equality between $a$ and $b$. Once we are familiar with propositionsastypes, however, it is convenient to also use the standard equality symbol for this; thus β$a=b$β will also be a notation for the type ${\mathrm{\pi \x9d\x96\xa8\pi \x9d\x96\xbd}}_{A}\beta \x81\u2019(a,b)$ corresponding to the proposition that $a$ equals $b$. For clarity, we may also write β$a{=}_{A}b$β to specify the type $A$. If we have an element of $a{=}_{A}b$, we may say that $a$ and $b$ are equal, or sometimes propositionally equal if we want to emphasize that this is different from the judgmental equality $a\beta \x89\u2018b$ discussed in Β§1.1 (http://planetmath.org/11typetheoryversussettheory).
Just as we remarked in Β§1.11 (http://planetmath.org/111propositionsastypes) that the propositionsastypes versions of βorβ and βthere existsβ can include more information than just the fact that the proposition is true, nothing prevents the type $a=b$ from also including more information. Indeed, this is the cornerstone of the homotopical interpretation^{}, where we regard witnesses of $a=b$ as paths or equivalences between $a$ and $b$ in the space $A$. Just as there can be more than one path between two points of a space, there can be more than one witness that two objects are equal. Put differently, we may regard $a=b$ as the type of identifications of $a$ and $b$, and there may be many different ways in which $a$ and $b$ can be identified. We will return to the interpretation in http://planetmath.org/node/87569Chapter 2; for now we focus on the basic rules for the identity type. Just like all the other types considered in this chapter, it will have rules for formation, introduction, elimination, and computation, which behave formally in exactly the same way.
The formation rule says that given a type $A:\mathrm{\pi \x9d\x92\xb0}$ and two elements $a,b:A$, we can form the type $(a{=}_{A}b):\mathrm{\pi \x9d\x92\xb0}$ in the same universe^{}. The basic way to construct an element of $a=b$ is to know that $a$ and $b$ are the same. Thus, the introduction rule is a dependent function
$$\mathrm{\pi \x9d\x97\x8b\pi \x9d\x96\u038e\pi \x9d\x96\u038f\pi \x9d\x97\x85}:\underset{a:A}{\beta \x88\x8f}(a{=}_{A}a)$$ 
called reflexivity^{}, which says that every element of $A$ is equal to itself (in a specified way). We regard ${\mathrm{\pi \x9d\x97\x8b\pi \x9d\x96\u038e\pi \x9d\x96\u038f\pi \x9d\x97\x85}}_{a}$ as being the constant path at the point $a$.
In particular, this means that if $a$ and $b$ are judgmentally equal, $a\beta \x89\u2018b$, then we also have an element ${\mathrm{\pi \x9d\x97\x8b\pi \x9d\x96\u038e\pi \x9d\x96\u038f\pi \x9d\x97\x85}}_{a}:a{=}_{A}b$. This is welltyped because $a\beta \x89\u2018b$ means that also the type $a{=}_{A}b$ is judgmentally equal to $a{=}_{A}a$, which is the type of ${\mathrm{\pi \x9d\x97\x8b\pi \x9d\x96\u038e\pi \x9d\x96\u038f\pi \x9d\x97\x85}}_{a}$.
The induction^{} principle (i.e.Β the elimination rule) for the identity types is one of the most subtle parts of type theory, and crucial to the homotopy interpretation. We begin by considering an important consequence of it, the principle that βequals may be substituted for equals,β as expressed by the following:
 Indiscernability of identicals:

For every family
$$C:A\beta \x86\x92\mathrm{\pi \x9d\x92\xb0}$$ there is a function
$$f:\underset{(x,y:A)}{\beta \x88\x8f}\underset{(p:x{=}_{A}y)}{\beta \x88\x8f}C\beta \x81\u2019(x)\beta \x86\x92C\beta \x81\u2019(y)$$ such that
$$f(x,x,{\mathrm{\pi \x9d\x97\x8b\pi \x9d\x96\u038e\pi \x9d\x96\u038f\pi \x9d\x97\x85}}_{x}):\beta \x89\u2018{\mathrm{\pi \x9d\x97\x82\pi \x9d\x96\xbd}}_{C\beta \x81\u2019(x)}.$$
This says that every family of types $C$ respects equality, in the sense that applying $C$ to equal elements of $A$ also results in a function between the resulting types. The displayed equality states that the function associated to reflexivity is the identity function (and we shall see that, in general, the function $f\beta \x81\u2019(x,y,p):C\beta \x81\u2019(x)\beta \x86\x92C\beta \x81\u2019(y)$ is always an equivalence of types).
Indiscernability of identicals can be regarded as a recursion principle for the identity type, analogous to those given for booleans and natural numbers^{} above. Just as ${\mathrm{\pi \x9d\x97\x8b\pi \x9d\x96\u038e\pi \x9d\x96\u038c}}_{\mathrm{\beta \x84\x95}}$ gives a specified map $\mathrm{\beta \x84\x95}\beta \x86\x92C$ for any other type $C$ of a certain sort, indiscernability of identicals gives a specified map from $x{=}_{A}y$ to certain other reflexive^{}, binary relations^{} on $A$, namely those of the form $C\beta \x81\u2019(x)\beta \x86\x92C\beta \x81\u2019(y)$ for some unary predicate^{} $C\beta \x81\u2019(x)$. We could also formulate a more general recursion principle with respect to reflexive relations of the more general form $C\beta \x81\u2019(x,y)$. However, in order to fully characterize the identity type, we must generalize this recursion principle to an induction principle, which not only considers maps out of $x{=}_{A}y$ but also families over it. Put differently, we consider not only allowing equals to be substituted for equals, but also taking into account the evidence $p$ for the equality.
Title  1.12 Identity types 

\metatable 