Lectures onType Theory
Chapter 189
Chapter 189Core route

Types as ∞-Groupoids

A path p:a=b can be reversed, concatenated with a path q:b=c, and mapped by a function f:AB. These operations satisfy the groupoid laws up to higher paths, and identity elimination computes each operation. Throughout the chapter the rules remain those of the intensional base through definition 30.1; univalence is not assumed.

Paths and the groupoid structure

We first fix the path notation and calculate its groupoid structure.

Convention 62.1 — Path language

We write a=Ab for the identity type IdA(a,b), omitting the subscript when it is determined; its elements are called paths from a to b, and the path space from a to b is the identity type displayed as the object-level formula a=b. Judgmental equality remains . Explicit metatheoretic equalities—for example, equalities of external natural-number indices or side-condition data—retain their ordinary meaning; the syntactic role therefore determines which reading of = is in force. Until univalence is introduced, every path constructed here is a term of the intensional identity type.

Type families are maps into a universe, P:AU (definition 29.1); we write P(x) for the fiber over x and trpP:P(x)P(y) for transport along p:x=y (chapter 30). We call A the base, x:AP(x) the total space, and a dependent function f:x:AP(x) a section of P.

Proposition 62.2 — The groupoid structure, transcribed

Let a,b,c,d:A and p:a=b, q:b=c, r:c=d. The operations of chapter 30 give refla:a=a, p1:b=a, and pq:a=c, subject to the laws of theorem 30.20:

  1. preflbp, and there is p:reflap=p (the left unit law), whose construction computes: reflareflrefla;

  2. pp1=refla and p1p=reflb;

  3. (p1)1=p;

  4. αp,q,r:(pq)r=p(qr).

All constructions compute on reflexivity: (refla)1refla, trreflaPidP(a), and apf(refla)reflf(a).

Proof of Proposition 62.2 — The groupoid structure, transcribed

Proof. Define pq by identity induction on q, with preflbp. A second identity induction gives p:reflap=p and computes reflareflrefla. Identity induction likewise gives inversion and the inverse and associativity paths; these are the formulas of theorem 30.20(ii)–(iv) in the notation of convention 62.1. ◻

Laws (i)–(iv) are themselves paths, in path spaces of path spaces, and so support their own algebra. The basic operations one level up are whiskerings, which map a path between paths through concatenation on one chosen side.

Construction 62.3 — Whiskering

Let p,q:a=b and r,s:b=c, and let α:p=q, β:r=s. Define the right and left whiskerings αr:=ap()r(α):pr=qr,qβ:=apq()(β):qr=qs, where ()r:=λt.tr and q():=λt.qt. Both compute on reflexivity: reflprreflpr and qreflrreflqr. Since treflbt, the function ()reflb is judgmentally the identity, so moreover αreflbapid(α). The two horizontal composites of α and β are αβ:=(αr)(qβ),αβ:=(pβ)(αs), both of type pr=qs.

Lemma 62.4 — The horizontal composites agree

For all p,q:a=b, r,s:b=c, α:p=q, and β:r=s, we have αβ=αβ.

Proof of Lemma 62.4 — The horizontal composites agree

Proof. The endpoints p,q of α and r,s of β are generic variables, so identity induction (the path-induction discipline of chapter 30) applies twice: we may assume α is reflp and β is reflr. All four whiskerings then compute to reflexivities, and since ureflu, reflpreflrdefinitionsofandwhiskeringreflprreflprrightunitcomputationreflprdefinitionsofandwhiskeringreflpreflr, so reflreflpr inhabits the instance. ◻

Remark 62.5 — The tower

Repeating the identity-type construction produces a=b, p=q, and paths between those paths. At each fixed finite level the operations of proposition 62.2 apply again, and whiskering is the first interaction between two levels.

Exercise 62.1

★☆☆ Let p:a=b. Show that if q:b=a satisfies pq=refla, then q=p1: inverses are unique up to a path. Conclude that the laws of proposition 62.2(ii) determine p1 among all q:b=a.

Functorial actions and transport

Given p:x=y and u:P(x), the first local problem is to move u into P(y) without pretending that the two fibers are judgmentally equal. Transport performs that move; ordinary and dependent path action explain how functions and sections respect it.

Lemma 62.6 — Identity and constant functions

Let p:x=Ay and b:B, and write constb:=λz.b:AB. Then (i) apidA(p)=p, and (ii) apconstb(p)=reflb.

Proof of Lemma 62.6 — Identity and constant functions

Proof. By identity induction on p; in each case both sides compute to a reflexivity, so reflrefl inhabits the required path. ◻

Lemma 62.7 — Transport is functorial in every argument

Let P:AU, let p:x=Ay and q:y=Az, and let u:P(x).

  1. trpqP(u)=trqP(trpP(u));

  2. for f:AA, p:x=Ay, and u:P(f(x)), trpPf(u)=trapf(p)P(u);

  3. for a family of maps h:x:AP(x)Q(x), trpQ(h(x)(u))=h(y)(trpP(u));

  4. for B:U and b:B, there is trconstp(b):trpλz.B(b)=b, computing to reflb when p is reflx.

Proof of Lemma 62.7 — Transport is functorial in every argument

Proof. (i) By identity induction on q: for qrefly we have preflyp and trreflyPid, so both sides are judgmentally trpP(u), and refl concludes. (ii)–(iv) are as follows.

(ii) Identity induction on p reduces both sides to u: the left side uses the transport computation for the composite family, and the right side first uses apf(refl)refl and then the same transport computation.

(iii) Identity induction on p reduces the asserted path to h(x)(u)=h(x)(u), so reflexivity concludes.

(iv) Identity induction on p reduces transport in the constant family to the identity. Define trconstreflx(b):=reflb; its computation clause is therefore judgmental. ◻

Lemma 62.8 — Transport in path families

Let a0:A, let f,g:AB, and let p:x=Ay.

  1. For q:a0=x: trpλz.(a0=z)(q)=qp;

  2. for q:x=a0: trpλz.(z=a0)(q)=p1q;

  3. for q:f(x)=g(x): trpλz.(f(z)=g(z))(q)=apf(p)1qapg(p).

Proof of Lemma 62.8 — Transport in path families

Proof. (i) By identity induction on p: the left side computes to q and the right side to qreflxq, so reflq concludes. (iii) By identity induction on p: the left side computes to q, and the right side computes judgmentally as apf(reflx)1qapg(reflx)(reflq)reflreflq, so the inverse q1 of the left unit law concludes.

(ii) Identity induction on p reduces the left side to q and the right side to reflx1qreflxq. The inverse q1:q=reflxq is the required path. ◻

Definition 62.9 — Paths over a path

Let P:AU, p:x=Ay, u:P(x), v:P(y). The type of paths from u to v over p is (u=pPv):=(trpP(u)=P(y)v). Thus apdf(p):f(x)=pPf(y) for every section f:x:AP(x): a section carries each path of the base to a path lying over it. For non-dependent f:AB the two actions are related by apdf(p)=trconstp(f(x))apf(p). Identity induction on p proves the equation: both sides reduce to reflexivity after constant-family transport and the unit law.

Exercise 62.2

★★☆ Prove items (ii)–(iv) of lemma 62.7 and item (ii) of lemma 62.8, recording which side of each equation computes judgmentally. Deduce from lemma 62.8(iii) and lemma 62.6 that trpλz.(z=z)(q)=p1qp for p:x=y and q:x=x.

Exercise 62.3

★☆☆ Prove the comparison stated in definition 62.9: apdf(p)=trconstp(f(x))apf(p) for f:AB and p:x=Ay.

Homotopies and naturality

Between functions there are two comparisons: paths f=g, and pointwise families of paths. This section studies the second and proves its characteristic property, naturality; as an application we obtain the Eckmann–Hilton commutativity of the second loop space.

Definition 62.10 — Homotopy

Let P:AU and f,g:x:AP(x). A homotopy from f to g is an element of (fg):=x:Af(x)=P(x)g(x).

Remark 62.11

A path p:f=g yields the homotopy λx.ap(hh(x))(p); whether every homotopy so arises is the question of function extensionality. Its expected independence from the base has the exact-signature boundary recorded in remark 111.89. No inverse to happly is assumed in this chapter; cf. remark 62.34.

Lemma 62.12

For each P:AU, the relation is reflexive, symmetric, and transitive: the types ff, (fg)(gf), and (fg)(gh)(fh) are inhabited.

Proof of Lemma 62.12

Proof. The three witnesses are hrefl(f):=λx.reflf(x),by path reflexivity,hsym(H):=λx.H(x)1,by path inversion,htrans(H,K):=λx.H(x)K(x),by path concatenation. Their codomains are respectively ff, gf, and fh by proposition 62.2. ◻

Theorem 62.13 — Homotopies are natural

Let f,g:AB, let H:fg, and let p:x=Ay. Then H(x)apg(p)=apf(p)H(y), that is, the square Mathematical diagramDiagram commutes up to a path.

Proof of Theorem 62.13 — Homotopies are natural

Proof. The endpoints of p are generic, so identity induction applies: we may assume p is reflx. Both ap’s compute, and the goal becomes H(x)reflg(x)=reflf(x)H(x). The left side is judgmentally H(x); the right side is identified with H(x) by the left unit law. Hence H(x)1 inhabits the instance. ◻

Corollary 62.14

Let f:AA and H:fidA. Then H(f(x))=apf(H(x)) for every x:A.

Proof of Corollary 62.14

Proof. Instantiate theorem 62.13 at the path H(x):f(x)=x: H(f(x))apid(H(x))=apf(H(x))H(x). By lemma 62.6(i) replace apid(H(x)) by H(x) on the left; whiskering both sides on the right with H(x)1 and cancelling by the inverse and associativity laws of proposition 62.2 yields the claim. ◻

Definition 62.15 — Loop spaces

A pointed type is a pair (A,a) with a:A. Its loop space is the pointed type Ω(A,a):=((a=a), refla), and its iterated loop spaces are Ωn+1(A,a):=Ωn(Ω(A,a)), with Ω0(A,a):=(A,a). We write Ω2(A,a) also for the underlying type refla=refla.

Lemma 62.16 — Whiskering by reflexivity, one level up

For α,β:Ω2(A,a): (i) αrefla=α, and (ii) reflaβ=β.

Proof of Lemma 62.16 — Whiskering by reflexivity, one level up

Proof. (i) By construction 62.3, αreflaapid(α), and apid(α)=α by lemma 62.6(i).

(ii) The left unit laws form a homotopy :(refla())id on the type a=a. Naturality (theorem 62.13) at the path β:refla=refla gives reflaapid(β)=aprefla()(β)refla. Since reflareflrefla (proposition 62.2(i)) and ureflu, the right side is judgmentally reflaβ, so reflaβ=naturalityreflreflaapid(β)=leftunitapid(β)=lemma62.6(i)β. ◻

Theorem 62.17 — Eckmann–Hilton

For every type A, point a:A, and α,β:Ω2(A,a), αβ=βα.

Proof of Theorem 62.17 — Eckmann–Hilton

Proof. Instantiate construction 62.3 at pqrsrefla; since reflareflarefla, all four composites lie in Ω2(A,a), and by definition αβ(αrefla)(reflaβ),αβ(reflaβ)(αrefla). Let u1:αrefla=α and u2:reflaβ=β be the paths of lemma 62.16. Their horizontal composites, one level up, give u1u2:αβ=αβ and u2u1:αβ=βα. Composing with lemma 62.4, αβ=αβ=αβ=βα. ◻

Exercise 62.4

★☆☆ Show that homotopies compose with functions on both sides: from H:fg (with f,g:AB), h:BC, and e:AA, construct hH:hfhg and He:fege.

Exercise 62.5

★★☆ (Dependent naturality.) Let P:AU, f,g:x:AP(x), H:fg, and p:x=Ay. Show aptrpP(H(x))apdg(p)=apdf(p)H(y).

Equivalences

A map of spaces is an equivalence when each of its fibers is a single point up to deformation. This section makes that the definition — contractible fibers — and calibrates it against the naive notion of two-sided inverse.

Definition 62.18 — Fibre

The fiber of f:AB at b:B is fibf(b):=a:Af(a)=Bb.

Definition 62.19 — Contractibility

A type A is contractible if isContr(A):=c:Ax:Ac=Ax is inhabited; given (c,C):isContr(A) we call c the center and C the contraction. (Note that C is precisely a homotopy constcidA.)

Lemma 62.20 — Singletons are contractible

For every a:A, the types x:Aa=Ax and x:Ax=Aa are contractible, with centers (a,refla).

Proof of Lemma 62.20 — Singletons are contractible

Proof. For the first: by Σ-η (definition 27.9) it suffices to produce, for all x:A and p:a=x, a path (a,refla)=(x,p). The endpoint x and the path p are exactly the data of based path induction, a theorem of the base proved in theorem 30.26: it suffices to treat xa, prefla, where refl concludes. The second is symmetric, using based induction from the right endpoint. Apply identity induction to generic x:A and p:x=a with motive (a,refla)=(x,p); its reflexivity case is reflexivity. ◻

Definition 62.21 — Equivalence

A map f:AB is an equivalence if all its fibers are contractible: isEquiv(f):=b:BisContr(fibf(b)),(AB):=f:ABisEquiv(f). We abuse notation by writing f:AB for an equivalence and f(a) for the application of its underlying map.

Example 62.22

idA is an equivalence: its fiber at b is x:Ax=b, contractible by lemma 62.20. Consequently, for every P:AU and p:x=Ay, transport trpP:P(x)P(y) is an equivalence: the endpoints of p are generic, so by identity induction we may assume p is reflx, and trreflxPidP(x). In particular, identified types are equivalent.

Definition 62.23 — Quasi-inverse

A quasi-inverse of f:AB is a triple (g,η,ε): qinv(f):=g:BA(gfidA)×(fgidB).

Proposition 62.24 — Equivalences have quasi-inverses

isEquiv(f)qinv(f).

Proof of Proposition 62.24 — Equivalences have quasi-inverses

Proof. Let e:isEquiv(f); write (cb,Cb):=e(b). Taking components of the centers defines g:=λb.pr1(cb):BA and ε:=λb.pr2(cb):fgidB. For the other homotopy: for x:A the pair (x,reflf(x)) lies in fibf(f(x)), so the contraction gives Cf(x)((x,reflf(x))):cf(x)=(x,reflf(x)), and we set η(x):=appr1(Cf(x)((x,reflf(x)))):g(f(x))=x. ◻

For calculations, the useful converse says that a quasi-inverse suffices to prove contractibility of every fiber. Choose the center of fibf(b) to be (g(b),ε(b)). At bf(x) the path constructor of construction 62.25 would need ε(f(x))=apf(η(x))reflf(x), The fields of qinv(f) contain g,η,ε, but no path of this type. Lemma 62.26 replaces ε by a homotopic choice together with the missing triangle path.

Construction 62.25 — Paths in a fibre

Let f:AB, y:B, and (x,p),(x,p):fibf(y). From α:x=xandβ:p=apf(α)p we construct a path (x,p)=(x,p) in fibf(y). By identity induction on α (generalizing p, p into the motive) we may assume α is reflx; then β:p=reflf(x)p, so composing with the left unit law gives βp:p=p, and apλt.(x,t)(βp) is the required path.

Lemma 62.26 — Coherent improvement

Let (g,η,ε) be a quasi-inverse of f:AB. Then there are ε~:fgidBandτ:x:Aapf(η(x))=ε~(f(x)).

Proof of Lemma 62.26 — Coherent improvement

Proof. The original counit need not satisfy the triangle equation. Correct it at b:B by ε~(b):=ε(f(g(b)))1(apf(η(g(b)))ε(b)):f(g(b))=b. Two naturality equations determine the correction. First, corollary 62.14 applied to η:gfidA gives (1)η(g(f(x)))=apgf(η(x)). Second, naturality of ε:fgidB at apf(η(x)):f(g(f(x)))=f(x) gives (2)ε(f(g(f(x))))apf(η(x))=apfg(apf(η(x)))ε(f(x)). Functoriality of path action, proved by identity induction on η(x), identifies the first path on the right of (2) with apf(apgf(η(x))). Hence ε~(f(x))=(1)ε(f(g(f(x))))1(apfg(apf(η(x)))ε(f(x)))=(2)ε(f(g(f(x))))1(ε(f(g(f(x))))apf(η(x)))=proposition62.2apf(η(x)). Let τ(x) be the inverse of this path. Its type is exactly apf(η(x))=ε~(f(x)). This calculation is the coherent improvement of HoTT Book Theorem 4.2.3 [Uni13]; only its provenance, not a proof premise, is imported. ◻

Proof of Theorem 62.27 — Quasi-inverses suffice

Proof. Let (g,η,ε) be a quasi-inverse of f, improved by lemma 62.26 to (g,η,ε~,τ). Fix b:B; we contract fibf(b) onto the center (g(b),ε~(b)).

For the contraction, by Σ-η it suffices to produce, for all b:B, x:A, and p:f(x)=b, a path (g(b),ε~(b))=(x,p). Since b is generic, based path induction on (b,p) reduces this to the case bf(x), preflf(x), i.e. to (g(f(x)),ε~(f(x)))=(x,reflf(x)). Apply construction 62.25 with α:=η(x) and β:=τ(x)1:ε~(f(x))=apf(η(x))apf(η(x))reflf(x), the final judgmental equality being the right unit law. ◻

Proposition 62.28 — Composition and inversion

Identity maps are equivalences; if f:AB and g:BC then gf:AC; and every equivalence f:AB has an inverse equivalence f¯:BA with f¯fidA and ff¯idB.

Proof of Proposition 62.28 — Composition and inversion

Proof. By proposition 62.24 choose quasi-inverses (f¯,ηf,εf) and (g¯,ηg,εg). Then f¯g¯ is a quasi-inverse of gf: pointwise, f¯(g¯(g(f(x))))apf¯(ηg(f(x)))f¯(f(x))ηf(x)x, and symmetrically for the other composite. Likewise f itself is a quasi-inverse of f¯. Theorem 62.27 converts all three quasi-inverses into equivalences. ◻

Remark 62.29 — Why fibres, and not qinv

A definition of “f is an equivalence” is serviceable only if (a) it follows from qinv(f); (b) it implies qinv(f); (c) any two of its inhabitants are identified, so that being an equivalence is a property of f and AB carries no phantom data. For definition 62.21, (a) is theorem 62.27, (b) is proposition 62.24. Under function extensionality, (c) follows because any two contractibility witnesses are identified pointwise. By contrast, qinv(f) records a chosen inverse and two chosen homotopies. At f:=idA, its defining type is g:AA(gidA)×(gidA). Even after fixing g:=idA, the two homotopies remain independent fields. Taking qinv as the definition would make “AB” assert structure, not property.

Several other property-like definitions pass demands (a)–(c) and are equivalent to definition 62.21: bi-invertibility (a left and a right inverse, separately), half-adjoint equivalence (a quasi-inverse with the coherence τ — what lemma 62.26 really constructs), and path-splitness [Uni13]. The fiberwise definition is Voevodsky’s; under function extensionality, pointwise contractibility identifies every two witnesses, with no coherence data to manage. Categorically, the passage from qinv to any of these notions is the passage from equivalences to adjoint equivalences in a higher category.

Lemma 189.30 — Concatenation by a fixed path is an equivalence

For q:b=c, the map ()q:(a=b)(a=c) is an equivalence; for p:a=b, the map p():(b=c)(a=c) is an equivalence.

Proof of Lemma 189.30 — Concatenation by a fixed path is an equivalence

Proof. The quasi-inverse of ()q is ()q1. Associativity and the right inverse/unit laws of theorem 30.20 give both homotopies. The second map has p1() as quasi-inverse, with the left inverse/unit laws. Apply theorem 62.27 in both cases. ◻

Exercise 62.6

★☆☆ Derive the right-handed based path induction used in lemma 62.20: for a family C:x:A(x=a)U with c:C(a)(refla), construct elements of C(x)(p) for all x,p, computing to c on (a,refla).

Exercise 62.7

★☆☆ For P:AU, show fibpr1(a)P(a) for every a:A, where pr1:x:AP(x)A.

Exercise 62.8

★☆☆ Reprove lemma 189.30 by identity induction and compare the resulting quasi-inverses with those obtained from the groupoid laws.

Exercise 62.9

★★☆ Symmetrize lemma 62.26: keep ε fixed, replace η by a homotopic choice, and construct the triangle path apg(ε(y))=η~(g(y)). Type every whiskering and compare the result with the displayed counit correction.

Exercise 62.10

★★☆ Show that if f:AB, g:BC, and any two of f, g, gf are equivalences, then so is the third.

Path spaces of the negative formers

The path space of a dependent pair is controlled by its eliminator. This section carries out that calculation. The corresponding function-space statement requires function extensionality, while the unit case follows from its explicit contraction: if C(u):=u, then C(u)1C(v):u=v for any u,v:1, so any two points of 1 are connected. Proposition 62.32 proves the stronger path-space calculation.

Theorem 62.30 — Paths in Σ -types

Let P:AU and w,w:x:AP(x). The map Φw,w:(w=w)p:pr1(w)=pr1(w)trpP(pr2(w))=pr2(w) defined by identity induction with Φ(reflw):=(reflpr1(w),reflpr2(w)) is an equivalence: a path in the total space is exactly a path p in the base together with a path over p between the second components (definition 62.9).

Proof of Theorem 62.30 — Paths in Σ -types

Proof. We exhibit a quasi-inverse and invoke theorem 62.27.

The map pair=. Work with generic variables a,b:A. For u:P(a), v:P(b), p:a=b, and q:trpP(u)=v, define pair=(p,q):(a,u)=(b,v) by identity induction on p, generalizing u,v into the motive: for prefla we have trreflaP(u)u, so q:u=v, and we set pair=(refla,q):=apλt.(a,t)(q). This computes: pair=(refla,reflu)refl(a,u). For arbitrary w,w the map Ψw,w(p,q):=pair=(p,q) has the required type, since w(pr1(w),pr2(w)) by Σ-η (definition 27.9).

Round trip on paths. For r:w=w we show Ψ(Φ(r))=r by identity induction on r: for rreflw, Ψ(Φ(reflw))pair=(reflpr1(w),reflpr2(w))refl(pr1(w),pr2(w))Σηreflw, so refl concludes.

Round trip on pairs. We prove, for all generic a,b,u,v at once: for all p:a=b and q:trpP(u)=v, Φ(pair=(p,q))=(p,q). By identity induction on p (generalizing u,v), then on q:u=v (whose endpoints are now generic), both sides compute to (refla,reflu), and refl concludes. Instantiating at a:=pr1(w), u:=pr2(w), etc., and applying Σ-η yields the claim for Φw,w and Ψw,w. ◻

Lemma 62.31 — Fibrewise equivalences totalize

Let P,Q:AU and h:x:AP(x)Q(x), and define tot(h):=λw.(pr1(w),h(pr1(w))(pr2(w))):x:AP(x)x:AQ(x). If h(x) has a quasi-inverse for every x:A, then tot(h) is an equivalence.

Proof of Lemma 62.31 — Fibrewise equivalences totalize

Proof. Choose (k(x),ηx,εx) with k(x):Q(x)P(x), ηx:k(x)h(x)id, and εx:h(x)k(x)id. Then tot(k) is a quasi-inverse of tot(h): for w with x:=pr1(w), v:=pr2(w), tot(h)(tot(k)(w))(x,h(x)(k(x)(v)))=(x,v)w via pair=(reflx,εx(v)) (theorem 62.30), using trreflid; and symmetrically with η. Theorem 62.27 concludes. ◻

Proposition 62.32 — Paths in the unit type

For all x,y:1, (x=y)1.

Proof of Proposition 62.32 — Paths in the unit type

Proof. By the η-rule of 1 (chapter 27), xy. Define e:=const:(x=y)1 and d:=constrefl:1(x=y). For u:1 we have e(d(u))u by η, so refl inhabits edid. For p:x=y: the endpoints being generic variables of 1, identity induction on p reduces d(e(p))=p to d()refl=refl, and refl concludes. Theorem 62.27 finishes. ◻

Construction 62.33 — Pointwise application

For f,g:x:AP(x), identity induction defines happly:(f=g)(fg),happly(reflf):=λx.reflf(x).

Remark 62.34 — The Π case is not computable here

For Σ, 1, and (in § 62.6) the positive formers, the base theory itself determines the path spaces. For Π it does not: the statement “happlyf,g is an equivalence for all f,g” is precisely function extensionality. The base-theory independence transfer remains open at remark 111.89, and no rule of the fixed base signature gives an inverse to happly. The path space of the universe is likewise undetermined by the base. We therefore use fg, not f=g, as the available comparison of functions.

Exercise 62.11

★★☆ (Paths in fibers.) For f:AB, y:B, and (x,p),(x,p):fibf(y), show ((x,p)=(x,p))α:x=xp=apf(α)p, Start with theorem 62.30. Rewrite transport using lemma 62.8(iii), with g:=consty, and then lemma 62.6(ii). Finish with the concatenation equivalences of lemma 189.30 and lemma 62.31. Check that the inverse map agrees with construction 62.25.

Exercise 62.12

★☆☆ Construct, for u:P(x) and p:x=y, the lifting lift(u,p):=pair=(p,refl):(x,u)=(y,trpP(u)), and show appr1(lift(u,p))=p: every path of the base lifts to the total space, with prescribed starting point.

Positive formers: the encode–decode method

A positive type is presented by constructors, and its path spaces are not read off from eliminations; they must be computed against a guess. Trying to apply path induction directly to p:inl(a0)=x cannot discover the path space: path induction reduces p to reflexivity at inl(a0) but leaves the code at inr(b) undefined. A second incomplete attempt is to define only d0:C(a0)(a0=a0); the desired round trip at a generic endpoint would contain the undefined expression dx(ex(p)). Thus decoding must be a dependent function d:x:AC(x)(a0=x) before path induction can prove the round trip.

The coproduct already shows the successful pattern. Put C(inla):=(a0=a),C(inrb):=0, take c0:=refla0, and define the decoder by coproduct induction: d(inla)(q):=apinl(q), while d(inrb)(z):=ind0(z). At the two constructors the code–decode composite reduces respectively to path induction on q and to 0-elimination. This first calculation displays the data that the general statement packages.

The method below — guess a family of codes by recursion, compare it with the path family — is used throughout homotopy type theory, and we fix it as a theorem once and for all.

Theorem 62.35 — The encode–decode method

Let A be a type and a0:A. Suppose given

  1. a family C:AU (codes) and an element c0:C(a0);

  2. a function d:x:AC(x)(a0=x) (decoding),

and define the encoding e:x:A(a0=x)C(x) by e(x)(p):=trpC(c0). If

  1. d(a0)(c0)=refla0, and

  2. e(x)(d(x)(c))=c for all x:A and c:C(x),

then e(x) and d(x) are mutually quasi-inverse for every x:A; in particular (a0=x)C(x) for all x:A.

Proof of Theorem 62.35 — The encode–decode method

Proof. Hypothesis (ii) says e(x)d(x)id. For the other composite we show d(x)(e(x)(p))=p for all x and p:a0=x together: since x is generic, based path induction reduces to xa0, prefla0, where d(a0)(e(a0)(refla0))d(a0)(trreflC(c0))d(a0)(c0)=refla0 by (i). Thus d(x) is a quasi-inverse of e(x), and theorem 62.27 concludes. ◻

Remark 62.36 — The recipe

First define C by the recursor of the positive former into a universe, a large elimination licensed by definition 29.1. Take c0 to be the code of reflexivity. Next use one induction on x to define d:x:AC(x)(a0=x) together with ρ:x:Ac:C(x)e(x)(d(x)(c))=c. In each constructor branch, compute e on the branch chosen for d and close the corresponding branch of ρ with the available induction hypotheses. Finally, based path induction proves d(x)(e(x)(p))=p. The decoder must be defined for all x simultaneously before that last induction is available.

Theorem 62.37 — Paths in coproducts

Let A,B be types and a0:A. Define C:A+BU by the recursor (chapter 28): C(inl(a)):=(a0=a),C(inr(b)):=0. Then (inl(a0)=x)C(x) for every x:A+B.

Proof of Theorem 62.37 — Paths in coproducts

Proof. We verify the hypotheses of theorem 62.35 at the point inl(a0), with c0:=refla0:C(inl(a0)) — well-typed since C(inl(a0))(a0=a0). Define d by the induction principle of A+B: d(inl(a))(c):=apinl(c),d(inr(b))(c):=rec0(c). (i): d(inl(a0))(refla0)apinl(refla0)reflinl(a0), so refl suffices.

(ii): by induction on x. For xinl(a) and c:a0=a, e(inl(a))(apinl(c))trapinl(c)C(refla0)=trcCinl(refla0)by lemma 62.7(ii)trcλz.(a0=z)(refla0)recursor computation=refla0cby lemma 62.8(i)=cleft unit law. For xinr(b), c:0, and rec0(c) proves anything. ◻

Corollary 62.38

For all a,a:A and b,b:B: (inl(a)=inl(a))(a=a),(inr(b)=inr(b))(b=b),(inl(a)=inr(b))0. In particular inl and inr are injective up to paths, with disjoint images.

Proof of Corollary 62.38

Proof. The first and third are instances of theorem 62.37 with a0:=a, reading off C(inl(a))(a=a) and C(inr(b))0; the second is the symmetric computation with the roles of A and B exchanged. ◻

Theorem 62.39 — Paths in the natural numbers

Define C:NNU by double recursion (definition 28.21): C(0,0):=1,C(suc(m),0):=0,C(0,suc(n)):=0,C(suc(m),suc(n)):=C(m,n), and r:n:NC(n,n) by r(0):=, r(suc(n)):=r(n). Then (m=n)C(m,n)for all m,n:N.

Proof of Theorem 62.39 — Paths in the natural numbers

Proof. Define d:m:Nn:NC(m,n)(m=n) by double induction: d(0)(0)(c):=refl0,d(suc(m))(0)(c):=rec0(c),d(0)(suc(n))(c):=rec0(c),d(suc(m))(suc(n))(c):=apsuc(d(m)(n)(c)). Fix m; we apply theorem 62.35 to the pointed family (C(m,),r(m)) over N with decoding d(m), so that e(m)(n)(p)trpC(m,)(r(m)).

(i): d(m)(m)(r(m))=reflm, by induction on m. For 0: d(0)(0)(r(0))refl0. For suc(m): d(sucm)(sucm)(r(sucm))apsuc(d(m)(m)(r(m)))=apsuc(reflm)reflsuc(m) by the inductive hypothesis and congruence.

(ii): e(m)(n)(d(m)(n)(c))=c for all c:C(m,n), by double induction on m,n. Case (0,0): both e(0)(0)(refl0)trrefl(r(0)) and c by the η-rule of 1, so refl concludes. Mixed cases: c:0, and rec0(c) concludes. Case (suc(m),suc(n)), with c:C(m,n): put q:=d(m)(n)(c). Then e(sucm)(sucn)(apsuc(q))trapsuc(q)C(sucm,)(r(m))=trqC(sucm,suc())(r(m))lemma 62.7(ii)trqC(m,)(r(m))recursor computatione(m)(n)(q)=cinductive hypothesis, using r(sucm)r(m) in the first line and, in the third, that C(sucm,suck)C(m,k) holds judgmentally for the generic variable k by the computation rules of the recursor. ◻

Corollary 62.40

For all m,n:N: (i) (0=suc(n))0: zero is no successor; (ii) (suc(m)=suc(n))(m=n): the successor is injective up to paths.

Proof of Corollary 62.40

Proof. Instances of theorem 62.39, reading off C(0,sucn)0 and C(sucm,sucn)C(m,n)(m=n), the last equivalence being theorem 62.39 again, inverted. ◻

Proposition 189.42 — Natural-number equality is decidable

There is a term decN:m:Nn:N(m=n)+((m=n)0).

Proof of Proposition 189.42 — Natural-number equality is decidable

Proof. For the codes C(m,n) of theorem 62.39, define δ(m,n):C(m,n)+(C(m,n)0) by double recursion: δ(0,0):=inl(),δ(suc(m),0):=inr(λz.z),δ(0,suc(n)):=inr(λz.z),δ(suc(m),suc(n)):=δ(m,n). Let em,n:(m=n)C(m,n) be the equivalence of theorem 62.39, and let dm,n:C(m,n)(m=n) be its displayed inverse. If δ(m,n)=inl(c), return inl(dm,n(c)). If δ(m,n)=inr(h), return inr(λp.h(em,n(p))). Coproduct elimination gives decN(m,n) in both cases. ◻

Definition 189.43 — Propositions and sets

A type X is a mere proposition when isProp(X):=x:Xy:Xx=y is inhabited. A type X is a set when every identity type is a mere proposition, that is, when x:Xy:XisProp(x=y) is inhabited. Only these two uniqueness levels are used in the natural-number calculation below.

Proposition 189.44 — Natural numbers are a set

N is a set: for every m,n:N, the identity type m=n is a mere proposition.

Proof of Proposition 189.44 — Natural numbers are a set

Proof. By theorem 62.39, it suffices to prove that every code C(m,n) is a mere proposition. Double induction on m,n reduces this assertion to the two defining cases. The type 1 is contractible, hence a proposition: its center is , and 1-η identifies every inhabitant with the center. The type 0 is a proposition because from z:0 its required path family is obtained by 0-elimination.

Write e:(m=n)C(m,n) for theorem 62.39 and choose its quasi-inverse (g,η,ε) by proposition 62.24. If h identifies every two elements of C(m,n), then for p,q:m=n the composite η(p)1apg(h(e(p),e(q)))η(q):p=q does the same for m=n. Thus each path type is a mere proposition. ◻

Remark 62.41 — Discreteness, and what comes next

Every path space m=n in N is a mere proposition; therefore N is a set. The recursive codes C(m,n) decide whether two natural numbers are equal by proposition 189.42.

Exercise 62.13

★★☆ Define codes C:22U by the recursor (definition 28.7) with C(tt,tt):=C(ff,ff):=1 and C(tt,ff):=C(ff,tt):=0, and prove (x=y)C(x,y) for all x,y:2. Conclude (tt=ff)0 and compare with theorem 29.14.

Exercise 62.14

★★☆ Reconstruct the decision term of proposition 189.42 from theorem 62.39. In particular, give the four equations for the code decision and trace the positive and negative branches into an element of m:Nn:N(m=n)+((m=n)0): equality of natural numbers is decidable.

Exercise 62.15

★★☆ Show that under the hypotheses of theorem 62.35 the total space x:AC(x) is contractible. Conversely, show that if x:AC(x) is contractible and c0:C(a0), then the conclusion of theorem 62.35 holds for the decoding defined by transport from the contraction — the fundamental theorem of identity types. (Use lemma 62.20, lemma 62.31.)

Bibliographic notes

This chapter is the material of Chapter 2 of the HoTT Book [Uni13], redistributed into our rhythm; the name encode–decode and the systematic computation of path spaces former by former are from there, as is the type-theoretic Eckmann–Hilton argument. Our treatment of equivalences follows Rijke [Rij25]: the contractible-fiber definition (definition 62.21) is Voevodsky’s, and the route through coherently invertible maps in lemma 62.26, theorem 62.27, as well as the “fundamental theorem” packaging of exercise 62.15, are Rijke’s; the half-adjoint coherence itself is HoTT Book §4.2, echoing adjoint equivalences in higher category theory. That the identity type of Martin-Löf’s theory [ML84] endows each type with groupoid-like structure was first exploited semantically in the groupoid interpretation of Hofmann and Streicher [Hof95] (discharged in this book as theorem 54.34), the syntactic study of the laws beginning in Streicher’s habilitation [Str93]. The metatheoretic statement behind remark 62.5 — the tower of identity types of any type forms a weak ω-groupoid — is due to Lumsdaine and, independently, van den Berg and Garner (2010–2011), confirming the homotopy-hypothesis reading of type theory. Angiuli and Gratzer [AG26] present the same circle of ideas with emphasis on what it demands of proof assistants.

Suggested first pass.

None of these problems is a prerequisite for a later chapter. Begin with exercise 189.16, then complete exercise 189.17.

Exercise 189.16

★★☆ Reconstruct functoriality of transport, then calculate transport in a Σ-family along a composite path. Display the dependent second component and identify the whiskering needed for associativity.

Exercise 189.17

★★★ Practical project.path-groupoid-checker Implement in Agda or Kappa symbolic path expressions with unit, inverse, composition, ap, and transport. Normalize by the proved groupoid laws while preserving endpoints. The checker must accept the two functoriality calculations and reject composition of mismatched endpoints; a mutation that omits reversal of endpoints under inverse must fail the rejection test.

Search the book

Type to search the local edition.