In HoTT, does $\prod_{T : \mathcal{U}} T \to T$ have only one element

homotopy-type-theorytype-theory

In Homotopy Type Theory, I can define

$id : \underset{T : \mathcal{U}}{\prod} T \to T$

by

$id(T, t) \equiv t$

But, are there any other elements of $\prod_{T:\mathcal{U}}T \to T$ ? I have been able to prove the following weaker statement with path induction:

Given $f: \underset{T : \mathcal{U}}{\prod} T \to T$

$proof : \underset{A, B : \mathcal{U}}{\prod} \underset{p : A = B}{\prod} \texttt{idtoequiv}(p) \circ f(A) = f(B) \circ \texttt{idtoequiv}(p)$

by

$proof(A, A,refl) \equiv refl$

So that if $T : \mathcal{U}$ and $e : T \to T$ is an equivalence, then $proof(T, T, ua(e)) : e \circ f(T) = f(T) \circ e$

Essentially, this is saying that for any such function $f$, $f(T)$ must commute with all equivalences on T. This is enough to prove (at least informally, I don't know about in type theory) that $f$ is the identity on any set except for the two element set. But what about general types?

Best Answer

It is not possible to construct, inside of type theory, an inhabitant of this type that is provably different from the polymorphic identity function. This is a metatheoretic fact known as parametricity.

On the other hand, it is not possible to prove inside of type theory that the identity function is the only element of this type, because as Berci says in the comments, there are models in which it has other elements. In particular, if excluded middle holds (such as in the simplicial set model of univalence), then one can define (internally) such a function to swap the two elements of the two-element set and be the identity everywhere else. In fact the converse also holds: if there is an element of this type that is not the identity on the two-element set, then excluded middle holds. This and various other facts about similar parametricity principles are proven in the paper Parametricity, automorphisms of the universe, and excluded middle by Booij, Escardo, Lumsdaine, and myself.

Related Question