Abstract 1 Introduction 2 A naive approach 3 Decomposition into equivalences 4 A refinement using 3-for-2 5 An example in synthetic homotopy theory References

Formalizing Equivalences Without Tears

Tom de Jong ORCID School of Computer Science, University of Nottingham, UK
Abstract

This expository note describes two convenient techniques in the context of homotopy type theory for proving – and formalizing – that a given map is an equivalence. The first technique decomposes the map as a series of basic equivalences, while the second refines this approach using the 3-for-2 property of equivalences. The techniques are illustrated by proving a basic result in synthetic homotopy theory.

Keywords and phrases:
3-for-2 property, 2-out-of-3 property, definitional equality, equivalence, formalization of mathematics, synthetic homotopy theory, type theory
Copyright and License:
[Uncaptioned image] © Tom de Jong; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Theory of computation Type theory
Acknowledgements:
I am grateful to Josh Chen, Stefania Damato, Martín Escardó, Nicolai Kraus, Fredrik Nordvall Forsberg, Stiéphen Pradal and Jon Sterling for comments on this note. I also thank the participants, organizers and support staff of the HIM trimester programme Prospects of Formal Mathematics for the opportunity to present the ideas in this note. Finally, I thank the anonymous reviewers for their helpful suggestions.
Funding:
This work was supported by The Royal Society (grant reference URF\R1\191055). The HIM programme was funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) under Germany’s Excellence Strategy – EXC-2047/1 – 390685813.
Editors:
Rasmus Ejlers Møgelberg and Benno van den Berg

1 Introduction

A very common problem in homotopy type theory (HoTT) [8] is to prove that a given map is an equivalence. The purpose of this short note is to describe convenient techniques for doing this, in particular when one is interested in formalizing the argument in a proof assistant. I claim no originality in the results of this note. Indeed, the technique I wish to highlight already informs much of the agda-unimath library developed by Rijke and contributors [5], while I picked up the other (decomposition) technique in this note via the Agda development TypeTopology of Escardó and collaborators [1] as well as Escardó’s comprehensive introduction to univalent foundations and its formalization in Agda [2]. Rather, I hope that this note will contribute to a greater awareness of these techniques, especially among junior type theorists.

Outline

The note is outlined as follows. Section 2 explains why directly proving that a map is an equivalence is often cumbersome. Section 3 describes an alternative technique by decomposing the given map into a sequence of (smaller) equivalences, while Section 4 further refines this method using the fact that equivalences satisfy the 3-for-2 property. These techniques are then illustrated in Section 5 in the context of synthetic homotopy theory [8, §8]. The example is self-contained and no prior knowledge of this area is required, although someone familiar with classical homotopy theory may find its simplicity appealing and consider it an invitation to learn more (see e.g. [7]).

Terminology

The 3-for-2 property of equivalences states that if any two maps in a commutative triangle are equivalences, then so is the third. This property is perhaps more commonly known as the 2-out-of-3 property. André Joyal proposed the name 3-for-2 by analogy to how discounts are often advertised; if you prove two maps are equivalences, then the third is for free [4]. Since we are interested in reducing the amount of (formalization) work and wish to get as much as possible for free, the analogy is quite apt and we prefer Joyal’s terminology in this note.

Foundations

As mentioned at the very start, this note is concerned with equivalences in homotopy type theory, although the issues and techniques described should carry over to other intensional type theories [3] and classes of maps that satisfy 3-for-2.111However, I don’t have a good illustration to hand of applying the techniques to a class of maps other than the equivalences. The class of n-equivalences, i.e. those maps whose n-truncation is an equivalence, comes to mind, but there I have found it easier to work with the fact that these maps can be characterized as those maps for which precomposition into n-types is an equivalence [6, Lem. 2.9] (see also [5, k-equivalences]). Moreover, while equivalences are invertible, maps satisfying 3-for-2 need not be of course, which means that it may be more difficult to arrange a diagram like in (2). We mostly adopt the terminology and notation of the HoTT Book [8], e.g. writing for judgemental (definitional) equality, using = for identity types (sometimes known as propositional equality), and for homotopies (i.e. pointwise identities).

2 A naive approach

Presented with the problem of showing that a map f:AB is an equivalence,222The precise definition of an equivalence is somewhat subtle, as discussed at length in [8, §4], but it is not too important for our purposes. a direct approach would be to try and construct a map g:BA together with identifications gfidA and fgidB. What makes this approach infeasible at times is that the construction of g may be involved, resulting in nontrivial computations (often involving transport) when showing that the round trips are homotopic to the identity maps, especially in proof-relevant settings such as HoTT.

In some cases we are lucky and the desired identifications hold definitionally, in which case the proof assistant can simply do the work for us by unfolding definitions. We return to using definitional equalities to our advantage in Section 4.

3 Decomposition into equivalences

Instead of directly arguing that a given map f:AB is an equivalence, it is often convenient to instead decompose f as a series of “building block equivalences”, general maps that we already know to be equivalences, as depicted below.

(1)

Some quintessential examples of such building block equivalences are as follows.

Projection from the total space of a contractible family.

Given a type X and a dependent type Y over it, if each Y(x) is contractible (i.e. it is equivalent to the unit type), then the projection map pr1:(x:X)Y(x)X is an equivalence. In fact, this is an equivalence if and only if each Y(x) is contractible.

Contractibility of singletons.

For any type X and x:X, the type (y:X)x=y is contractible and hence the two projection maps from (x:X)(y:X)x=y to X are equivalences.

Associativity of dependent sums.

For a type A, and dependent types B(a) and C(a,b) over A and (a:A)B(a), respectively, the map

(a:A)(b:B(a))C(a,b) (p:(a:A)B(a))C(p)
(a,b,c) ((a,b),c)

is an equivalence.

Reindexing dependent sums along an equivalence.

Given an equivalence between types f:AB and a dependent type Y(b) over B, the assignment

(a:A)Y(f(a)) (b:B)Y(b)
(a,y) (f(a),y)

is an equivalence. And of course there is a similar result for dependent products.

Distributivity of over .

Given a type A and dependent types B and Y over A and (a:A)B(a), respectively, the map

(a:A)(b:B(a))Y(a,b) (f:(a:A)B(a))(a:A)Y(a,f(a))
α (λa.pr1(α(a)),λa.pr2(α(a)))

is an equivalence with inverse (f,p)λa.(f(a),p(a)).

This, and especially its nondependent version

(a:A)(b:B)Y(a,b)(f:AB)(a:A)Y(a,f(a)),

is traditionally called the “type theoretic axiom of choice”, but this is a misnomer as there is no choice involved, see also [8, pp. 32 and 104].

Distributivity of over +.

Given a type A and dependent types X and Y over it, the map

(a:A)(X(a)+Y(a)) (a:A)X(a)+(a:A)Y(a)
(a,inlx) inl(a,x)
(a,inry) inr(a,y)

is an equivalence.

Congruence of type formers.

All type formers respect equivalences. For example, if we have f:AX and g:BY, then (A+B)(X+Y) by applying f to the elements on the left and g to the elements on the right.

Composition with a fixed path.

Given elements x, y and z of a type X and a path p0:x=y, the path composition maps
(z=x) (z=y) p pp0 and     (x=z) (y=z) p p0p
are equivalences.

This list is not exhaustive, but should give a good impression of the available building blocks. The interested reader may find many more examples in [1, UF.EquivalenceExamples].

The idea is to reduce the task of proving that f is an equivalence to identifying suitable building blocks – the equivalences in (1) – and proving that the diagram (1) commutes. It is the latter point that may pose similar difficulties to those explained in the previous section: the commutativity proof could involve nontrivial computations. We turn to a refinement in the next section to address this.

We should mention that this technique is still very valuable, especially when we are not interested in having a particular equivalence, or when there is a unique such equivalence, e.g. when proving that a type X is contractible.

4 A refinement using 3-for-2

To address the issue identified above, we will make use of the fact that equivalences satisfy the 3-for-2 property:

Lemma 1 (3-for-2 for equivalences, [8, Thm. 4.7.1]).

In a commutative triangle

if two of the maps are equivalences, then so is the third.

Rather than decomposing f, the idea is to simply involve f into any commutative diagram where all (other) maps are equivalences, as depicted below.

(2)

By the 3-for-2 property, we can still conclude that f is an equivalence from (2), but verifying the commutativity may now be easier, especially when the type Xn is simpler than B. Indeed, we can often ensure this in practice as illustrated and commented on at the end of the next section.

5 An example in synthetic homotopy theory

Usually [8, §7.5], a type is said to be n-connected if its n-truncation is contractible. For us, the following characterization may serve as a definition.

Proposition 2 ([8, Cor. 7.5.9]).

A type A is n-connected if and only if for every n-type333We recall from [8, §7.1] that the n-types are inductively defined for n2: a 2-type is a contractible type and an (n+1)-type is a type whose identity types are n-types. B, the constants map

B (AB)
b λa.b

is an equivalence.

We will illustrate the above techniques by giving a slick proof of a well-known result (see e.g. [8, Thm. 8.2.1]) in homotopy theory: taking the suspension of a type increases its connectedness by one. The reader may wish to compare the proof below to that given in op. cit, or inspects its formalization as part of the agda-unimath library [5, Suspensions increase connectedness].

For completeness, we recall suspensions in homotopy type theory.

Definition 3 (Suspension Σ).

The suspension ΣA of a type A is the pushout of the span 𝟏A𝟏. Equivalently, it is the higher inductive type generated by two point constructors N,S:ΣA (short for North and South) and a path constructor merid:AN=S (short for meridian).

Figure 1: Illustration of the suspension of a type A. The lines from N to S going through the points a:A and b:A represent the paths merid(a) and merid(b), respectively.

We shall only need the following basic fact about suspensions which is just the universal property of the suspension as a pushout. (We recall from [8, §2.2] that apg denotes the action of g on the identity types.)

Proposition 4 (Universal property of the suspension, [8, Exer. 6.11]).

The map

(ΣAB) (bN:B)(bS:B)(AbN=bS)
g (g(N),g(S),λa.apg(merid(a)))

is an equivalence for all types A and B.

Theorem 5.

The suspension of an n-connected type is (n+1)-connected.

Proof.

Let A be an n-connected type and B an (n+1)-type. By Proposition 2, we need to show that the constants map consts:B(ΣAB) is an equivalence. We first consider the evaluation map

eval:(ΣAB)Bdefined byeval(g):g(N),

and note that the diagram

commutes definitionally. Hence, by 3-for-2, it suffices to prove that eval is an equivalence. We use the decomposition technique to do so and consider the following diagram.

(3)

Note that because A is n-connected and bN=bS is an n-type (since B is an (n+1)-type), the constants map (bN=bS)(AbN=bS) is an equivalence. The middle equivalence in the diagram (3) is induced by the inverse of this map. It should be stressed that the definitional behaviour of this inverse is completely irrelevant for verifying the commutativity of the diagram (3); we only need to know the middle map’s behaviour on the first two components of the Σ-types to see that the diagram commutes definitionally.

Finally, the first map in the decomposition of eval is an equivalence by Proposition 4 and the last map is an equivalence by contractibility of singletons (from page Contractibility of singletons.).

We end this note by pointing out an important heuristic that is nicely illustrated by the above proof: We always try to orient the maps in our diagrams towards the simplest possible type – which in (3) is clearly B. The reason for this is that checking commutativity should then be the easiest as there is relatively little data in the target type to compare. Similarly, we defined a section of eval, rather than directly defining a map B(ΣAB) and proving it’s an inverse to eval which would involve the cumbersome task of comparing functions ΣAB for equality.

References