Flipping identifications [01EJ]

Fix A~\mathit {type} and u,v:A. Given an identification p:u=_Av we should be able to define a “flipped” identification \bar {p}:v=_Au. We will do so by means of an implicit definition:

\begin {aligned} & \mathsf {flip}: {\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(u,v:A)}}\; u=_Av\to v=_Au \\ & \mathsf {flip}~u~u~\mathsf {refl}_u :\equiv \mathsf {refl}_u \end {aligned}

Then we define \bar {p}:\equiv \mathsf {flip}\,u\,v\,p when u,v are understood.

Above we were allowed to collapse the pair (v,p) to (u,\mathsf {refl}_u) by virtue of the identification elimination rule. The corresponding explicit definition is as follows:

\mathsf {flip} :\equiv \lambda u,v,p\mathpunct {.} \mathsf {J}_{y,z\mathpunct {.}y=u}(p; \mathsf {refl}_u)