8. Equivalences, Glue and univalence
The univalence principle says that equivalent types are equal: an equivalence e : Equiv A B gives a path ua e : Path U A B, and every path between types arises this way. In Kubus, ua is a definition, and transport along ua e computes to e.
Equivalences
A type is contractible if it has an element to which every element is connected by a path. A function is an equivalence if each of its fibers is contractible:
The identity is an equivalence, and so is every function with an inverse up to paths (an isomorphism); the library proves the latter in lemIso:
isoToEquiv : {A B : U} → (f : A → B) → (g : B → A) → section f g → retract f g → Equiv A BGlue types
To turn an equivalence into a path of types, we need a line of types that is A at one end and B at the other. Glue types build such lines. Glue B [φ -> (T, e)] is a type that
- is
Ton the facesφ, - and elsewhere is
B, with the elements ofTglued on along the equivalencee : Equiv T B.
With φ = (i = 0 \/ i = 1), gluing A along e at i = 0 and B along the identity at i = 1 gives exactly the line we want:
On the faces, the Glue type reduces to the glued type, so the endpoints are right by computation:
Elements of Glue types are introduced with glue and eliminated with unglue, which maps a glued element to the base B:
Transport along ua computes
Composition in a Glue type is defined in terms of composition in the base and the equivalence (it is the most intricate case of the evaluator). The upshot: transporting along ua e applies e.
false : Bool
true : Bool
false : Bool
Transporting backwards (along the reversed path; the ^1 is explained in chapter 10) applies the inverse. In general, transport along ua e agrees with e up to a path, by unglueing the filler of the transport:
The univalence axiom, as a theorem
ua gives one direction of univalence. The full statement says that ua is an equivalence, or equivalently that for each type A the type of types T with an equivalence T ≃ A is contractible: there is essentially only one such pair, (A, idEquiv A). The proof glues A along the given equivalence and shows that unglue is an equivalence:
The proof is in lib/univalence.ktt. Like everything else in the library, it is certified by the kernel.