We will now see how to reformulate the identification elimination rule into an “induction principle” for singletons. The idea is the following:
If you want to prove something about all \left \{u\right \}^\pm _{A} it suffices to consider just the trivial element \left \langle u,\mathsf {refl}_u\right \rangle .
In other words, \left \langle u,\mathsf {refl}_u\right \rangle is the “base case” for an induction on \left \{u\right \}^\pm _{A}, in the same way that 0 is the base case for mathematical induction; the induction here is simpler than mathematical induction, because there is only a base case and no inductive step.
We will derive singleton induction using the \mathsf {J} elimination rule, which we recall below:
\frac {
w:u=_Av\quad
y:A,z:u=_Ay\vdash C[y,z]~\mathit {type}\quad
c:C[u,\mathsf {refl}_u]
}{
\mathsf {J}_{y,z\mathpunct {.} C[y,z]}(w; c)
:C[v,w]
}
We wish to define the following derived forms:
\frac {
z:\left \{u\right \}^-_{A}\vdash C[z]~\mathit {type}
\quad
p:\left \{u\right \}^\pm _{A}
\quad
c:C[\left \langle u,\mathsf {refl}_u\right \rangle ]
}{
\mathsf {J}^\pm _{z\mathpunct {.}{C[z]}}(p; c): C[p]
}
We can specify the following implicit definitions for the derived induction principles:
\begin {aligned}
\mathsf {J}^+_{z\mathpunct {.}C[z]}(\left \langle u,\mathsf {refl}_u\right \rangle ; c) &:\equiv c\\
\mathsf {J}^-_{z\mathpunct {.}C[z]}(\left \langle u,\mathsf {refl}_u\right \rangle ; c) &:\equiv c
\end {aligned}
The first one above is easy to justify:
\begin {aligned}
\mathsf {J}^+_{z\mathpunct {.}{C[z]}}(p; c) &:\equiv
\mathsf {J}_{y,z\mathpunct {.}{C[\left \langle y,z\right \rangle ]}}(
p.2
; c)
\end {aligned}
The second one is harder to justify. It turns out that the simplest way to proceed is to first define a “defective” version of \mathsf {J}^- in terms of \mathsf {J}^- that has the wrong type, and then use transport to correct the type. In particular, we define:
\begin {aligned}
&
\tilde {\mathsf {J}}^-_{z\mathpunct {.}C[z]}(p;c) : C \left \langle p.1, \overline {\overline {p.2}}\right \rangle
\\
&\tilde {\mathsf {J}}^-_{z\mathpunct {.}C[z]}(p;c) :\equiv
\mathsf {J}^+_{z\mathpunct {.}{C\left [\left \langle z.1,\overline {z.2}\right \rangle \right ]}}\left (\left \langle p.1,\overline {p.2}\right \rangle ; c\right )
\end {aligned}
Then we define:
\mathsf {J}^-_{z\mathpunct {.}{C[z]}}(p; c) :\equiv
\mathsf {transport}_{q\mathpunct {.} C[\left \langle p.1,q\right \rangle ]}(\mathsf {flipInv}~(p.1)~u~(p.2);
\tilde {\mathsf {J}}^-_{z\mathpunct {.}C[z]}(p;c)
)
You need to convince yourself that all of the above is well-typed.
The benefit of singleton induction is that it provides a (perhaps) less noisy way to think about the identification elimination rule, and gives a schema for defining correct implicit definitions by “matching” on identifications no matter which side of the identification the “fixed” variable is located.
The three operations \mathsf {J}, \mathsf {J}^+, and \mathsf {J}^- are all equivalent, in the sense that you can derive any two from the remaining one. There is a further option seen in Exercise [01EE], which is also equivalent to all of these. In the end, we work mainly with implicit definitions which we know to be justified by any one of these principles.