Lectures onType Theory
ch:categories: ch:categories
appendix sectionsolutions

ch:categories: ch:categories

exercise 141.1.

With Θ=z:22 and ρ=(zff), ρτ=((zff)[τ])=((λw:2.y)ff):ΔΛ, so (ρτ)σ=(((λw:2.y)ff)[(fx)/y])=((λw:2.fx)ff), the bound w needing no change because w is not free in fx. On the other side, τσ=(λw:2.fx) by the calculation in the text, and ρ(τσ)=((zff)[(λw:2.fx)/z])=((λw:2.fx)ff). The two lists coincide, as proposition 141.7 requires.

exercise 141.2.

By the definition of composition in example 141.19, (x,x)RRy.(x,y)R(x,y)R,(y,y)RRx.(x,y)R(x,y)R. Hence idARR says xA.y.(x,y)R, which is totality, and RRidB says (x,y)R(x,y)Ry=y, which is single-valuedness. A relation is the graph of a function exactly when it is total and single-valued: the function sends x to the unique y with (x,y)R.

exercise 141.3.

First the claim in the hint. By the clauses of definition 2.41, (e1e2)[σ] is an application, (λy:B.b)[σ] is an abstraction, and tt[σ]=tt, ff[σ]=ff; so if t[σ] is a variable then t is a variable xi and t[σ]=σ(xi).

Let σ:ΓΔ and τ:ΔΓ with τσ=idΓ and στ=idΔ. The first equation says τ(xi)[σ]=xi for each declaration xi:Ai of Γ; by the claim, τ(xi) is a variable yk(i) of Δ with σ(yk(i))=xi. Symmetrically the second equation gives, for each yj:Bj of Δ, a variable xm(j) with σ(yj)=xm(j) and τ(xm(j))=yj. Then m(k(i))=i and k(m(j))=j, so k and m are mutually inverse bijections between the declarations of Γ and of Δ. Typing of the components gives Δyk(i):Ai, so Bk(i)=Ai. Thus Δ lists the same types as Γ, in the order given by k, under the renaming xiyk(i).

Conversely, if Δ is obtained from Γ by a bijection k on positions with Bk(i)=Ai and a renaming, then σ:=(xm(1),,xm(|Δ|)) and τ:=(yk(1),,yk(|Γ|)) are substitutions, and (τσ)(xi)=yk(i)[σ]=xm(k(i))=xi, likewise for the other composite.

exercise 141.4.

Let 0 and 0 be initial and let i:00 and i:00 be the unique arrows. Then ii:00 and id0 are both arrows 00, so they are equal by uniqueness; likewise ii=id0. Any isomorphism 00 is an arrow 00, hence equals i. Compared with the displayed proof, every arrow has been reversed: t:11 became i:00 with the source and target exchanged, and the composite tt:11 became ii:00, which is the reversed composite topt read in Cop.

exercise 141.5.

Let rf=ida. If fu=fu for u,u:ta, then u=unitidau=(rf)u=assoc.r(fu)=hyp.r(fu)=assoc.(rf)u=u, so f is monic. If moreover f is epic, compute (fr)f=assoc.f(rf)=fida=f=idbf; cancelling the epimorphism f on the right gives fr=idb. Together with rf=ida this makes f an isomorphism with inverse r.

exercise 141.6.

If gf=ida and fg=idb, then F(g)F(f)=(141.4)F(gf)=hyp.F(ida)=(141.4)idF(a), and likewise F(f)F(g)=idF(b); so F(f) is an isomorphism and, by lemma 141.22, F(f)1=F(g)=F(f1).

For the converse, let P={a,b} with ab and not ba, let Q be the one-element preorder {}, and let F send both objects to ; F is monotone, hence a functor by example 141.33. The arrow f given by ab is sent to id, an isomorphism, but f is not an isomorphism in P, because an inverse would be an arrow ba and homP(b,a) is empty.

exercise 141.7.

For f:ab, g:bc in C and (u,u)(K×K)(c), (K×K)(gf)(u,u)=(K(gf)(u),K(gf)(u))=(141.5)(K(f)(K(g)(u)),K(f)(K(g)(u)))=(K×K)(f)((K×K)(g)(u,u)), and (K×K)(ida)(u,u)=(u,u) by the identity clause of (141.5) in each component. For the conditional: if Γe:2 and Γei:A then Γif(e;e1;e2):A by the conditional rule of chapter 2, so the map is well defined, and the nonbinding-constructor clause of definition 2.41, which recurses in the immediate subterms, gives, for every σ:ΓΔ, if(e;e1;e2)[σ]=if(e[σ];e1[σ];e2[σ]), the analogue of (141.6).

exercise 141.8.

Naturality of at at σ:ΓΔ requires, for eTmAB(Δ), (et)[σ]=e[σ]t. By the application clause the left side is e[σ]t[σ], so the requirement is t[σ]=t, which is lemma 141.2(3) because t is closed. The one property used is FV(t)=; for an open t the family is not natural in general, because t[σ] can differ from t.

exercise 141.10.

Choose xx and let Δ2:=(x:A,x:A). By proposition 141.62 with Γ=A, y(Δ2)y(A)×TmA, and by proposition 141.60, y(A)TmA; composing the natural isomorphisms componentwise gives TmA×TmAy(Δ2), the component at Γ sending (e,e) to the substitution (e,e). Then corollary 141.53 with r=Δ2, K=TmB gives Nat(TmA×TmA,TmB)TmB(Δ2), the terms x:A,x:Ab:B. The transformation of b has components (e,e)TmB((e,e))(b)=b[e/x,e/x], and the term of a transformation α is αΔ2(x,x). For A=AB, application (e1,e2)e1e2 corresponds to appΔ2(x,x)=xx, and indeed (xx)[e1/x,e2/x]=e1e2.

exercise 141.11.

Regard P as a category by example 141.15. A presheaf K assigns a set K(a) to each a and a function K(ab):K(b)K(a) to each ab, with K(aa)=idK(a) and K(ac)=K(ab)K(bc) for abc. The representable y(r) has y(r)(a)=homP(a,r), a one-element set when ar and empty otherwise: the down-set of r. A natural transformation ϕ:y(r)K is a family of elements ϕaK(a) for ar (the value of ϕa at the unique arrow), natural when K(ab)(ϕb)=ϕa for all abr: a compatible family over the down-set. Corollary 141.53 says such a family is determined by ϕrK(r) through ϕa=K(ar)(ϕr), and every element of K(r) arises. In chapter 49, the values at a context restrict along every extension, and the uniform action demanded there is exactly compatibility of the family; the lemma identifies a single value at Γ with its whole compatible family of restrictions.

exercise 141.9.

If aa and bb then ab implies aabb, and symmetrically, so [a][b] does not depend on the representatives. It is reflexive and transitive because is, and antisymmetric: [a][b] and [b][a] give ab and ba, so ab and [a]=[b]. The quotient map q(a):=[a] is monotone, hence a functor (example 141.33); it is faithful because hom-sets have at most one element, full because [a][b] means ab by definition, and essentially surjective because every class is q(a) for any of its members. By theorem 141.46 it is an equivalence. If is antisymmetric then every class is a singleton, q is a bijection on objects, and the map sending [a] to its member is an inverse functor, monotone because [a][b] means ab; so q is an isomorphism of categories. Conversely an isomorphism of categories is injective on objects, so ab implies [a]=[b] implies a=b: antisymmetry. For the generality order, σ1σ2 means σ1σ2 and σ2σ1, that is, every instance of each is an instance of the other: the two schemes have the same monotype instances, as α.αα, β.ββ, and αβ.αα do.

exercise 141.12.

τσ=((yv)[σ])=((λw:2.uw)(utt)):ΓΘ. The range of τσ has free variable u, which is the bound name of e:=λu:2.z; so the abstraction clause renames it: (λu:2.z)[τσ]=λu:2.(λw:2.uw)(utt). Separately, e[τ]=λu:2.yv with no renaming, since u is not free in yv; then applying σ, whose range again has u free, renames the binder and gives λu:2.(λw:2.uw)(utt). The two results are identical, confirming lemma 141.5. A bound name changed at exactly the steps where a substitution whose range contains u passed under the binder u: once in the composite action and once in the second of the two separate actions. Without the change, the free u of Γ would have been captured and the result would have been closed.

exercise 141.13.

For R:AB and S:BC, (z,x)(SR)def. (x,z)SRdef. y.(x,y)R(y,z)Sdef. y.(z,y)S(y,x)Rdef. (z,x)RS, and (idA)={(x,x)}=idA. Define F:RelRelop as the identity on objects and F(R):=R, an arrow BA of Rel, hence an arrow AB of Relop. Functoriality: F(SR)=RS, and in Relop the composite F(S)opF(R) is F(R)F(S)=RS by definition 141.25; identities are preserved by the second equation. Since (R)=R, F is its own inverse, so it is an isomorphism of categories.

exercise 141.15.

Define Θ(g):=homC(g,) for g:sr, with components homC(r,a)homC(s,a), hhg; this is natural by associativity, as in the proof of theorem 141.52. Define the inverse Ξ(ϕ):=ϕr(idr)homC(s,r) for natural ϕ:homC(r,)homC(s,). Then Ξ(Θ(g))=idrg=g. For the other composite, let ϕ be natural, a an object, h:ra; naturality of ϕ at h, evaluated at idr, gives ϕa(hidr)=hϕr(idr), i.e. ϕa(h)=hΞ(ϕ)=Θ(Ξ(ϕ))a(h). So Θ and Ξ are mutually inverse. The assignment rhomC(r,), ghomC(g,) is a functor Cop[C,Set]: an arrow rs of Cop is g:sr, and homC(gg,)=homC(g,)homC(g,) componentwise, hhgg, which is the composite in the order required by Cop. The bijection just proved says this functor is injective and surjective on each hom-set, that is, fully faithful.

exercise 141.16.

Let α:FG, β:GH, γ:HJ. Associativity asserts (γβ)α=γ(βα) as natural transformations FJ; two natural transformations are equal when all their components are, and at a the two sides are (γaβa)αa and γa(βaαa), equal by associativity in D. The unit laws idGα=α=αidF reduce at a to idG(a)αa=αa=αaidF(a), the unit laws of D. That the composites are natural was shown in section 141.7, so the laws are equations between arrows of [C,D].

exercise 141.17.

w is a substitution because Γ,x:Axi:Ai by Var. Its action on a Γ-term e is e[x1/x1,,xn/xn]=e by lemma 141.2(2), the same term regarded in the larger context; so the action is injective.

Epic. Let v,v:ΓΘ with vw=vw. Componentwise, v(zk)[w]=v(zk)[w], and by the remark just made this is v(zk)=αv(zk); so v=v.

Not monic. Let Λ:=Γ,x:A,x:A and u:=(x1,,xn,x), u:=(x1,,xn,x), both substitutions ΛΓ,x:A. Then wu=(x1,,xn)=wu, since w has no component for x, but uu.

Not an isomorphism. An isomorphism f with inverse g is monic: fu=fu gives u=gfu=gfu=u. Since w is not monic, it is not an isomorphism.

The epimorphism argument used only the injectivity of the action: if e[w]=e[w] then e=e. The global-element argument of proposition 141.29 separated two arrows into A by evaluating them at elements 1A. In Ctx take A=P atomic: the source Γ,x:P of w has no global elements, because a global element would include a closed term of type P, and by theorem 2.43 and lemma 2.59 a closed normal term has a non-atomic type or a free variable. So the test “wρ=wρ implies ρ=ρ” at t= holds vacuously while w is not monic; cancellation in Ctx must be tested against arbitrary contexts, as the definition requires.

exercise 141.14.

An arrow (a,b)(a,b) of P×Q is a pair of an arrow aa and an arrow bb, which exists exactly when both relations hold and is then unique; so P×Q has at most one arrow between any two objects and is the preorder described, by example 141.15. On a preorder, homP(a,b) is a one-element set when ab and empty otherwise, and homP(f,g) for f:aa, g:bb is the unique function between the corresponding sets, which exists because ab implies aabb. Functoriality is automatic. For a functor K:Pop×PSet with empty or one-element values, define the canonical functor K^ by K^(a,b)=1 when K(a,b) is inhabited and K^(a,b)= otherwise. The function on objects (a,b)[K(a,b)] is monotone into {01}: a function K(a,b)K(a,b) can exist only when K(a,b)= or K(a,b). Conversely a monotone truth-value map defines such a canonical functor, with every arrow action the unique function between the corresponding empty or singleton sets. The unique bijection K(a,b)K^(a,b) at each object is natural, since every square is between sets with at most one element. Thus K and K^ are naturally isomorphic; they need not be literally equal when K uses noncanonical singleton sets. Under this correspondence the hom bifunctor is naturally isomorphic to the functor classified by the map sending (a,b) to 1 iff ab: it is monotone because (a,b)(a,b) in Pop×P means aa and bb, and then ab implies ab.

exercise 141.18.

homC(1,) sends f:ab to the function ufu on global elements. It is faithful exactly when ff implies that these functions differ, that is, that some u has fufu: this is the definition of having enough points. Set has enough points because ff means f(x)f(x) for some x, and then fxfx. In Ctx, let P be atomic. The substitutions (tt),(ff):P2 are distinct. A global element of P is a closed term of type P, and there is none: such a term would reduce, by theorem 2.43 and subject reduction (corollary 2.44), to a closed normal term of type P, which by lemma 2.59 is an introduction form, whose type is never atomic, or variable-headed, which needs a free variable. So the two substitutions agree on every environment vacuously, and Ctx does not have enough points.

exercise 141.19.

Let η:IdGF, ε:FGId, η:IdGF, ε:FGId be the given natural isomorphisms. Define θd:=G(εd)ηG(d):G(d)G(F(G(d)))G(d). Each component is an isomorphism: ηG(d) is one, and G(εd) is one with inverse G(εd1), by (141.4). Naturality at g:dd: θdG(g)=G(εd)ηG(d)G(g)=nat. ηG(εd)G(F(G(g)))ηG(d)=functorG(εdF(G(g)))ηG(d)=nat. εG(gεd)ηG(d)=G(g)θd. So θ is a natural isomorphism GG by proposition 141.43.

exercise 141.20.

Let (r,u) and (r,u) be two representations, so both are terminal objects of K by proposition 141.65. By lemma 141.27 they are isomorphic in K by a unique isomorphism f:(r,u)(r,u) with inverse f. The arrows of K are arrows of C composed as in C, so f:rr and f:rr satisfy ff=idr and ff=idr in C, because the projection πK is the identity on arrows and composition in K is that of C. Hence rr, which is the uniqueness stated in corollary 141.59; moreover f satisfies K(f)(u)=u, so it carries one universal element to the other.

exercise 141.21.

An object of Env is a pair (Γ,ρ) of a context and an environment ρ:Γ for it. An arrow (Γ,ρ)(Δ,ρ) is a substitution σ:ΓΔ with Env(σ)(ρ)=σρ=ρ: a substitution that carries the first environment to the second. The object (,()), the empty context with the empty environment, is initial: an arrow (,())(Γ,ρ) is a substitution σ:Γ with σ()=ρ, and σ()=σ since () is id, so σ=ρ is the unique such arrow. This is the dual of the terminal object (A,x) of TmA: the covariant functor Env=homCtx(,) is represented by , and its category of elements has an initial object, the universal element ().

exercise 141.22.

Suppose ϕ:y(Δ)K is a natural isomorphism. By proposition 141.43 its component at is a bijection homCtx(,Δ)K()={0,1}, so homCtx(,Δ) has exactly two elements. These elements are lists of closed terms (aj:Bj)j.

If Δ=, the only list is the empty one: one element. Otherwise, if some declared type Bj has no closed term, the hom-set is empty. This happens for an atomic type P: a closed term of type P would, by strong normalization (theorem 2.43) and subject reduction (corollary 2.44), reduce to a closed normal term n of type P, and by lemma 2.59 n is either an introduction form, whose type is never atomic, or is variable-headed, which requires a free variable; neither has type P in the empty context, the argument of corollary 2.44. If every Bj has a closed term tj, then the hom-set is infinite: the terms t1, (λy:B1.y)t1, (λy:B1.y)((λy:B1.y)t1),  are closed, of type B1 by Lam and App, and pairwise distinct as syntax trees, hence as α-classes, since their sizes differ; each gives a different list. In every case the count is not two, so no representation exists. Note that TmA counts terms up to α-equivalence only; the argument would change for terms up to βη-equality.

Search the book

Type to search the local edition.