Three facts have been proved separately in this book, each about a different kind of composition. Type substitutions compose in diagrammatic order and id is a two-sided unit for that composition (definition 3.5). Simultaneous term substitutions act on terms, and extending a substitution by one more variable is the same as acting twice (equation 2.1). Context extensions Δ ⊵Γ compose, and a semantic value at Γ must act uniformly at every extension (chapter 49). Each proof is a short induction, and each is repeated whenever a new calculus arrives. The repetition is not harmless: comparing a syntax with its environments, or a calculus with a model, requires saying that two such composition structures agree, and that statement cannot be made until both structures are instances of one definition. The object that removes the repetition is a set of arrows with a typed composition satisfying three equations.
Substitutions compose
Fix the simply typed calculus of chapter 2: types 𝐴,𝐵 ::=𝑃 ∣𝟐 ∣𝐴 →𝐵; terms built from variables, abstraction, application, the constants 𝗍𝗍,𝖿𝖿, and the conditional 𝗂𝖿(𝑒;𝑒1;𝑒2), typed by the rules Var, Lam, App, and the Boolean rules; and simultaneous capture-avoiding substitution 𝑒[𝜎] from definition 2.41. A context Γ =𝑥1 :𝐴1,…,𝑥𝑛 :𝐴𝑛 declares distinct variables. As in convention 2.3, a term is an 𝛼-equivalence class, so equality of terms is equality up to renaming of bound variables; the symbol =𝛼 marks the places where a calculation is performed on representatives.
Let Γ 𝖼𝗍𝗑 and Δ =𝑦1 :𝐵1,…,𝑦𝑚 :𝐵𝑚. A substitution 𝜎 :Γ ⟶Δ is a list (𝑏1,…,𝑏𝑚) of terms with Γ⊢𝑏𝑗:𝐵𝑗(1≤𝑗≤𝑚). Its action on a term Δ ⊢𝑒 :𝐴 is the simultaneous substitution 𝑒[𝜎]:=𝑒[𝑏1/𝑦1,…,𝑏𝑚/𝑦𝑚]. We write 𝜎(𝑦𝑗) for 𝑏𝑗.
Referenced from 8 locations
A substitution Γ ⟶Δ provides a Γ-term for each variable of Δ, so its action sends Δ-terms to Γ-terms: the arrow and the action point in opposite directions. Chapter 26 wrote 𝑓 :Γ ⇒Δ for the dependent form of the same list (definition 26.45); here it is written with the arrow ⟶.
Three facts about substitution are used repeatedly and are stated once.
Let 𝜃 be a simultaneous substitution and 𝑒 a term.
If 𝑦 is not in the domain of 𝜃, then 𝑒[𝜃,𝑦 ↦𝑦] =𝛼𝑒[𝜃].
𝑒[𝑥1/𝑥1,…,𝑥𝑛/𝑥𝑛] =𝛼𝑒.
If no free variable of 𝑒 is in the domain of 𝜃, then 𝑒[𝜃] =𝛼𝑒; in particular a closed term is fixed by every substitution.
Referenced from 8 locations
Proof of Lemma 141.2 — Trivial substitutions
Proof. All three are proved by induction on 𝑒, choosing each bound name fresh for 𝑦, for the 𝑥𝑖, and for the range of 𝜃. At a variable, both sides of (1) are 𝑦 if the variable is 𝑦 and the value of 𝜃 otherwise; both sides of (2) are the variable itself; and in (3) the variable is free in 𝑒, hence outside the domain, and is unchanged. Application, the constants, and the conditional recurse in their immediate subterms, the hypothesis of (3) passing to each subterm because its free variables are among those of 𝑒. At an abstraction 𝜆𝑧 :𝐵. 𝑏 with 𝑧 fresh, the abstraction clause of definition 2.41 removes 𝑧 from the domain on both sides; for (3) the free variables of 𝑏 are those of 𝑒 together with 𝑧, which is not in the domain of 𝜃 ∖𝑧, so the induction hypothesis applies to 𝑏, and 𝜆𝑧 is reattached. ◻
If 𝜎 :Γ ⟶Δ and Δ ⊢𝑒 :𝐴, then Γ ⊢𝑒[𝜎] :𝐴.
Referenced from 4 locations
Proof of Lemma 141.3 — Action preserves typing
Proof. Induct on the derivation of Δ ⊢𝑒 :𝐴, proving the statement for every Γ and every 𝜎 :Γ ⟶Δ at once.
Variable case. The term is 𝑦𝑗 with 𝐴 =𝐵𝑗, and 𝑦𝑗[𝜎] =𝑏𝑗, which has type 𝐵𝑗 in Γ by the definition of a substitution.
Application case. From Δ ⊢𝑒1 :𝐵 →𝐴 and Δ ⊢𝑒2 :𝐵 the induction hypothesis gives Γ ⊢𝑒1[𝜎] :𝐵 →𝐴 and Γ ⊢𝑒2[𝜎] :𝐵, and App derives the type of 𝑒1[𝜎] 𝑒2[𝜎] =(𝑒1𝑒2)[𝜎]. The constants are unchanged by substitution and keep their type; the conditional recurses in its three subterms exactly as application does.
Binder case. The term is 𝜆𝑦 :𝐵. 𝑏 with Δ,𝑦 :𝐵 ⊢𝑏 :𝐶 and 𝐴 =𝐵 →𝐶. Choose the bound name 𝑦 fresh for Γ, for Δ, and for every 𝑏𝑗; convention 2.3 permits this. The list 𝜎+:=(𝑏1,…,𝑏𝑚,𝑦) is then a substitution Γ,𝑦 :𝐵 ⟶Δ,𝑦 :𝐵: each 𝑏𝑗 keeps its type by lemma 2.14, and 𝑦 has type 𝐵 by Var. The induction hypothesis for 𝑏 at 𝜎+ gives Γ,𝑦 :𝐵 ⊢𝑏[𝜎+] :𝐶, and 𝑏[𝜎+] =𝑏[𝜎] by lemma 141.2(1). Then Lam derives Γ ⊢𝜆𝑦 :𝐵. 𝑏[𝜎] :𝐵 →𝐶, whose subject is (𝜆𝑦 :𝐵. 𝑏)[𝜎] by the abstraction clause of definition 2.41. ◻
Let 𝜎 :Γ ⟶Δ and 𝜏 :Δ ⟶Θ with Θ =𝑧1 :𝐶1,…,𝑧𝑛 :𝐶𝑛 and 𝜏 =(𝑐1,…,𝑐𝑛). Define 𝜏∘𝜎:=(𝑐1[𝜎],…,𝑐𝑛[𝜎]):Γ⟶Θ,idΓ:=(𝑥1,…,𝑥𝑛):Γ⟶Γ.
Referenced from 6 locations
Both lists are substitutions: Γ ⊢𝑐𝑘[𝜎] :𝐶𝑘 by lemma 141.3, and Γ ⊢𝑥𝑖 :𝐴𝑖 by Var. Compute one composite before proving anything about it. Let Γ=𝑓:𝟐→𝟐, 𝑥:𝟐,Δ=𝑦:𝟐,Θ=𝑧:𝟐→𝟐, and take 𝜎 =(𝑓 𝑥) :Γ ⟶Δ and 𝜏 =(𝜆𝑤 :𝟐. 𝑦) :Δ ⟶Θ. Then 𝜏∘𝜎=((𝜆𝑤:𝟐.𝑦)[(𝑓𝑥)/𝑦])=(𝜆𝑤:𝟐.𝑓𝑥):Γ⟶Θ. Now let Θ ⊢𝑒 :𝟐 be 𝑒:=𝑧 𝗍𝗍 and compare the two ways of reaching a Γ-term: 𝑒[𝜏∘𝜎]=(𝜆𝑤:𝟐.𝑓𝑥)𝗍𝗍,𝑒[𝜏][𝜎]=((𝜆𝑤:𝟐.𝑦)𝗍𝗍)[(𝑓𝑥)/𝑦]=(𝜆𝑤:𝟐.𝑓𝑥)𝗍𝗍. They agree. The composite 𝜏 ∘𝜎 is “first 𝜎, then 𝜏” as arrows, and its action on terms is “first 𝜏, then 𝜎”. That the two calculations always agree is the following lemma.
For 𝜎 :Γ ⟶Δ, 𝜏 :Δ ⟶Θ, and Θ ⊢𝑒 :𝐴, 𝑒[𝜏∘𝜎]=𝛼𝑒[𝜏][𝜎].
Referenced from 10 locations
Proof of Lemma 141.5 — Action law
Proof. Induct on 𝑒, proving the equation for all Γ,Δ,Θ and all 𝜎,𝜏 at once, and choosing every bound name fresh for Γ, Δ, Θ, and the ranges of 𝜎, 𝜏, and 𝜏 ∘𝜎 (convention 2.3).
Variable case. For 𝑒 =𝑧𝑘, 𝑧𝑘[𝜏∘𝜎]𝑑𝑒𝑓. ∘=𝑐𝑘[𝜎]𝑑𝑒𝑓. 𝑎𝑐𝑡𝑖𝑜𝑛=𝑧𝑘[𝜏][𝜎].
Application case. For 𝑒 =𝑒1𝑒2 and any substitution 𝜃, (𝑒1𝑒2)[𝜃] =𝑒1[𝜃] 𝑒2[𝜃] by the application clause, so both sides are applications whose two components are equal by the induction hypotheses for 𝑒1 and 𝑒2. The constants are fixed by every substitution, and the conditional recurses in its three subterms as application does.
Binder case. For 𝑒 =𝜆𝑦 :𝐵. 𝑏 with 𝑦 fresh as above, 𝑦 lies in the domain of neither substitution, so the abstraction clause of definition 2.41 reads (𝜆𝑦 :𝐵. 𝑏)[𝜃] =𝜆𝑦 :𝐵. 𝑏[𝜃] for 𝜃 ∈{𝜏 ∘𝜎, 𝜏, 𝜎}. Write 𝜎+:=(𝜎,𝑦 ↦𝑦) and 𝜏+:=(𝜏,𝑦 ↦𝑦), substitutions Γ,𝑦 :𝐵 ⟶Δ,𝑦 :𝐵 and Δ,𝑦 :𝐵 ⟶Θ,𝑦 :𝐵. Two facts are used:
𝑡[𝜃] =𝑡[𝜃+] for every term 𝑡 and each 𝜃, by lemma 141.2(1), since 𝑦 is in no domain;
(𝜏 ∘𝜎)+ =𝜏+ ∘𝜎+ componentwise: at 𝑧𝑘 the left side is 𝑐𝑘[𝜎] and the right side is 𝑐𝑘[𝜎+], equal by (1); at 𝑦 both sides are 𝑦.
Then (𝜆𝑦:𝐵.𝑏)[𝜏∘𝜎](1)=𝜆𝑦:𝐵.𝑏[(𝜏∘𝜎)+](2)=𝜆𝑦:𝐵.𝑏[𝜏+∘𝜎+]𝐼𝐻=𝜆𝑦:𝐵.𝑏[𝜏+][𝜎+](1)=(𝜆𝑦:𝐵.𝑏)[𝜏][𝜎], the induction hypothesis being applied to 𝑏 with the substitutions 𝜎+ and 𝜏+. ◻
The binder case is where a careless definition fails. Take Θ =𝑧 :𝟐, 𝑒:=𝜆𝑥 :𝟐. 𝑧, 𝜏 =(𝑦) :Δ ⟶Θ with Δ =𝑦 :𝟐, and 𝜎 =(𝑥) :Γ ⟶Δ with Γ =𝑥 :𝟐. Then 𝑒[𝜏] =𝜆𝑥 :𝟐. 𝑦, and applying 𝜎 without renaming would produce 𝜆𝑥 :𝟐. 𝑥, a closed term, in which the free 𝑥 of Γ has been captured. The fresh choice of the bound name gives 𝜆𝑥′ :𝟐. 𝑥 instead, and this is also 𝑒[𝜏 ∘𝜎] with 𝜏 ∘𝜎 =(𝑥).
Referenced from 6 locations
For 𝜎 :Γ ⟶Δ, 𝜏 :Δ ⟶Θ, and 𝜌 :Θ ⟶Λ:
(𝜌 ∘𝜏) ∘𝜎 =𝜌 ∘(𝜏 ∘𝜎);
idΔ ∘𝜎 =𝜎 and 𝜎 ∘idΓ =𝜎.
Referenced from 11 locations
Proof of Proposition 141.7 — The substitution algebra
Proof. Let Λ =𝑤1 :𝐷1,…,𝑤𝑝 :𝐷𝑝 and 𝜌 =(𝑑1,…,𝑑𝑝). Compare the 𝑘-th components: ((𝜌∘𝜏)∘𝜎)(𝑤𝑘)𝑑𝑒𝑓.=𝑑𝑘[𝜏][𝜎]𝑎𝑐𝑡𝑖𝑜𝑛𝑙𝑎𝑤=𝑑𝑘[𝜏∘𝜎]𝑑𝑒𝑓.=(𝜌∘(𝜏∘𝜎))(𝑤𝑘). For the identities, (idΔ ∘𝜎)(𝑦𝑗) =𝑦𝑗[𝜎] =𝑏𝑗 by the variable clause, and (𝜎 ∘idΓ)(𝑦𝑗) =𝑏𝑗[𝑥1/𝑥1,…,𝑥𝑛/𝑥𝑛] =𝑏𝑗 by lemma 141.2(2). ◻
★☆☆ With Γ =𝑓 :𝟐 →𝟐, 𝑥 :𝟐, Δ =𝑦 :𝟐, Θ =𝑧 :𝟐 →𝟐, 𝜎 =(𝑓 𝑥), and 𝜏 =(𝜆𝑤 :𝟐. 𝑦) as in (141.1), let Λ =𝑢 :𝟐 and 𝜌 =(𝑧 𝖿𝖿) :Θ ⟶Λ. Compute (𝜌 ∘𝜏) ∘𝜎 and 𝜌 ∘(𝜏 ∘𝜎) as lists of terms and confirm that they coincide.
Referenced from 6 locations
Proposition 141.7 mentions neither terms nor the action: it is three equations between composites of arrows. The definition that follows records what the proposition uses: objects, typed arrows, composition, identities, and the three equations; nothing else. The action 𝑒[𝜎] is not part of it; it returns in section 141.6 as additional structure over a category.
The definition
A category C consists of
a collection of objects;
for each pair of objects 𝑎,𝑏 a set homC(𝑎,𝑏), the hom-set, of arrows from 𝑎 to 𝑏; we write 𝑓 :𝑎 ⟶𝑏 for 𝑓 ∈homC(𝑎,𝑏);
for each triple 𝑎,𝑏,𝑐 a composition function ∘ :homC(𝑏,𝑐) ×homC(𝑎,𝑏) →homC(𝑎,𝑐), written 𝑔 ∘𝑓 for 𝑓 :𝑎 ⟶𝑏 and 𝑔 :𝑏 ⟶𝑐;
for each object 𝑎 an identity arrow id𝑎 :𝑎 ⟶𝑎;
such that, for all objects 𝑎,𝑏,𝑐,𝑑 and all 𝑓 :𝑎 ⟶𝑏, 𝑔 :𝑏 ⟶𝑐, ℎ :𝑐 ⟶𝑑, (ℎ∘𝑔)∘𝑓=ℎ∘(𝑔∘𝑓),id𝑏∘𝑓=𝑓,𝑓∘id𝑎=𝑓.
Referenced from 4 locations
Composition is written in the order of functions, 𝑔 ∘𝑓 meaning “first 𝑓, then 𝑔”; chapter 3 wrote the composition of type substitutions in the opposite, diagrammatic order 𝑆;𝑇. Each hom-set is a set; the objects need not form a set, and a category whose objects do form a set is called small. Size is noted at the places where it matters.
𝐒𝐞𝐭 has sets as objects, functions as arrows, composition (𝑔 ∘𝑓)(𝑥) =𝑔(𝑓(𝑥)), and identities id𝐴(𝑥) =𝑥. The three laws hold pointwise: each side of each equation is a function, and evaluating both sides at an arbitrary 𝑥 gives the same element.
Referenced from 2 locations
A category is a monoid whose multiplication is typed. In 𝐂𝐭𝐱 the product 𝜏 ∘𝜎 exists only when the target of 𝜎 is the source of 𝜏: in (141.1) the middle context Δ is what makes the two lists fit, and (𝑓 𝑥) :Γ ⟶Δ has no composite with an arrow out of any other context. The objects are the types of this partial multiplication. With one object the typing is vacuous.
Let C have exactly one object ∗. Then 𝑀:=homC( ∗, ∗) with multiplication ∘ and unit id∗ is a monoid. Conversely every monoid (𝑀, ⋅,𝑒) is the hom-set of a one-object category with 𝑔 ∘𝑓:=𝑔 ⋅𝑓 and id∗:=𝑒.
Referenced from 5 locations
Proof of Proposition 141.11 — One-object categories
Proof. With one object, every pair of arrows is composable, so ∘ is a total binary operation on 𝑀, and (141.2) says precisely that it is associative with two-sided unit id∗. Conversely, the monoid axioms for (𝑀, ⋅,𝑒) are (141.2) with 𝑎 =𝑏 =𝑐 =𝑑 = ∗. ◻
Besides the three equations, the definition asks for two things: an identity arrow at every object, and a composite for every two arrows whose types match. For a subcollection of the arrows of 𝐂𝐭𝐱 these are closure conditions. The following three examples keep the objects of 𝐂𝐭𝐱 and restrict the arrows: the first restriction is a category, the second has no identities, and the third is not closed under composition.
Keep the objects of 𝐂𝐭𝐱 and keep only the substitutions whose components are variables, 𝜎 =(𝑥𝑖1,…,𝑥𝑖𝑚) with 𝐴𝑖𝑗 =𝐵𝑗. Every identity is such a list, and the composite of two such lists is again one, because 𝑥𝑖[𝜎] is a component of 𝜎. So the restriction is a category, the category of renamings; in general a subcategory of C is a category with some of the objects and some of the arrows of C, composed as in C. The extensions Δ ⊵Γ of chapter 49 are the renamings Δ ⟶Γ whose components are the variables of Γ in order, the weakenings.
Referenced from 4 locations
Keep the objects of 𝐂𝐭𝐱 and keep only the substitutions all of whose components are closed terms. The collection is closed under composition: if 𝜏 has closed components 𝑐𝑘, then 𝑐𝑘[𝜎] =𝑐𝑘 by lemma 141.2(3), so 𝜏 ∘𝜎 has the same closed components. But idΓ has the variables of Γ as components, which are not closed unless Γ is empty. The collection is closed under composition but has no identity at any nonempty context, so it is not a category.
Referenced from 2 locations
Keep the objects of 𝐂𝐭𝐱 and keep only the substitutions whose components are normal forms, terms with no ⟶𝗉 reduct. Every identity qualifies. Take Δ =𝑦 :𝟐 →𝟐, Θ =𝑧 :𝟐, 𝜏 =(𝑦 𝗍𝗍) :Δ ⟶Θ, whose component is normal, and 𝜎 =(𝜆𝑤 :𝟐. 𝑤) :Γ ⟶Δ for any Γ. Then 𝜏∘𝜎=((𝑦𝗍𝗍)[𝜎])=((𝜆𝑤:𝟐.𝑤)𝗍𝗍), a redex. The collection contains every identity but is not closed under composition, so it is not a category. The restriction is a natural one to try, because normal forms are the terms one computes with; but substituting a normal form into a normal form creates the redexes that normalization then removes.
Referenced from 2 locations
Three further examples change what an arrow carries rather than which arrows there are.
A preorder is a set 𝑃 with a reflexive and transitive relation ≤. Take the elements of 𝑃 as objects and let hom𝑃(𝑎,𝑏) have exactly one element when 𝑎 ≤𝑏 and be empty otherwise. Composition of 𝑎 ≤𝑏 and 𝑏 ≤𝑐 is the unique arrow 𝑎 ≤𝑐, which exists by transitivity; id𝑎 is 𝑎 ≤𝑎, which exists by reflexivity. The three laws hold because each side is an element of a set with at most one element. Conversely, a category with at most one arrow between any two objects is a preorder on its objects. The generality order 𝜎1 ⊒𝜎2 on type schemes (chapter 3) is a preorder, and so is extension of contexts, read with an arrow Δ ⟶Γ exactly when Δ ⊵Γ: this preorder is the subcategory of weakenings in example 141.12, which has at most one arrow between any two contexts. When arrows carry no data, the laws are automatic and the whole content is which hom-sets are inhabited.
Referenced from 8 locations
Take the terms of chapter 2 as objects and, as arrows 𝑒 ⟶𝑒′, the finite reduction sequences 𝑒 =𝑒0 ⟶𝗉𝑒1 ⟶𝗉⋯ ⟶𝗉𝑒𝑛 =𝑒′, with 𝑛 ≥0. Composition is concatenation of sequences and id𝑒 is the empty sequence at 𝑒; concatenation is associative and the empty sequence is neutral, so this is a category, written 𝐏𝐚𝐭𝐡𝐬. It is not a preorder: in the context 𝑧 :𝟐, the term (𝜆𝑥 :𝟐. 𝑥) ((𝜆𝑦 :𝟐. 𝗍𝗍) 𝑧) reduces to 𝗍𝗍 by contracting the outer redex first, through (𝜆𝑦 :𝟐. 𝗍𝗍) 𝑧, and by contracting the inner redex first, through (𝜆𝑥 :𝟐. 𝑥) 𝗍𝗍; the two intermediate terms differ, so these are two different sequences of length two, hence two arrows with the same source and target. Forgetting the sequence and keeping only its existence gives the preorder ⟶∗𝗉 of chapter 2: the same objects, each hom-set collapsed as in example 141.15.
Referenced from 2 locations
The construction of 𝐏𝐚𝐭𝐡𝐬 used nothing about reduction except that it is a relation on terms: a set of vertices and a set of edges.
A graph 𝐺, in the sense of vertices and edges rather than the graph of a function, consists of a set of vertices, a set of edges, and two functions assigning to each edge a source and a target vertex. The free category 𝐅𝐫𝐞𝐞(𝐺) has the vertices as objects and, as arrows 𝑣 ⟶𝑣′, the finite paths 𝑣 =𝑣0 →𝑣1 →⋯ →𝑣𝑛 =𝑣′ of edges, with concatenation as composition and the empty path at 𝑣 as id𝑣. Concatenation of paths is associative and the empty path is neutral on either side, so (141.2) hold.
Referenced from 3 locations
𝐏𝐚𝐭𝐡𝐬 is the free category on the graph whose vertices are terms and whose edges are the one-step reductions.
Let 𝐺 have two vertices 𝑎,𝑏, two edges 𝜖1,𝜖2 :𝑎 →𝑏, and one edge ℓ :𝑎 →𝑎. In 𝐅𝐫𝐞𝐞(𝐺), hom𝐅𝐫𝐞𝐞(𝐺)(𝑎,𝑎)={ℓ𝑛∣𝑛≥0},hom𝐅𝐫𝐞𝐞(𝐺)(𝑎,𝑏)={𝜖𝑖∘ℓ𝑛∣𝑖=1,2, 𝑛≥0},hom𝐅𝐫𝐞𝐞(𝐺)(𝑏,𝑎)=∅,hom𝐅𝐫𝐞𝐞(𝐺)(𝑏,𝑏)={id𝑏}, where ℓ𝑛 is the path that traverses ℓ 𝑛 times and ℓ0 =id𝑎. Three edges generate infinitely many arrows, and 𝜖1 and 𝜖2 are different arrows with the same source and target: an arrow records the path taken, not only that the target is reachable. Collapsing each hom-set to at most one arrow, as in example 141.15, leaves the reachability preorder 𝑎 ≤𝑎, 𝑎 ≤𝑏, 𝑏 ≤𝑏.
Referenced from 2 locations
𝐑𝐞𝐥 has sets as objects and relations 𝑅 ⊆𝐴 ×𝐵 as arrows 𝐴 ⟶𝐵, composed by 𝑆∘𝑅:={(𝑥,𝑧)∣∃𝑦. (𝑥,𝑦)∈𝑅∧(𝑦,𝑧)∈𝑆}for 𝑅:𝐴⟶𝐵, 𝑆:𝐵⟶𝐶, with id𝐴 ={(𝑥,𝑥) ∣𝑥 ∈𝐴}. Associativity is the commutation of two existential quantifiers: for 𝑇 :𝐶 ⟶𝐷, (𝑥,𝑤)∈(𝑇∘𝑆)∘𝑅⟺∃𝑦.(𝑥,𝑦)∈𝑅∧(∃𝑧.(𝑦,𝑧)∈𝑆∧(𝑧,𝑤)∈𝑇)⟺∃𝑦∃𝑧.(𝑥,𝑦)∈𝑅∧(𝑦,𝑧)∈𝑆∧(𝑧,𝑤)∈𝑇⟺∃𝑧.(∃𝑦.(𝑥,𝑦)∈𝑅∧(𝑦,𝑧)∈𝑆)∧(𝑧,𝑤)∈𝑇⟺(𝑥,𝑤)∈𝑇∘(𝑆∘𝑅). For the identities, (𝑥,𝑦) ∈id𝐵 ∘𝑅 iff ∃𝑦′. (𝑥,𝑦′) ∈𝑅 ∧𝑦′ =𝑦 iff (𝑥,𝑦) ∈𝑅, and (𝑥,𝑦) ∈𝑅 ∘id𝐴 iff ∃𝑥′. 𝑥 =𝑥′ ∧(𝑥′,𝑦) ∈𝑅 iff (𝑥,𝑦) ∈𝑅. A function 𝑓 :𝐴 →𝐵 is the relation {(𝑥,𝑓(𝑥)) ∣𝑥 ∈𝐴}, and composing two such relations gives the graph of the composite function, so 𝐒𝐞𝐭 sits inside 𝐑𝐞𝐥 with the same objects. 𝐒𝐞𝐭 and 𝐑𝐞𝐥 have the same objects and are different categories: the arrows, not the objects, carry the structure.
Referenced from 4 locations
★☆☆ Show that a relation 𝑅 ⊆𝐴 ×𝐵 is the graph of a function 𝐴 →𝐵 if and only if id𝐴 ⊆𝑅⌣ ∘𝑅 and 𝑅 ∘𝑅⌣ ⊆id𝐵, where 𝑅⌣:={(𝑦,𝑥) ∣(𝑥,𝑦) ∈𝑅}. Express each inclusion as a quantified statement first, then identify it with totality or with single-valuedness.
Referenced from 3 locations
A monoid is a one-object category by proposition 141.11; monoids also form a category. 𝐌𝐨𝐧 has monoids (𝑀, ⋅,𝑒) as objects and monoid homomorphisms as arrows: functions ℎ :𝑀 →𝑁 with ℎ(𝑥 ⋅𝑦) =ℎ(𝑥) ⋅ℎ(𝑦) and ℎ(𝑒) =𝑒. Composition and identities are those of 𝐒𝐞𝐭, and the laws hold because they hold in 𝐒𝐞𝐭; what has to be checked is closure, namely that 𝑔 ∘ℎ is again a homomorphism: 𝑔(ℎ(𝑥 ⋅𝑦)) =𝑔(ℎ(𝑥) ⋅ℎ(𝑦)) =𝑔(ℎ(𝑥)) ⋅𝑔(ℎ(𝑦)) and 𝑔(ℎ(𝑒)) =𝑔(𝑒) =𝑒.
Referenced from 2 locations
Isomorphisms, duality, and terminal objects
An arrow 𝑓 :𝑎 ⟶𝑏 is an isomorphism if there is 𝑔 :𝑏 ⟶𝑎 with 𝑔 ∘𝑓 =id𝑎 and 𝑓 ∘𝑔 =id𝑏. Objects 𝑎,𝑏 are isomorphic, 𝑎 ≅𝑏, when such an 𝑓 exists.
Referenced from 3 locations
If 𝑔 ∘𝑓 =id𝑎 and 𝑓 ∘𝑔′ =id𝑏, then 𝑔 =𝑔′.
Referenced from 4 locations
Proof of Lemma 141.22 — Inverses are unique
Proof. 𝑔𝑢𝑛𝑖𝑡=𝑔∘id𝑏ℎ𝑦𝑝.=𝑔∘(𝑓∘𝑔′)𝑎𝑠𝑠𝑜𝑐.=(𝑔∘𝑓)∘𝑔′ℎ𝑦𝑝.=id𝑎∘𝑔′𝑢𝑛𝑖𝑡=𝑔′. ◻
The inverse of an isomorphism 𝑓 is therefore well defined and is written 𝑓−1. In 𝐒𝐞𝐭 the isomorphisms are the bijections; in a preorder 𝑎 ≅𝑏 means 𝑎 ≤𝑏 and 𝑏 ≤𝑎; in a one-object category they are the invertible elements of the monoid.
★★☆ Show that Γ ≅Δ in 𝐂𝐭𝐱 if and only if Δ is obtained from Γ by permuting declarations and renaming variables. Hint: if 𝜏 ∘𝜎 =idΔ then 𝜏(𝑦𝑗)[𝜎] =𝑦𝑗 for each 𝑗, and a term whose substitution instance is a variable is itself a variable.
Referenced from 4 locations
The paths 𝑝 :𝑎 =𝑏 of chapter 30 compose, have inverses 𝑝−1, and satisfy the laws of a category up to higher paths. The strict form of that structure has a name.
A groupoid is a category in which every arrow is an isomorphism.
Referenced from 3 locations
A one-object groupoid is a group: by proposition 141.11 it is a monoid, and every element has an inverse. A preorder is a groupoid exactly when its relation is symmetric, that is, an equivalence relation: the arrow 𝑎 ≤𝑏 has an inverse only if 𝑏 ≤𝑎, and conversely when 𝑏 ≤𝑎 the two composites are identities because each hom-set has at most one element. Every category C contains a groupoid with the same objects, whose arrows are the isomorphisms of C: identities are isomorphisms, and the composite of isomorphisms 𝑓,𝑔 is an isomorphism with inverse 𝑓−1 ∘𝑔−1. For 𝐂𝐭𝐱, exercise 141.3 identifies these arrows as the permutation-renamings.
An arrow of 𝐏𝐚𝐭𝐡𝐬 of positive length has no inverse: the concatenation of a path of length 𝑛 ≥1 with any path has length at least 𝑛, while id𝑒 is the empty path, of length 0. For the same length reason, no free category on a graph with an edge is a groupoid. For typed terms more is true: there is no path from 𝑒 back to 𝑒 of positive length at all, since repeating one would give an infinite reduction sequence from 𝑒, which strong normalization (theorem 2.43) forbids.
Referenced from 2 locations
Every definition of this section has a mirror image obtained by reversing all arrows, and the reversal is itself a category.
For a category C, the category Cop has the same objects, homCop(𝑎,𝑏):=homC(𝑏,𝑎), the identities of C, and composition 𝑔 ∘op𝑓:=𝑓 ∘𝑔.
Referenced from 7 locations
The laws for Cop follow from those of C; for associativity, (ℎ∘op𝑔)∘op𝑓𝑑𝑒𝑓.=𝑓∘(𝑔∘ℎ)𝑎𝑠𝑠𝑜𝑐.=(𝑓∘𝑔)∘ℎ𝑑𝑒𝑓.=ℎ∘op(𝑔∘op𝑓), and the unit laws likewise; also (Cop)op =C. An arrow 𝑎 ⟶𝑏 in Cop is an arrow 𝑏 ⟶𝑎 in C; nothing else changes. A statement 𝑆 about an arbitrary category, formulated in terms of objects, arrows, composition, and identities, has a dual statement 𝑆op obtained by reversing every arrow and every composite. If 𝑆 holds in every category, then so does 𝑆op: applying 𝑆 to Cop yields 𝑆op for C. Lemma 141.27 is proved once and used twice in this way. Concretely, for 𝑅 ⊆𝐴 ×𝐵 put 𝑅⌣:={(𝑏,𝑎) ∣(𝑎,𝑏) ∈𝑅}. Directly from example 141.19, (𝑆∘𝑅)⌣=𝑅⌣∘𝑆⌣,id⌣𝐴=id𝐴,(𝑅⌣)⌣=𝑅. Thus converse is an isomorphism 𝐑𝐞𝐥 →𝐑𝐞𝐥op that is the identity on objects and is its own inverse. A preorder’s opposite is the same set with ≤ reversed.
An object 1 of C is terminal if for every object 𝑎 there is exactly one arrow 𝑎 ⟶1. Dually, an object 0 is initial if for every object 𝑎 there is exactly one arrow 0 ⟶𝑎; an initial object of C is a terminal object of Cop.
Referenced from 3 locations
Any two terminal objects are isomorphic by a unique isomorphism, and likewise any two initial objects.
Referenced from 7 locations
Proof of Lemma 141.27 — Uniqueness up to isomorphism
Proof. Let 1 and 1′ be terminal and let 𝑡 :1 ⟶1′ and 𝑡′ :1′ ⟶1 be the unique arrows. Then 𝑡′ ∘𝑡 :1 ⟶1 and id1 are both arrows 1 ⟶1, so they are equal by uniqueness; likewise 𝑡 ∘𝑡′ =id1′. Any isomorphism 1 ⟶1′ is an arrow 1 ⟶1′, hence equals 𝑡. The statement for initial objects is the dual. ◻
★☆☆ Write out the proof of lemma 141.27 for initial objects without mentioning Cop, and check that it is the displayed proof with every composite reversed.
Referenced from 3 locations
In 𝐂𝐭𝐱 the empty context ⋅ is terminal, the only substitution Γ ⟶ ⋅ being the empty list. 𝐂𝐭𝐱 has no initial object: for any context Γ, the two lists (𝗍𝗍) and (𝖿𝖿) are distinct substitutions Γ ⟶⟨𝟐⟩, where ⟨𝐴⟩:=(𝑥 :𝐴) denotes the one-declaration context; so no hom-set out of Γ into ⟨𝟐⟩ has exactly one element. In 𝐒𝐞𝐭 a one-element set is terminal and the empty set is initial; in a preorder a greatest element is terminal and a least element is initial.
Cancellation and test objects
Injectivity of a function 𝑓 :𝐴 →𝐵 is a statement about elements: 𝑓(𝑥) =𝑓(𝑥′) implies 𝑥 =𝑥′. In a category there are no elements, only arrows, so the statement must be made about arrows into 𝐴.
An arrow 𝑓 :𝑎 ⟶𝑏 is a monomorphism (is monic) if for every object 𝑡 and all 𝑢,𝑢′ :𝑡 ⟶𝑎, 𝑓∘𝑢=𝑓∘𝑢′ ⟹ 𝑢=𝑢′. It is an epimorphism (is epic) if for every object 𝑡 and all 𝑣,𝑣′ :𝑏 ⟶𝑡, 𝑣 ∘𝑓 =𝑣′ ∘𝑓 implies 𝑣 =𝑣′.
Referenced from 5 locations
The quantifier over 𝑡 is the point: 𝑓 is monic when it cannot identify two arrows from any test object 𝑡. An epimorphism in C is a monomorphism in Cop: the two notions are dual, and every fact proved about one for all categories holds for the other. In 𝐒𝐞𝐭 one test object suffices for each.
A function 𝑓 :𝐴 →𝐵 is monic if and only if it is injective, and epic if and only if it is surjective.
Referenced from 7 locations
Proof of Proposition 141.29 — Cancellation in
Proof. Let 1:={ ∗} be a one-element set. A function 𝑢 :1 →𝐴 is determined by the single element 𝑢( ∗) ∈𝐴, and every element 𝑥 ∈𝐴 is 𝑢( ∗) for exactly one such 𝑢, namely the constant function at 𝑥, written 𝑥――. Then 𝑓∘𝑥――=𝑓(𝑥)―――.
Suppose 𝑓 is monic and 𝑓(𝑥) =𝑓(𝑥′). Then 𝑓∘𝑥――(141.3)=𝑓(𝑥)―――ℎ𝑦𝑝.=𝑓(𝑥′)――――(141.3)=𝑓∘𝑥′――, so 𝑥―― =𝑥′―― by cancellation at 𝑡 =1, and 𝑥 =𝑥′. Conversely suppose 𝑓 injective and 𝑓 ∘𝑢 =𝑓 ∘𝑢′ for 𝑢,𝑢′ :𝑡 →𝐴. For each 𝑠 ∈𝑡, 𝑓(𝑢(𝑠)) =𝑓(𝑢′(𝑠)), so 𝑢(𝑠) =𝑢′(𝑠); hence 𝑢 =𝑢′.
Let 2:={0,1}. Suppose 𝑓 is epic and let 𝑦 ∈𝐵; define 𝑣,𝑣′ :𝐵 →2 by 𝑣(𝑧) =1 for all 𝑧, and 𝑣′(𝑧) =1 if 𝑧 is in the image of 𝑓 and 𝑣′(𝑧) =0 otherwise. Then 𝑣 ∘𝑓 =𝑣′ ∘𝑓, both being constantly 1 on 𝐴, so 𝑣 =𝑣′ by cancellation at 𝑡 =2; evaluating at 𝑦 gives 𝑣′(𝑦) =1, so 𝑦 is in the image of 𝑓. Conversely suppose 𝑓 surjective and 𝑣 ∘𝑓 =𝑣′ ∘𝑓 for 𝑣,𝑣′ :𝐵 →𝑡. For each 𝑦 ∈𝐵 choose 𝑥 with 𝑓(𝑥) =𝑦; then 𝑣(𝑦) 𝑐ℎ𝑜𝑖𝑐𝑒=𝑣(𝑓(𝑥)) ℎ𝑦𝑝.=𝑣′(𝑓(𝑥)) 𝑐ℎ𝑜𝑖𝑐𝑒=𝑣′(𝑦), so 𝑣 =𝑣′. ◻
The proof used two facts about 𝐒𝐞𝐭: arrows 1 →𝐴 are the elements of 𝐴, and arrows 𝐵 →2 are the subsets of 𝐵. Each is a statement that a set-theoretic notion is represented by maps from or to one fixed test object.
Let C have a terminal object 1. A global element of an object 𝑎 is an arrow 1 ⟶𝑎.
Referenced from 2 locations
In 𝐒𝐞𝐭 the global elements of 𝐴 are its elements. In 𝐂𝐭𝐱 a global element ⋅ ⟶Γ is a list of closed terms ( ⋅ ⊢𝑎𝑖 :𝐴𝑖)𝑖, one for each declaration of Γ. Call such a list an environment for Γ: it assigns a closed term to each variable, as the environments 𝜂 of chapter 12 assign an element of a domain to each variable. Evaluating Γ ⊢𝑒 :𝐴 in the environment 𝜌 is the action 𝑒[𝜌], a closed term.
★☆☆ An arrow 𝑓 :𝑎 ⟶𝑏 is a split monomorphism if some 𝑟 :𝑏 ⟶𝑎 satisfies 𝑟 ∘𝑓 =id𝑎. Show that a split monomorphism is monic, and that an arrow which is both a split monomorphism and epic is an isomorphism. Each proof is a chain of at most four equalities.
Referenced from 3 locations
In 𝐒𝐞𝐭 an arrow that is both monic and epic is a bijection, hence an isomorphism. In a preorder this fails: every arrow 𝑎 ≤𝑏 is monic and epic, the hom-sets having at most one element, and it is an isomorphism only when also 𝑏 ≤𝑎. It also fails when arrows carry data.
In 𝐌𝐨𝐧, the inclusion 𝑖 :(ℕ, +,0) ⟶(ℤ, +,0) is monic and epic but not an isomorphism.
Referenced from 3 locations
Proof of Proposition 141.31 — Monic and epic but not invertible
Proof. 𝑖 is injective, hence monic by the argument of proposition 141.29, which used only that arrows are functions. It is not an isomorphism: an inverse 𝑗 :ℤ ⟶ℕ would be a homomorphism with 𝑗 ∘𝑖 =idℕ, and 𝑗(1)+𝑗(−1)ℎ𝑜𝑚.=𝑗(1+(−1))=𝑗(0)ℎ𝑜𝑚.=0 gives 𝑗(1) =0 in ℕ, since 0 is the only element of ℕ with an additive inverse, while 𝑗(1) =𝑗(𝑖(1)) =1.
To see that 𝑖 is epic, let 𝑣,𝑣′ :ℤ ⟶𝑀 be homomorphisms with 𝑣 ∘𝑖 =𝑣′ ∘𝑖, that is, 𝑣(𝑛) =𝑣′(𝑛) for all 𝑛 ≥0. For 𝑛 ≥0, 𝑣(−𝑛)⋅𝑣(𝑛)ℎ𝑜𝑚.=𝑣(−𝑛+𝑛)=𝑣(0)ℎ𝑜𝑚.=𝑒,𝑣(𝑛)⋅𝑣(−𝑛)=𝑒 likewise, so 𝑣( −𝑛) is a two-sided inverse of 𝑣(𝑛) in 𝑀. The same holds for 𝑣′( −𝑛) and 𝑣′(𝑛) =𝑣(𝑛). Inverses in a monoid are unique, by the calculation of lemma 141.22 read in the one-object category of 𝑀. Hence 𝑣( −𝑛) =𝑣′( −𝑛), and 𝑣 =𝑣′. ◻
Functors
A monoid homomorphism preserves the multiplication and the unit. The corresponding notion for categories preserves composition and identities, and must also respect the typing of arrows.
A functor 𝐹 :C →D assigns to each object 𝑎 of C an object 𝐹(𝑎) of D and to each arrow 𝑓 :𝑎 ⟶𝑏 an arrow 𝐹(𝑓) :𝐹(𝑎) ⟶𝐹(𝑏), such that for all 𝑓 :𝑎 ⟶𝑏 and 𝑔 :𝑏 ⟶𝑐, 𝐹(𝑔∘𝑓)=𝐹(𝑔)∘𝐹(𝑓),𝐹(id𝑎)=id𝐹(𝑎).
Referenced from 3 locations
By proposition 141.11, a functor between one-object categories is exactly a monoid homomorphism: (141.4) is the homomorphism condition. By example 141.15, a functor between preorders is exactly a monotone map: the object assignment is a function 𝐹 :𝑃 →𝑄, the arrow assignment says that 𝑎 ≤𝑏 implies 𝐹(𝑎) ≤𝐹(𝑏), and the laws are automatic because hom-sets have at most one element.
Referenced from 4 locations
𝑈 :𝐌𝐨𝐧 →𝐒𝐞𝐭 sends a monoid to its carrier and a homomorphism to itself as a function. Both laws hold because composition and identities in 𝐌𝐨𝐧 are those of 𝐒𝐞𝐭.
Referenced from 3 locations
A functor out of a free category is determined by its values on the edges, and any choice of values extends to one.
Let 𝐺 be a graph and D a category. An assignment of an object 𝐹(𝑣) to each vertex and an arrow 𝐹(𝜖) :𝐹(𝑣) ⟶𝐹(𝑣′) to each edge 𝜖 :𝑣 →𝑣′ extends to exactly one functor 𝐹 :𝐅𝐫𝐞𝐞(𝐺) →D.
Referenced from 3 locations
Proof of Proposition 141.35 — Functors out of a free category
Proof. A path is a composite of its edges, 𝜖𝑛 ∘⋯ ∘𝜖1, and the empty path is an identity, so a functor 𝐹 must send the path to 𝐹(𝜖𝑛) ∘⋯ ∘𝐹(𝜖1) and the empty path to id𝐹(𝑣); this fixes 𝐹 on every arrow. Conversely that assignment is a functor: it sends the empty path to an identity, and it sends the concatenation of two paths to the composite of their images. When one of the paths is empty this is a unit law in D; when both are nonempty, both sides are the composite of the same sequence of edge images, bracketed in two ways, and repeated use of associativity in D identifies any two bracketings of one sequence. ◻
For example, the assignment sending every term to the single object ∗ and every one-step reduction to 1 in the one-object category of the monoid (ℕ, +,0) extends to the functor 𝐏𝐚𝐭𝐡𝐬 →(ℕ, +,0) that sends a reduction sequence to its length.
The functor that relates syntax to environments is the following. For a context Γ, let Env(Γ):=hom𝐂𝐭𝐱( ⋅,Γ) be the set of environments for Γ, its global elements. A substitution 𝜎 :Γ ⟶Δ turns an environment for Γ into one for Δ: if 𝜌 assigns closed terms to the variables of Γ, then 𝜎 ∘𝜌 assigns to 𝑦𝑗 the closed term 𝜎(𝑦𝑗)[𝜌].
Env :𝐂𝐭𝐱 →𝐒𝐞𝐭, with Env(Γ):=hom𝐂𝐭𝐱( ⋅,Γ) and Env(𝜎)(𝜌):=𝜎 ∘𝜌, is a functor.
Referenced from 5 locations
Proof of Proposition 141.36 — Environments form a functor
Proof. For 𝜎 :Γ ⟶Δ, 𝜏 :Δ ⟶Θ, and 𝜌 ∈Env(Γ), Env(𝜏∘𝜎)(𝜌)=(𝜏∘𝜎)∘𝜌𝑎𝑠𝑠𝑜𝑐.=𝜏∘(𝜎∘𝜌)=Env(𝜏)(Env(𝜎)(𝜌)),Env(idΓ)(𝜌)=idΓ∘𝜌𝑢𝑛𝑖𝑡=𝜌, using the laws of proposition 141.7. ◻
Nothing in that proof mentioned terms. Replacing ⋅ by any object 𝑟 of any category gives the same functor.
For an object 𝑟 of C, the assignments homC(𝑟, −)(𝑎):=homC(𝑟,𝑎), where − marks the argument that varies, and homC(𝑟, −)(𝑓)(𝑢):=𝑓 ∘𝑢 for 𝑓 :𝑎 ⟶𝑏 and 𝑢 :𝑟 ⟶𝑎 define a functor homC(𝑟, −) :C →𝐒𝐞𝐭.
Referenced from 4 locations
Proof of Proposition 141.37 — Hom-functors
Proof. The calculation of proposition 141.36 with ⋅ replaced by 𝑟: (𝑔 ∘𝑓) ∘𝑢 =𝑔 ∘(𝑓 ∘𝑢) and id𝑎 ∘𝑢 =𝑢. ◻
Functors compose: for 𝐹 :C →D and 𝐺 :D →E, the assignments 𝑎 ↦𝐺(𝐹(𝑎)) and 𝑓 ↦𝐺(𝐹(𝑓)), written 𝐺 ∘𝐹, satisfy (141.4) because each of 𝐹 and 𝐺 does, and the identity assignment is a functor C →C. Small categories and functors therefore form a category 𝐂𝐚𝐭; the restriction to small categories keeps each hom-set a set.
★★☆ Show that a functor sends isomorphisms to isomorphisms, with 𝐹(𝑓−1) =𝐹(𝑓)−1. Then show that the converse fails: give a functor 𝐹 :𝑃 →𝑄 between preorders and an arrow 𝑓 of 𝑃 such that 𝐹(𝑓) is an isomorphism but 𝑓 is not.
Referenced from 3 locations
Variance and presheaves
Environments vary with the context in the direction of the arrows. Terms vary against it. For a fixed type 𝐴 and a context Γ, let Tm𝐴(Γ):={𝑒∣Γ⊢𝑒:𝐴} be the set of terms of type 𝐴 in context Γ, up to 𝛼-equivalence. A substitution 𝜎 :Γ ⟶Δ acts by 𝑒 ↦𝑒[𝜎], which by lemma 141.3 is a function Tm𝐴(Δ) →Tm𝐴(Γ), from the target of 𝜎 to its source. The functor laws hold in this reversed form: lemma 141.5 says 𝑒[𝜏 ∘𝜎] =𝑒[𝜏][𝜎], and the identity law of proposition 141.7 says 𝑒[idΓ] =𝑒. Rather than a second definition of functor with the arrows reversed, the category is reversed: a functor out of Cop (definition 141.25) is a functor that sends an arrow 𝑎 ⟶𝑏 of C to an arrow from the image of 𝑏 to the image of 𝑎.
A presheaf on C is a functor 𝐾 :Cop →𝐒𝐞𝐭. Unwinding definition 141.25, a presheaf assigns a set 𝐾(𝑎) to each object and a function 𝐾(𝑓) :𝐾(𝑏) →𝐾(𝑎) to each arrow 𝑓 :𝑎 ⟶𝑏 of C, with 𝐾(𝑔∘𝑓)=𝐾(𝑓)∘𝐾(𝑔),𝐾(id𝑎)=id𝐾(𝑎).
Referenced from 3 locations
For each type 𝐴, Tm𝐴 with Tm𝐴(𝜎)(𝑒):=𝑒[𝜎] is a presheaf on 𝐂𝐭𝐱.
Referenced from 2 locations
Proof of Proposition 141.39 — Terms form a presheaf
Proof. For 𝜎 :Γ ⟶Δ, 𝜏 :Δ ⟶Θ, and 𝑒 ∈Tm𝐴(Θ), Tm𝐴(𝜏∘𝜎)(𝑒)=𝑒[𝜏∘𝜎]𝑎𝑐𝑡𝑖𝑜𝑛𝑙𝑎𝑤=𝑒[𝜏][𝜎]=Tm𝐴(𝜎)(Tm𝐴(𝜏)(𝑒)),Tm𝐴(idΓ)(𝑒)=𝑒[idΓ]𝑢𝑛𝑖𝑡=𝑒, by lemma 141.5 and proposition 141.7. ◻
Presheaves combine pointwise. For presheaves 𝐾,𝐾′ on C, the assignment 𝑎 ↦𝐾(𝑎) ×𝐾′(𝑎) with (𝐾 ×𝐾′)(𝑓)(𝑢,𝑢′):=(𝐾(𝑓)(𝑢),𝐾′(𝑓)(𝑢′)) satisfies (141.5) in each component, so it is a presheaf, the product 𝐾 ×𝐾′. For types 𝐴 and 𝐵, the product Tm𝐴→𝐵 ×Tm𝐴 has as value at Γ the set of pairs (𝑒1,𝑒2) with Γ ⊢𝑒1 :𝐴 →𝐵 and Γ ⊢𝑒2 :𝐴. Application sends such a pair to 𝑒1𝑒2 ∈Tm𝐵(Γ) by App, and the application clause of definition 2.41 is the equation (𝑒1𝑒2)[𝜎]=𝑒1[𝜎]𝑒2[𝜎]for every 𝜎:Γ⟶Δ.
A presheaf is a system of sets indexed by the objects and acted on contravariantly by the arrows. The semantic values of chapter 49, which are given at every context and restrict along every extension Δ ⊵Γ, are presheaves on the preorder of extensions of example 141.15, read with its arrow Δ ⟶Γ: restriction goes from the value at Γ to the value at Δ, against the arrow, and the restriction law 𝑎 ↾Γ =𝑎 together with the compatibility of successive restrictions is (141.5).
★★☆ Write out the verification that 𝐾 ×𝐾′ satisfies (141.5) for arbitrary presheaves 𝐾,𝐾′. Then show that the conditional defines, for each Γ, a function Tm𝟐(Γ) ×Tm𝐴(Γ) ×Tm𝐴(Γ) →Tm𝐴(Γ), (𝑒,𝑒1,𝑒2) ↦𝗂𝖿(𝑒;𝑒1;𝑒2), and state and prove the analogue of (141.6) for it.
Referenced from 3 locations
Natural transformations
Application is a family of functions appΓ :Tm𝐴→𝐵(Γ) ×Tm𝐴(Γ) →Tm𝐵(Γ), one for each context, and (141.6) says that substituting and then applying gives the same term as applying and then substituting: the family commutes with the action of every arrow. Other families of maps between term sets do not.
For each Γ define 𝑐Γ :Tm𝟐(Γ) →Tm𝟐(Γ) by 𝑐Γ(𝑒):=𝗍𝗍 if 𝑒 is a variable and 𝑐Γ(𝑒):=𝑒 otherwise. Let Δ =𝑦 :𝟐, Γ =𝑓 :𝟐 →𝟐, 𝑥 :𝟐, and 𝜎 =(𝑓 𝑥) :Γ ⟶Δ. Then 𝑐Γ(𝑦[𝜎])=𝑐Γ(𝑓𝑥)=𝑓𝑥,𝑐Δ(𝑦)[𝜎]=𝗍𝗍[𝜎]=𝗍𝗍. Substituting first and inspecting second differs from inspecting first and substituting second. The family is defined at every context but is not compatible with the arrows between contexts.
Referenced from 4 locations
The condition that a family commute with every arrow is an equation between two composites, and such equations are often displayed as diagrams. The equation 𝑔 ∘𝑓 =𝑘 ∘ℎ for 𝑓 :𝑎 ⟶𝑏, 𝑔 :𝑏 ⟶𝑑, ℎ :𝑎 ⟶𝑐, 𝑘 :𝑐 ⟶𝑑 is drawn as
Diagram and the square is said to commute. A diagram is a directed graph whose vertices are objects and whose edges are arrows; it commutes when, for every two paths with the same start and end, the composites along the two paths are equal. A diagram is therefore a finite list of equations, one for each pair of parallel paths, and a diagram is always displayed together with the equations it abbreviates. The picture saves bookkeeping when several equations share arrows; it proves nothing by itself.
Let 𝐹,𝐺 :C →D be functors. A natural transformation 𝛼 :𝐹 ⇒𝐺 is a family of arrows 𝛼𝑎 :𝐹(𝑎) ⟶𝐺(𝑎), one for each object 𝑎 of C, such that for every arrow 𝑓 :𝑎 ⟶𝑏 of C, 𝐺(𝑓)∘𝛼𝑎=𝛼𝑏∘𝐹(𝑓)in homD(𝐹(𝑎),𝐺(𝑏)). The arrows 𝛼𝑎 are the components of 𝛼, and (141.7) is naturality at 𝑓. Drawn as a square,
Diagram commutes for every 𝑓.
Referenced from 3 locations
The arrow ⇒ is the symbol chapter 26 used for context substitutions 𝑓 :Γ ⇒Δ; here it relates two functors and never two contexts, which are related by ⟶. Write Nat(𝐹,𝐺) for the collection of natural transformations 𝐹 ⇒𝐺; when C is small, it is a set because its components form a C-indexed family of sets.
Two instances outside syntax show the condition at its simplest. Between monotone maps 𝐹,𝐺 :𝑃 →𝑄 of preorders, a natural transformation exists exactly when 𝐹(𝑎) ≤𝐺(𝑎) for every 𝑎, and then it is unique: the components are the arrows 𝐹(𝑎) ≤𝐺(𝑎), and (141.7) is automatic because hom𝑄(𝐹(𝑎),𝐺(𝑏)) has at most one element. In 𝐒𝐞𝐭, with Id the identity functor and 𝐷(𝐴):=𝐴 ×𝐴 on objects and 𝐷(𝑓)(𝑥,𝑦):=(𝑓(𝑥),𝑓(𝑦)) on arrows, the diagonal 𝛿𝐴(𝑥):=(𝑥,𝑥) is natural Id ⇒𝐷: 𝐷(𝑓)(𝛿𝐴(𝑥)) =(𝑓(𝑥),𝑓(𝑥)) =𝛿𝐵(𝑓(𝑥)).
For presheaves 𝐾,𝐾′ :Cop →𝐒𝐞𝐭 the arrows reverse: 𝛼 :𝐾 ⇒𝐾′ has components 𝛼𝑎 :𝐾(𝑎) →𝐾′(𝑎) and naturality at 𝑓 :𝑎 ⟶𝑏 in C reads 𝐾′(𝑓) ∘𝛼𝑏 =𝛼𝑎 ∘𝐾(𝑓) as functions 𝐾(𝑏) →𝐾′(𝑎).
With 𝐾:=Tm𝐴→𝐵 ×Tm𝐴 and 𝐾′:=Tm𝐵, naturality of app at 𝜎 :Γ ⟶Δ is, for (𝑒1,𝑒2) ∈𝐾(Δ), 𝐾′(𝜎)(appΔ(𝑒1,𝑒2))=(𝑒1𝑒2)[𝜎](141.6)=𝑒1[𝜎]𝑒2[𝜎]=appΓ(𝐾(𝜎)(𝑒1,𝑒2)). The family 𝑐 of example 141.40 is not natural: the displayed calculation there is the failure of (141.7) at one 𝜎. Naturality is the exact form of “defined uniformly in the context”: a natural family may use its argument only through the operations that substitution preserves.
Referenced from 2 locations
★☆☆ For a closed term ⋅ ⊢𝑡 :𝐴, define atΓ :Tm𝐴→𝐵(Γ) →Tm𝐵(Γ) by atΓ(𝑒):=𝑒 𝑡. Show that at is natural, and identify the one property of 𝑡 the proof uses.
Referenced from 4 locations
Natural transformations compose componentwise. For 𝛼 :𝐹 ⇒𝐺 and 𝛽 :𝐺 ⇒𝐻, set (𝛽 ∘𝛼)𝑎:=𝛽𝑎 ∘𝛼𝑎. Naturality at 𝑓 :𝑎 ⟶𝑏 is 𝐻(𝑓)∘𝛽𝑎∘𝛼𝑎𝑛𝑎𝑡. 𝛽=𝛽𝑏∘𝐺(𝑓)∘𝛼𝑎𝑛𝑎𝑡. 𝛼=𝛽𝑏∘𝛼𝑏∘𝐹(𝑓), and id𝐹 with components id𝐹(𝑎) is natural because both sides of (141.7) are 𝐹(𝑓). Associativity and the unit laws hold componentwise, so functors C →D and natural transformations form a category, the functor category [C,D], with hom[C,D](𝐹,𝐺) =Nat(𝐹,𝐺). Size matters here: Nat(𝐹,𝐺) is a family indexed by the objects of C, and it is a set when C is small, which 𝐂𝐭𝐱 and every preorder in this chapter are. The presheaf category is [Cop,𝐒𝐞𝐭]:=[Cop,𝐒𝐞𝐭].
𝛼 :𝐹 ⇒𝐺 is an isomorphism in [C,D] if and only if every component 𝛼𝑎 is an isomorphism in D.
Referenced from 9 locations
Proof of Proposition 141.43 — Natural isomorphisms
Proof. If 𝛽 ∘𝛼 =id𝐹 and 𝛼 ∘𝛽 =id𝐺, then at each 𝑎 the components satisfy 𝛽𝑎 ∘𝛼𝑎 =id𝐹(𝑎) and 𝛼𝑎 ∘𝛽𝑎 =id𝐺(𝑎). Conversely suppose each 𝛼𝑎 has an inverse 𝛼−1𝑎. The family 𝛽𝑎:=𝛼−1𝑎 is natural: for 𝑓 :𝑎 ⟶𝑏, 𝐹(𝑓)∘𝛽𝑎𝛽𝑏𝛼𝑏=id=𝛽𝑏∘𝛼𝑏∘𝐹(𝑓)∘𝛽𝑎𝑛𝑎𝑡. 𝛼=𝛽𝑏∘𝐺(𝑓)∘𝛼𝑎∘𝛽𝑎𝛼𝑎𝛽𝑎=id=𝛽𝑏∘𝐺(𝑓). Then 𝛽 ∘𝛼 and 𝛼 ∘𝛽 are the identities componentwise. ◻
Such an 𝛼 is a natural isomorphism, and 𝐹 and 𝐺 are naturally isomorphic.
Equivalence of categories
Two categories can agree in everything that is said about arrows and still have different objects. 𝐂𝐭𝐱 has as objects all contexts, under all choices of variable names; a context and its renaming are isomorphic by the renaming substitution and its inverse, and nothing said in terms of arrows distinguishes them. The comparison of 𝐂𝐭𝐱 with its nameless form requires the following notions.
A functor 𝐹 :C →D is
faithful if for all objects 𝑎,𝑏 the function 𝑓 ↦𝐹(𝑓) from homC(𝑎,𝑏) to homD(𝐹(𝑎),𝐹(𝑏)) is injective;
full if each such function is surjective;
fully faithful if it is both;
essentially surjective if every object 𝑑 of D is isomorphic to 𝐹(𝑐) for some object 𝑐 of C.
A full subcategory of D is a subcategory whose hom-sets are exactly those of D; the functor including it into D is fully faithful.
Referenced from 2 locations
The forgetful functor 𝑈 :𝐌𝐨𝐧 →𝐒𝐞𝐭 is faithful, because a homomorphism is a function, and not full, because not every function between carriers is a homomorphism. A monotone map 𝐹 :𝑃 →𝑄 is always faithful, hom-sets having at most one element, and it is full exactly when 𝐹(𝑎) ≤𝐹(𝑏) implies 𝑎 ≤𝑏. The renaming category of example 141.12 is not a full subcategory of 𝐂𝐭𝐱: it has the same objects, but the arrow (𝑓 𝑥) of (141.1) is not a renaming.
A functor 𝐹 :C →D is an equivalence if there are a functor 𝐺 :D →C and natural isomorphisms 𝜂 :IdC ⇒𝐺 ∘𝐹 and 𝜀 :𝐹 ∘𝐺 ⇒IdD. When there is a 𝐺 with 𝐺 ∘𝐹 =IdC and 𝐹 ∘𝐺 =IdD as functors, 𝐹 is an isomorphism of categories.
Referenced from 6 locations
An isomorphism of categories is a bijection on objects and on each hom-set. An equivalence need not be: it identifies objects only up to isomorphism, which is the identification the arrows can see.
A functor 𝐹 :C →D is an equivalence if and only if it is fully faithful and essentially surjective.
Referenced from 7 locations
Proof of Theorem 141.46 — Characterization of equivalences
Proof. Only if. Let 𝐺,𝜂,𝜀 be as in definition 141.45. Essential surjectivity: for an object 𝑑, 𝜀𝑑 :𝐹(𝐺(𝑑)) ⟶𝑑 is an isomorphism, so 𝑑 ≅𝐹(𝑐) with 𝑐:=𝐺(𝑑). Faithfulness: for 𝑓,𝑓′ :𝑎 ⟶𝑏 with 𝐹(𝑓) =𝐹(𝑓′), naturality of 𝜂 at 𝑓 reads 𝐺(𝐹(𝑓)) ∘𝜂𝑎 =𝜂𝑏 ∘𝑓, so 𝑓𝜂𝑏𝑖𝑠𝑜=𝜂−1𝑏∘𝜂𝑏∘𝑓𝑛𝑎𝑡. 𝜂=𝜂−1𝑏∘𝐺(𝐹(𝑓))∘𝜂𝑎ℎ𝑦𝑝.=𝜂−1𝑏∘𝐺(𝐹(𝑓′))∘𝜂𝑎𝑛𝑎𝑡. 𝜂=𝜂−1𝑏∘𝜂𝑏∘𝑓′=𝑓′. The functor 𝐺 is faithful as well. If 𝑔,𝑔′ :𝑑 ⟶𝑑′ and 𝐺(𝑔) =𝐺(𝑔′), naturality of 𝜀 gives 𝑔𝜀𝑑𝑖𝑠𝑜=𝑔∘𝜀𝑑∘𝜀−1𝑑𝑛𝑎𝑡. 𝜀=𝜀𝑑′∘𝐹(𝐺(𝑔))∘𝜀−1𝑑ℎ𝑦𝑝.=𝜀𝑑′∘𝐹(𝐺(𝑔′))∘𝜀−1𝑑𝑛𝑎𝑡. 𝜀=𝑔′∘𝜀𝑑∘𝜀−1𝑑𝜀𝑑𝑖𝑠𝑜=𝑔′. Fullness: let 𝑔 :𝐹(𝑎) ⟶𝐹(𝑏) and set 𝑓:=𝜂−1𝑏 ∘𝐺(𝑔) ∘𝜂𝑎 :𝑎 ⟶𝑏. Then 𝐺(𝐹(𝑓))𝑛𝑎𝑡. 𝜂=𝜂𝑏∘𝑓∘𝜂−1𝑎𝑑𝑒𝑓. 𝑓=𝜂𝑏∘𝜂−1𝑏∘𝐺(𝑔)∘𝜂𝑎∘𝜂−1𝑎𝑖𝑠𝑜=𝐺(𝑔), and faithfulness of 𝐺 gives 𝐹(𝑓) =𝑔.
If. Let 𝐹 be fully faithful and essentially surjective. The inverse functor is built in four stages.
Objects. By essential surjectivity, choose for each object 𝑑 of D an object 𝐺(𝑑) of C and an isomorphism 𝜀𝑑 :𝐹(𝐺(𝑑)) ⟶𝑑; this choice is discussed after the proof.
Arrows. For an arrow 𝑔 :𝑑 ⟶𝑑′, the composite 𝜀−1𝑑′ ∘𝑔 ∘𝜀𝑑 is an arrow 𝐹(𝐺(𝑑)) ⟶𝐹(𝐺(𝑑′)), and since 𝐹 is fully faithful there is exactly one arrow 𝐺(𝑔) :𝐺(𝑑) ⟶𝐺(𝑑′) with 𝐹(𝐺(𝑔))=𝜀−1𝑑′∘𝑔∘𝜀𝑑. 𝐺 is a functor: 𝐹(𝐺(id𝑑)) (141.8)=𝜀−1𝑑 ∘𝜀𝑑 𝑖𝑠𝑜=id𝐹(𝐺(𝑑)) 𝑓𝑢𝑛𝑐𝑡𝑜𝑟=𝐹(id𝐺(𝑑)), and for 𝑔′ :𝑑′ ⟶𝑑″, 𝐹(𝐺(𝑔′)∘𝐺(𝑔))=𝐹(𝐺(𝑔′))∘𝐹(𝐺(𝑔))(141.8)=𝜀−1𝑑″∘𝑔′∘𝜀𝑑′∘𝜀−1𝑑′∘𝑔∘𝜀𝑑=𝜀−1𝑑″∘(𝑔′∘𝑔)∘𝜀𝑑(141.8)=𝐹(𝐺(𝑔′∘𝑔)), so faithfulness of 𝐹 gives the two functor laws.
The counit. Equation (141.8) rearranged, 𝑔 ∘𝜀𝑑 =𝜀𝑑′ ∘𝐹(𝐺(𝑔)), is naturality of 𝜀 :𝐹 ∘𝐺 ⇒IdD, and its components are isomorphisms, so 𝜀 is a natural isomorphism by proposition 141.43.
The unit. For each object 𝑐 of C, 𝜀𝐹(𝑐) :𝐹(𝐺(𝐹(𝑐))) ⟶𝐹(𝑐) is an isomorphism between two objects in the image of 𝐹, so by full faithfulness there is exactly one 𝜂𝑐 :𝑐 ⟶𝐺(𝐹(𝑐)) with 𝐹(𝜂𝑐) =𝜀−1𝐹(𝑐). It is an isomorphism: for the unique 𝜃 with 𝐹(𝜃) =𝜀𝐹(𝑐), 𝐹(𝜃 ∘𝜂𝑐) =𝜀𝐹(𝑐) ∘𝜀−1𝐹(𝑐) =𝐹(id𝑐), so 𝜃 ∘𝜂𝑐 =id𝑐 by faithfulness, and likewise 𝜂𝑐 ∘𝜃 =id𝐺(𝐹(𝑐)). Naturality of 𝜂 at 𝑓 :𝑐 ⟶𝑐′ is 𝐺(𝐹(𝑓)) ∘𝜂𝑐 =𝜂𝑐′ ∘𝑓; apply 𝐹 to both sides: 𝐹(𝐺(𝐹(𝑓)))∘𝐹(𝜂𝑐)(141.8)=𝜀−1𝐹(𝑐′)∘𝐹(𝑓)∘𝜀𝐹(𝑐)∘𝜀−1𝐹(𝑐)=𝜀−1𝐹(𝑐′)∘𝐹(𝑓)=𝐹(𝜂𝑐′)∘𝐹(𝑓), and faithfulness of 𝐹 gives the equation itself. ◻
Let 𝐹 :C →D be an equivalence. Suppose (𝐺,𝜂,𝜀) and (𝐺′,𝜂′,𝜀′) are two choices of the data in definition 141.45. Then 𝐺 and 𝐺′ are naturally isomorphic.
Referenced from 5 locations
Proof of Lemma 141.47 — Inverse functors are unique up to natural isomorphism
Proof. For each object 𝑑 of D, define 𝛼𝑑:=𝐺′(𝜀𝑑)∘𝜂′𝐺(𝑑):𝐺(𝑑)⟶𝐺′(𝑑). Both factors are isomorphisms. For 𝑔 :𝑑 ⟶𝑒, functoriality, naturality of 𝜀, and naturality of 𝜂′ give 𝐺′(𝑔)∘𝛼𝑑𝑑𝑒𝑓.=𝐺′(𝑔∘𝜀𝑑)∘𝜂′𝐺(𝑑)𝑛𝑎𝑡. 𝜀=𝐺′(𝜀𝑒)∘𝐺′(𝐹(𝐺(𝑔)))∘𝜂′𝐺(𝑑)𝑛𝑎𝑡. 𝜂′=𝐺′(𝜀𝑒)∘𝜂′𝐺(𝑒)∘𝐺(𝑔)𝑑𝑒𝑓.=𝛼𝑒∘𝐺(𝑔). Thus 𝛼 :𝐺 ⇒𝐺′ is natural, and proposition 141.43 makes it a natural isomorphism. ◻
The “if” direction chose one object 𝐺(𝑑) and one isomorphism 𝜀𝑑 for each 𝑑. When no rule singles them out, this is a use of the axiom of choice, over a class when the objects of D do not form a set; and the inverse functor 𝐺 depends on the choices, two inverse functors from different choices being naturally isomorphic by lemma 141.47. In the case that follows the choice is canonical, a renaming to 𝑥1,…,𝑥𝑛, and no choice principle is used.
Let 𝐂𝐭𝐱0 be the full subcategory of 𝐂𝐭𝐱 on the contexts whose variables are 𝑥1,𝑥2,…,𝑥𝑛 in order, for some 𝑛. The inclusion 𝐂𝐭𝐱0 →𝐂𝐭𝐱 is an equivalence of categories, and not an isomorphism of categories.
Referenced from 6 locations
Proof of Proposition 141.48 — Named and nameless contexts
Proof. The inclusion of a full subcategory is fully faithful. It is essentially surjective: a context Γ =𝑦1 :𝐴1,…,𝑦𝑛 :𝐴𝑛 is isomorphic to 𝑋:=𝑥1 :𝐴1,…,𝑥𝑛 :𝐴𝑛 by the renaming 𝜎:=(𝑦1,…,𝑦𝑛) :Γ ⟶𝑋 and 𝜏:=(𝑥1,…,𝑥𝑛) :𝑋 ⟶Γ, since 𝜏 ∘𝜎 =(𝑥1[𝜎],…,𝑥𝑛[𝜎]) =(𝑦1,…,𝑦𝑛) =idΓ and 𝜎 ∘𝜏 =(𝑦1[𝜏],…,𝑦𝑛[𝜏]) =(𝑥1,…,𝑥𝑛) =id𝑋. So the inclusion is an equivalence by theorem 141.46. It is not an isomorphism of categories: an isomorphism of categories is a bijection on objects, and the context 𝑦 :𝟐 is not in 𝐂𝐭𝐱0. ◻
An object of 𝐂𝐭𝐱0 is determined by its list of types, so the contexts of 𝐂𝐭𝐱0 are nameless, a variable being its position, while its arrows are still lists of named terms. The proposition is the precise statement that the choice of variable names in a context adds nothing that substitutions can see. An inverse to the inclusion sends each context to its canonical renaming; a different choice of canonical names gives another inverse, naturally isomorphic to it by lemma 141.47.
Let 𝐅𝐢𝐧 be the full subcategory of 𝐒𝐞𝐭 on the finite sets, and 𝐅𝐢𝐧0 its full subcategory on the sets [𝑛]:={0,…,𝑛 −1} for 𝑛 ≥0. The inclusion 𝐅𝐢𝐧0 →𝐅𝐢𝐧 is fully faithful, and essentially surjective because a set with 𝑛 elements is in bijection with [𝑛]; so it is an equivalence by theorem 141.46. It is not an isomorphism of categories, since { ∗} is not of the form [𝑛]. Here the choice in the “if” direction is genuine: an inverse functor must fix, for each finite set, one enumeration of its elements, and no enumeration is canonical; two inverses built from different enumerations are naturally isomorphic by lemma 141.47. Up to equivalence, a finite set is its size; up to isomorphism of categories it is not.
Referenced from 2 locations
★★★ For a preorder 𝑃, let 𝑃/ ∼ be the set of equivalence classes of the relation 𝑎 ∼𝑏 iff 𝑎 ≤𝑏 and 𝑏 ≤𝑎, ordered by [𝑎] ≤[𝑏] iff 𝑎 ≤𝑏. Show that [𝑎] ≤[𝑏] is well defined and antisymmetric, that the quotient map 𝑃 →𝑃/ ∼ is an equivalence of categories, and that it is an isomorphism of categories exactly when ≤ is antisymmetric. For the generality order ⊒ on type schemes of chapter 3, show that two schemes lie in one class exactly when they have the same monotype instances.
Referenced from 3 locations
Representable functors and the Yoneda lemma
A functor 𝐾 :C →𝐒𝐞𝐭 assigns to each object 𝑎 a set of observations 𝐾(𝑎), and to each arrow 𝑓 :𝑎 ⟶𝑏 a way 𝐾(𝑓) of transporting observations. The hom-functor homC(𝑟, −) of proposition 141.37 is the system whose observations at 𝑎 are the arrows 𝑟 ⟶𝑎, transported by composition. The question this section answers is when an arbitrary 𝐾 is of this form: when every observation in every 𝐾(𝑎) arises, by transport along a unique arrow, from one observation at one test object 𝑟.
A functor 𝐾 :C →𝐒𝐞𝐭 is representable if there are an object 𝑟 and a natural isomorphism 𝜙 :homC(𝑟, −) ⇒𝐾. The pair (𝑟,𝜙) is a representation, and 𝑢:=𝜙𝑟(id𝑟) ∈𝐾(𝑟) is its universal element.
Referenced from 3 locations
The following calculation shows that 𝜙 is recovered from 𝑢 alone, which is why 𝑢 is called universal. For any natural 𝜙 :homC(𝑟, −) ⇒𝐾, any object 𝑎, and any 𝑓 :𝑟 ⟶𝑎, 𝜙𝑎(𝑓)𝑢𝑛𝑖𝑡=𝜙𝑎(𝑓∘id𝑟)ℎ𝑜𝑚−𝑓𝑢𝑛𝑐𝑡𝑜𝑟=𝜙𝑎(homC(𝑟,−)(𝑓)(id𝑟))𝑛𝑎𝑡. 𝜙𝑎𝑡𝑓=𝐾(𝑓)(𝜙𝑟(id𝑟))=𝐾(𝑓)(𝑢). So every observation 𝜙𝑎(𝑓) is the transport 𝐾(𝑓)(𝑢) of the one element 𝑢, and when 𝜙 is an isomorphism every element of 𝐾(𝑎) is such a transport for exactly one 𝑓. Calculation (141.9) did not use that 𝜙 is an isomorphism; it holds for every natural transformation out of a hom-functor, and that is the lemma. One more family is needed to state how the lemma varies with 𝑟.
For 𝑔 :𝑠 ⟶𝑟, the functions homC(𝑔, −)𝑎 :homC(𝑟,𝑎) →homC(𝑠,𝑎), ℎ ↦ℎ ∘𝑔, form a natural transformation homC(𝑔, −) :homC(𝑟, −) ⇒homC(𝑠, −).
Referenced from 3 locations
Proof of Lemma 141.51 — Precomposition
Proof. At 𝑓 :𝑎 ⟶𝑏 both composites of (141.7) send ℎ ∈homC(𝑟,𝑎) to 𝑓 ∘ℎ ∘𝑔, by associativity. ◻
Let 𝐾 :C →𝐒𝐞𝐭 be a functor and 𝑟 an object. The functions Φ𝐾𝑟:Nat(homC(𝑟,−),𝐾)→𝐾(𝑟),Φ𝐾𝑟(𝜙):=𝜙𝑟(id𝑟),Ψ𝐾𝑟:𝐾(𝑟)→Nat(homC(𝑟,−),𝐾),Ψ𝐾𝑟(𝑢)𝑎(𝑓):=𝐾(𝑓)(𝑢), are mutually inverse. The bijection is natural in 𝐾 and in 𝑟: for every natural 𝛼 :𝐾 ⇒𝐾′ and every 𝜙 :homC(𝑟, −) ⇒𝐾, and for every 𝑔 :𝑠 ⟶𝑟 and every 𝜓 :homC(𝑠, −) ⇒𝐾, Φ𝐾′𝑟(𝛼∘𝜙)=𝛼𝑟(Φ𝐾𝑟(𝜙)),Φ𝐾𝑟(𝜓∘homC(𝑔,−))=𝐾(𝑔)(Φ𝐾𝑠(𝜓)).
Referenced from 9 locations
Proof of Theorem 141.52 — Yoneda
Proof. The proof has five parts: Ψ(𝑢) is natural, Φ ∘Ψ and Ψ ∘Φ are identities, and the two naturality equations hold. The superscript and subscript of Φ,Ψ are omitted when fixed.
Ψ(𝑢) is natural. Fix 𝑢 ∈𝐾(𝑟). The components Ψ(𝑢)𝑎 :homC(𝑟,𝑎) →𝐾(𝑎) are functions. For 𝑓 :𝑎 ⟶𝑏 and ℎ ∈homC(𝑟,𝑎), 𝐾(𝑓)(Ψ(𝑢)𝑎(ℎ))=𝐾(𝑓)(𝐾(ℎ)(𝑢))(141.4)=𝐾(𝑓∘ℎ)(𝑢)=Ψ(𝑢)𝑏(𝑓∘ℎ)=Ψ(𝑢)𝑏(homC(𝑟,−)(𝑓)(ℎ)), which is (141.7) at 𝑓.
Φ ∘Ψ =id𝐾(𝑟). For 𝑢 ∈𝐾(𝑟), Φ(Ψ(𝑢))=Ψ(𝑢)𝑟(id𝑟)=𝐾(id𝑟)(𝑢)(141.4)=id𝐾(𝑟)(𝑢)=𝑢.
Ψ ∘Φ is the identity. For natural 𝜙 :homC(𝑟, −) ⇒𝐾, an object 𝑎, and 𝑓 :𝑟 ⟶𝑎, Ψ(Φ(𝜙))𝑎(𝑓)=𝐾(𝑓)(𝜙𝑟(id𝑟))(141.9)=𝜙𝑎(𝑓), so Ψ(Φ(𝜙)) and 𝜙 agree at every component and every argument.
Naturality in 𝐾. For 𝛼 :𝐾 ⇒𝐾′ and 𝜙 :homC(𝑟, −) ⇒𝐾, the composite 𝛼 ∘𝜙 is natural, being a composite of natural transformations, and Φ𝐾′𝑟(𝛼∘𝜙)=(𝛼∘𝜙)𝑟(id𝑟)=𝛼𝑟(𝜙𝑟(id𝑟))=𝛼𝑟(Φ𝐾𝑟(𝜙)).
Naturality in 𝑟. For 𝑔 :𝑠 ⟶𝑟 and 𝜓 :homC(𝑠, −) ⇒𝐾, the composite 𝜓 ∘homC(𝑔, −) is a natural transformation homC(𝑟, −) ⇒𝐾 by lemma 141.51, and Φ𝐾𝑟(𝜓∘homC(𝑔,−))=𝜓𝑟(homC(𝑔,−)𝑟(id𝑟))=𝜓𝑟(id𝑟∘𝑔)𝑢𝑛𝑖𝑡=𝜓𝑟(𝑔)(141.9)=𝐾(𝑔)(𝜓𝑠(id𝑠))=𝐾(𝑔)(Φ𝐾𝑠(𝜓)), where (141.9) is applied to 𝜓 at the arrow 𝑔 :𝑠 ⟶𝑟. ◻
The theorem applies to presheaves through the opposite category. A presheaf 𝐾 :Cop →𝐒𝐞𝐭 is a functor on Cop, and the hom-functor of Cop at 𝑟 is homCop(𝑟, −) =homC( −,𝑟), the presheaf 𝑎 ↦homC(𝑎,𝑟) with 𝑓 :𝑎 ⟶𝑏 acting by ℎ ↦ℎ ∘𝑓. Theorem 141.52 for Cop therefore reads:
For a presheaf 𝐾 on C and an object 𝑟, the functions Φ(𝜙):=𝜙𝑟(id𝑟)∈𝐾(𝑟),Ψ(𝑢)𝑎(ℎ):=𝐾(ℎ)(𝑢)for ℎ:𝑎⟶𝑟, are mutually inverse between Nat(homC( −,𝑟),𝐾) and 𝐾(𝑟), naturally in 𝐾 and in 𝑟.
Referenced from 10 locations
Proof of Corollary 141.53 — Yoneda for presheaves
Proof. Every arrow and composite in the proof of theorem 141.52 is read in Cop; by definition 141.25, an arrow 𝑓 :𝑎 ⟶𝑏 of Cop is an arrow 𝑏 ⟶𝑎 of C and homCop(𝑟, −)(𝑓) is ℎ ↦ℎ ∘𝑓 in C. No step of that proof used anything about C beyond (141.2), which hold in Cop. ◻
The two naturality equations (141.10) say one thing about a function of two arguments, an object and a functor. To state it as one naturality, form a category of pairs.
For categories C and D, the category C ×D has pairs (𝑎,𝑏) of objects as objects, pairs (𝑓,𝑔) of arrows 𝑓 :𝑎 ⟶𝑎′, 𝑔 :𝑏 ⟶𝑏′ as arrows (𝑎,𝑏) ⟶(𝑎′,𝑏′), composition (𝑓′,𝑔′) ∘(𝑓,𝑔):=(𝑓′ ∘𝑓,𝑔′ ∘𝑔), and identities (id𝑎,id𝑏). A functor out of a product category is called a bifunctor.
Referenced from 3 locations
The laws hold in each coordinate separately. A bifunctor 𝐹 :C ×D →E is a functor in each argument when the other is fixed, since 𝐹(𝑓,id𝑏) and 𝐹(id𝑎,𝑔) satisfy (141.4); and the two partial actions commute, 𝐹(𝑓,id𝑏′) ∘𝐹(id𝑎,𝑔) =𝐹(𝑓,𝑔) =𝐹(id𝑎′,𝑔) ∘𝐹(𝑓,id𝑏), because (𝑓,id𝑏′) ∘(id𝑎,𝑔) =(𝑓,𝑔) =(id𝑎′,𝑔) ∘(𝑓,id𝑏) in C ×D.
The assignments (𝑎,𝑏) ↦homC(𝑎,𝑏) and, for 𝑓 :𝑎′ ⟶𝑎 and 𝑔 :𝑏 ⟶𝑏′, homC(𝑓,𝑔):homC(𝑎,𝑏)→homC(𝑎′,𝑏′),ℎ↦𝑔∘ℎ∘𝑓, define a functor homC( −, −) :Cop ×C →𝐒𝐞𝐭.
Referenced from 4 locations
Proof of Proposition 141.55 — The hom bifunctor
Proof. An arrow (𝑎,𝑏) ⟶(𝑎′,𝑏′) of Cop ×C is a pair of an arrow 𝑓 :𝑎′ ⟶𝑎 of C and an arrow 𝑔 :𝑏 ⟶𝑏′, so the typing of homC(𝑓,𝑔) is as stated. For a second pair 𝑓′ :𝑎″ ⟶𝑎′, 𝑔′ :𝑏′ ⟶𝑏″, the composite in Cop ×C is (𝑓 ∘𝑓′,𝑔′ ∘𝑔), and homC(𝑓∘𝑓′,𝑔′∘𝑔)(ℎ)=(𝑔′∘𝑔)∘ℎ∘(𝑓∘𝑓′)𝑎𝑠𝑠𝑜𝑐.=𝑔′∘(𝑔∘ℎ∘𝑓)∘𝑓′=homC(𝑓′,𝑔′)(homC(𝑓,𝑔)(ℎ)); identities are preserved by the unit laws. ◻
Fixing 𝑎 recovers proposition 141.37; fixing 𝑏 gives the presheaf homC( −,𝑏). In 𝐂𝐭𝐱 the bifunctor reads hom𝐂𝐭𝐱(𝜎,𝜏)(𝜌) =𝜏 ∘𝜌 ∘𝜎: substitute on both sides.
Let 𝐹,𝐺 :C ×D →E be bifunctors and 𝛼𝑎,𝑏 :𝐹(𝑎,𝑏) ⟶𝐺(𝑎,𝑏) a family of arrows. Then 𝛼 is natural as a transformation 𝐹 ⇒𝐺 if and only if it is natural in each variable with the other fixed: for all 𝑓 :𝑎 ⟶𝑎′ and 𝑔 :𝑏 ⟶𝑏′, 𝐺(𝑓,id𝑏) ∘𝛼𝑎,𝑏 =𝛼𝑎′,𝑏 ∘𝐹(𝑓,id𝑏) and 𝐺(id𝑎,𝑔) ∘𝛼𝑎,𝑏 =𝛼𝑎,𝑏′ ∘𝐹(id𝑎,𝑔).
Referenced from 3 locations
Proof of Lemma 141.56 — Naturality in each variable
Proof. Joint naturality at (𝑓,𝑔) specializes to the two separate conditions at (𝑓,id𝑏) and (id𝑎,𝑔). Conversely, since (𝑓,𝑔) =(id𝑎′,𝑔) ∘(𝑓,id𝑏) in C ×D, 𝐺(𝑓,𝑔)∘𝛼𝑎,𝑏=𝐺(id𝑎′,𝑔)∘𝐺(𝑓,id𝑏)∘𝛼𝑎,𝑏𝑛𝑎𝑡. 𝑖𝑛𝑎=𝐺(id𝑎′,𝑔)∘𝛼𝑎′,𝑏∘𝐹(𝑓,id𝑏)𝑛𝑎𝑡. 𝑖𝑛𝑏=𝛼𝑎′,𝑏′∘𝐹(id𝑎′,𝑔)∘𝐹(𝑓,id𝑏)=𝛼𝑎′,𝑏′∘𝐹(𝑓,𝑔). ◻
Let C be small, so that [C,𝐒𝐞𝐭] is a category. Define two functors C ×[C,𝐒𝐞𝐭] →𝐒𝐞𝐭 on objects by Ev(𝑟,𝐾):=𝐾(𝑟),Nt(𝑟,𝐾):=Nat(homC(𝑟,−),𝐾), and on an arrow (𝑔,𝛼) :(𝑠,𝐾) ⟶(𝑟,𝐾′), that is 𝑔 :𝑠 ⟶𝑟 and 𝛼 :𝐾 ⇒𝐾′, by Ev(𝑔,𝛼)(𝑢):=𝛼𝑟(𝐾(𝑔)(𝑢)),Nt(𝑔,𝛼)(𝜓):=𝛼∘𝜓∘homC(𝑔,−).
Ev and Nt are bifunctors, and the family Φ𝐾𝑟 :Nt(𝑟,𝐾) →Ev(𝑟,𝐾) of theorem 141.52 is a natural isomorphism Nt ⇒Ev.
Referenced from 2 locations
Proof of Proposition 141.57 — Yoneda as a natural isomorphism
Proof. Ev(id𝑟,id𝐾) is the identity, and for (𝑔′,𝛼′) :(𝑟,𝐾′) ⟶(𝑟′,𝐾″) and 𝑢 ∈𝐾(𝑠), Ev(𝑔′,𝛼′)(Ev(𝑔,𝛼)(𝑢))=𝛼′𝑟′(𝐾′(𝑔′)(𝛼𝑟(𝐾(𝑔)(𝑢))))𝑛𝑎𝑡. 𝛼𝑎𝑡𝑔′=𝛼′𝑟′(𝛼𝑟′(𝐾(𝑔′)(𝐾(𝑔)(𝑢))))(141.4)=(𝛼′∘𝛼)𝑟′(𝐾(𝑔′∘𝑔)(𝑢))=Ev(𝑔′∘𝑔,𝛼′∘𝛼)(𝑢). Nt(id𝑟,id𝐾)(𝜓) =𝜓 because homC(id𝑟, −) is the identity transformation, and the composition law is associativity of composition of natural transformations together with homC(𝑔′ ∘𝑔, −) =homC(𝑔, −) ∘homC(𝑔′, −), both sides sending ℎ to ℎ ∘𝑔′ ∘𝑔. By lemma 141.56, naturality of Φ may be checked in each variable separately, and the two conditions are exactly the two equations of (141.10). Each component is a bijection by theorem 141.52, so Φ is a natural isomorphism by proposition 141.43. ◻
A presheaf 𝐾 on C is representable when 𝐾 ≅homC( −,𝑟) in [Cop,𝐒𝐞𝐭] for some object 𝑟, and its universal element is again 𝜙𝑟(id𝑟) ∈𝐾(𝑟) for the isomorphism 𝜙.
The two facts used in proposition 141.29 are representations. The identity functor Id :𝐒𝐞𝐭 →𝐒𝐞𝐭 is represented by 1 with universal element ∗ ∈1: by theorem 141.52, Nat(hom𝐒𝐞𝐭(1, −),Id) ≅Id(1) =1, and the component at 𝐴 of the transformation determined by ∗ sends 𝑥―― :1 →𝐴 to Id(𝑥――)( ∗) =𝑥, the bijection between arrows 1 →𝐴 and elements of 𝐴. The presheaf P(𝐵):={𝑆 ∣𝑆 ⊆𝐵}, with P(𝑓) the inverse image along 𝑓, is represented by 2 with universal element {1} ⊆2: the transformation determined by {1} sends 𝜒 :𝐵 →2 to 𝜒−1{1}, the bijection between arrows 𝐵 →2 and subsets of 𝐵. In 𝐂𝐭𝐱, the test object ⋅ observes environments (proposition 141.36), and proposition 141.60 shows that the test object ⟨𝐴⟩ observes terms.
The functor y :C →[Cop,𝐒𝐞𝐭] sends an object 𝑟 to y(𝑟):=homC( −,𝑟) and an arrow 𝑔 :𝑟 ⟶𝑟′ to the natural transformation y(𝑔) :y(𝑟) ⇒y(𝑟′) with components ℎ ↦𝑔 ∘ℎ.
Referenced from 3 locations
That y(𝑔) is natural and that y satisfies (141.4) are both associativity: 𝑔 ∘(ℎ ∘𝑓) =(𝑔 ∘ℎ) ∘𝑓 gives naturality, and (𝑔′ ∘𝑔) ∘ℎ =𝑔′ ∘(𝑔 ∘ℎ) gives y(𝑔′ ∘𝑔) =y(𝑔′) ∘y(𝑔).
The functor y :C →[Cop,𝐒𝐞𝐭] is fully faithful: for objects 𝑟,𝑟′, the function 𝑔 ↦y(𝑔) :homC(𝑟,𝑟′) →Nat(y(𝑟),y(𝑟′)) is a bijection. Consequently y(𝑟) ≅y(𝑟′) in [Cop,𝐒𝐞𝐭] implies 𝑟 ≅𝑟′ in C: a representable presheaf determines its representing object up to isomorphism. The name embedding records these two properties; by theorem 141.46, y is an equivalence onto the full subcategory of representable presheaves.
Referenced from 5 locations
Proof of Corollary 141.59 — The embedding is fully faithful
Proof. Apply corollary 141.53 with 𝐾:=y(𝑟′): Nat(y(𝑟),y(𝑟′)) ≅y(𝑟′)(𝑟) =homC(𝑟,𝑟′), and the inverse Ψ sends 𝑔 to the transformation ℎ ↦y(𝑟′)(ℎ)(𝑔) =𝑔 ∘ℎ, which is y(𝑔). For the consequence, let 𝜙 :y(𝑟) ⇒y(𝑟′) and 𝜓 :y(𝑟′) ⇒y(𝑟) be mutually inverse. By the bijection just proved, 𝜙 =y(𝑔) and 𝜓 =y(𝑔′) for unique 𝑔 :𝑟 ⟶𝑟′ and 𝑔′ :𝑟′ ⟶𝑟, and y(𝑔′∘𝑔)𝑓𝑢𝑛𝑐𝑡𝑜𝑟=y(𝑔′)∘y(𝑔)𝑐ℎ𝑜𝑖𝑐𝑒=𝜓∘𝜙ℎ𝑦𝑝.=idy(𝑟)𝑓𝑢𝑛𝑐𝑡𝑜𝑟=y(id𝑟), so 𝑔′ ∘𝑔 =id𝑟 by injectivity of y on arrows; likewise 𝑔 ∘𝑔′ =id𝑟′. ◻
The presheaf of terms is representable, and the representing object is the smallest context that declares a variable of the right type.
For each type 𝐴 and its one-declaration context ⟨𝐴⟩ =(𝑥 :𝐴), the functions 𝜙Γ:hom𝐂𝐭𝐱(Γ,⟨𝐴⟩)→Tm𝐴(Γ),𝜙Γ((𝑒)):=𝑒, form a natural isomorphism y(⟨𝐴⟩) ⇒Tm𝐴, with universal element the variable 𝑥 ∈Tm𝐴(⟨𝐴⟩).
Referenced from 8 locations
Proof of Proposition 141.60 — Terms are represented by one variable
Proof. A substitution Γ ⟶⟨𝐴⟩ is a one-element list (𝑒) with Γ ⊢𝑒 :𝐴, so 𝜙Γ is a bijection with inverse 𝑒 ↦(𝑒). Naturality at 𝜎 :Γ ⟶Δ: for (𝑒) ∈hom𝐂𝐭𝐱(Δ,⟨𝐴⟩), Tm𝐴(𝜎)(𝜙Δ((𝑒)))=𝑒[𝜎]𝑑𝑒𝑓. ∘=𝜙Γ((𝑒)∘𝜎)=𝜙Γ(y(⟨𝐴⟩)(𝜎)((𝑒))). The universal element is 𝜙⟨𝐴⟩(id⟨𝐴⟩), and id⟨𝐴⟩ =(𝑥), so it is 𝑥. ◻
For types 𝐴,𝐵, the natural transformations Tm𝐴 ⇒Tm𝐵 are in bijection with terms 𝑥 :𝐴 ⊢𝑏 :𝐵: the transformation determined by 𝑏 has components Tm𝐴(Γ)→Tm𝐵(Γ),𝑒↦𝑏[𝑒/𝑥], and every natural transformation arises from exactly one 𝑏, namely the image of the variable 𝑥 under its component at ⟨𝐴⟩.
Referenced from 6 locations
Proof of Theorem 141.61 — Natural operations on terms are substitutions
Proof. By proposition 141.60, Tm𝐴 ≅y(⟨𝐴⟩), so composing with that isomorphism identifies Nat(Tm𝐴,Tm𝐵) with Nat(y(⟨𝐴⟩),Tm𝐵). Corollary 141.53 with 𝑟 =⟨𝐴⟩ and 𝐾 =Tm𝐵 identifies Nat(y(⟨𝐴⟩),Tm𝐵) with Tm𝐵(⟨𝐴⟩), the terms 𝑥 :𝐴 ⊢𝑏 :𝐵. Tracing the bijections: a term 𝑏 goes to Ψ(𝑏), whose component at Γ sends (𝑒) :Γ ⟶⟨𝐴⟩ to Tm𝐵((𝑒))(𝑏) =𝑏[(𝑒)] =𝑏[𝑒/𝑥]; and a natural 𝛼 :Tm𝐴 ⇒Tm𝐵 goes to Φ(𝛼 ∘𝜙) =𝛼⟨𝐴⟩(𝜙⟨𝐴⟩(id⟨𝐴⟩)) =𝛼⟨𝐴⟩(𝑥). ◻
The theorem is the precise form of the slogan that a natural family may use its argument only through substitution-preserving operations. The family at of exercise 141.8 is the term 𝑥 𝑡; the family 𝑐 of example 141.40 corresponds to no term, because 𝑐⟨𝟐⟩(𝑥) =𝗍𝗍 would give 𝑐Γ(𝑒) =𝗍𝗍[𝑒/𝑥] =𝗍𝗍 for every 𝑒, which 𝑐 does not satisfy.
A context with one more declaration decomposes, as a presheaf, into the shorter context and the terms of the added type.
For a context Γ, a type 𝐴, and a variable 𝑥 not declared in Γ, the functions hom𝐂𝐭𝐱(Δ,Γ,𝑥 :𝐴) →hom𝐂𝐭𝐱(Δ,Γ) ×Tm𝐴(Δ), (𝑏1,…,𝑏𝑛,𝑎) ↦((𝑏1,…,𝑏𝑛),𝑎), form a natural isomorphism y(Γ,𝑥 :𝐴) ⇒y(Γ) ×Tm𝐴.
Referenced from 4 locations
Proof of Proposition 141.62 — Extension of a context
Proof. A substitution Δ ⟶Γ,𝑥 :𝐴 is a list of 𝑛 +1 terms whose first 𝑛 entries form a substitution Δ ⟶Γ and whose last entry is a term Δ ⊢𝑎 :𝐴, so the function is a bijection. Naturality at 𝜎 :Δ′ ⟶Δ: both composites send (𝑏1,…,𝑏𝑛,𝑎) to ((𝑏1[𝜎],…,𝑏𝑛[𝜎]),𝑎[𝜎]), by definition 141.4 on the left and componentwise on the right. ◻
For types 𝐴,𝐴′,𝐵, natural transformations Tm𝐴 ×Tm𝐴′ ⇒Tm𝐵 are in bijection with terms 𝑥 :𝐴, 𝑥′ :𝐴′ ⊢𝑏 :𝐵. The term 𝑏 determines the components (𝑒,𝑒′)↦𝑏[𝑒/𝑥,𝑒′/𝑥′]. When 𝐴 =𝐴′ →𝐵, application is represented by the term 𝑥 𝑥′.
Referenced from 4 locations
Proof of Theorem 141.63 — Natural binary operations are two-variable terms
Proof. Apply proposition 141.62 to the context 𝑥 :𝐴 and the added declaration 𝑥′ :𝐴′, then apply proposition 141.60 for 𝐴. The resulting natural isomorphisms give y(𝑥:𝐴,𝑥′:𝐴′)≅y(𝑥:𝐴)×Tm𝐴′≅Tm𝐴×Tm𝐴′. Yoneda (corollary 141.53) therefore identifies natural transformations from the product to Tm𝐵 with Tm𝐵(𝑥 :𝐴,𝑥′ :𝐴′). Tracing the representing substitution sends (𝑒,𝑒′) to 𝑏[𝑒/𝑥,𝑒′/𝑥′]. For 𝐴 =𝐴′ →𝐵, the term 𝑥 𝑥′ has type 𝐵, and its component is ordinary application. ◻
Representability says that every element of every 𝐾(𝑎) is 𝐾(𝑓)(𝑢) for exactly one 𝑓 :𝑎 ⟶𝑟. Collect all the elements of all the 𝐾(𝑎) into one structure, with the arrows that transport one to another, and this uniqueness becomes a terminal object. The case 𝐾 =Tm𝐴 shows the structure first. Its elements are the terms in context, the pairs (Γ,𝑒) with Γ ⊢𝑒 :𝐴; a substitution 𝜎 :Γ ⟶Δ transports (Δ,𝑒′) to (Γ,𝑒′[𝜎]), so take as arrows (Γ,𝑒) ⟶(Δ,𝑒′) the substitutions 𝜎 :Γ ⟶Δ with 𝑒′[𝜎] =𝑒. These compose: if also 𝜏 :Δ ⟶Θ with 𝑒″[𝜏] =𝑒′, then 𝑒″[𝜏 ∘𝜎] =𝑒″[𝜏][𝜎] =𝑒 by lemma 141.5; and idΓ is an arrow (Γ,𝑒) ⟶(Γ,𝑒). The pair (⟨𝐴⟩,𝑥) is terminal: an arrow (Γ,𝑒) ⟶(⟨𝐴⟩,𝑥) is a substitution 𝜎 :Γ ⟶⟨𝐴⟩ with 𝑥[𝜎] =𝑒, that is, with 𝜎(𝑥) =𝑒, and (𝑒) is the only one. Write ∫Tm𝐴 for this category. The same recipe applies to any presheaf.
For a presheaf 𝐾 on C, the category of elements ∫𝐾 has as objects the pairs (𝑎,𝑢) with 𝑎 an object of C and 𝑢 ∈𝐾(𝑎), and as arrows (𝑎,𝑢) ⟶(𝑏,𝑣) the arrows 𝑓 :𝑎 ⟶𝑏 of C with 𝐾(𝑓)(𝑣) =𝑢, composed as in C. The projection 𝜋𝐾 :∫𝐾 →C sends (𝑎,𝑢) to 𝑎 and an arrow to itself.
Referenced from 2 locations
The composite of 𝑓 :(𝑎,𝑢) ⟶(𝑏,𝑣) and 𝑔 :(𝑏,𝑣) ⟶(𝑐,𝑤) is an arrow of ∫𝐾 because 𝐾(𝑔 ∘𝑓)(𝑤) (141.5)=𝐾(𝑓)(𝐾(𝑔)(𝑤)) 𝑔𝑎𝑟𝑟𝑜𝑤=𝐾(𝑓)(𝑣) 𝑓𝑎𝑟𝑟𝑜𝑤=𝑢, and id𝑎 is one because 𝐾(id𝑎)(𝑢) =𝑢; the laws are inherited from C. When C is a preorder 𝑃, ∫𝐾 is again a preorder: (𝑎,𝑢) ≤(𝑏,𝑣) exactly when 𝑎 ≤𝑏 and the restriction of 𝑣 along 𝑎 ≤𝑏 is 𝑢. The elements of 𝐾 are stacked over the elements of 𝑃, each 𝑢 ∈𝐾(𝑎) over its index 𝑎, and ordered by restriction; the projection forgets the upper layer.
A presheaf 𝐾 on C is representable if and only if ∫𝐾 has a terminal object. A terminal object (𝑟,𝑢) gives the representation Ψ(𝑢) :y(𝑟) ⇒𝐾 with universal element 𝑢, and every representation arises so.
Referenced from 4 locations
Proof of Proposition 141.65 — Representability by a terminal element
Proof. Let 𝜙 :y(𝑟) ⇒𝐾 be a natural isomorphism with universal element 𝑢 =𝜙𝑟(id𝑟); by corollary 141.53, 𝜙 =Ψ(𝑢), so 𝜙𝑎(𝑓) =𝐾(𝑓)(𝑢) for 𝑓 :𝑎 ⟶𝑟. An arrow (𝑎,𝑣) ⟶(𝑟,𝑢) of ∫𝐾 is an 𝑓 :𝑎 ⟶𝑟 with 𝐾(𝑓)(𝑢) =𝑣, that is, with 𝜙𝑎(𝑓) =𝑣; since 𝜙𝑎 is a bijection there is exactly one, so (𝑟,𝑢) is terminal. Conversely let (𝑟,𝑢) be terminal. For each 𝑎 and 𝑣 ∈𝐾(𝑎) there is exactly one 𝑓 :𝑎 ⟶𝑟 with 𝐾(𝑓)(𝑢) =𝑣, so Ψ(𝑢)𝑎 :𝑓 ↦𝐾(𝑓)(𝑢) is a bijection homC(𝑎,𝑟) →𝐾(𝑎); Ψ(𝑢) is natural by corollary 141.53, hence a natural isomorphism by proposition 141.43, with universal element Ψ(𝑢)𝑟(id𝑟) =𝐾(id𝑟)(𝑢) =𝑢. ◻
For 𝐾 =Tm𝐴 this is proposition 141.60 seen from inside. For the representable y(𝑟) =homC( −,𝑟), the objects of ∫y(𝑟) are the arrows ℎ :𝑎 ⟶𝑟 and an arrow (𝑎,ℎ) ⟶(𝑏,ℎ′) is an 𝑓 :𝑎 ⟶𝑏 with ℎ′ ∘𝑓 =ℎ: the arrows into 𝑟 with the factorizations between them. This category is called the slice of C over 𝑟 and written C/𝑟.
★★☆ Reconstruct theorem 141.63 by tracing the two representing isomorphisms in the opposite order. Verify naturality of (𝑒,𝑒′) ↦𝑏[𝑒/𝑥,𝑒′/𝑥′] directly from lemma 141.5, and calculate the application instance 𝑏:=𝑥 𝑥′ when 𝐴 =𝐴′ →𝐵.
Referenced from 3 locations
★★☆ State corollary 141.53 for a preorder 𝑃 regarded as a category, where a presheaf is a family of sets 𝐾(𝑎) with restriction maps 𝐾(𝑏) →𝐾(𝑎) for 𝑎 ≤𝑏. Show that it specializes to: a natural transformation from the down-set {𝑎 ∣𝑎 ≤𝑟} (with one-element sets) to 𝐾 is the same as an element of 𝐾(𝑟). Conclude, for the semantic values of chapter 49 regarded as a presheaf 𝑉 on the extension preorder, that an element of 𝑉(Γ) is the same as a family (𝑎Δ)Δ⊵Γ with 𝑎Δ ∈𝑉(Δ) compatible with restriction.
Referenced from 3 locations
The chapter began with three composition structures proved one at a time. Two of them are objects of one kind: 𝐂𝐭𝐱 is a category, and the semantic values of chapter 49 form a presheaf on its preorder of extensions. The restriction lemma of that chapter, which states that evaluating a term and then restricting the value equals restricting the environment and then evaluating, is the statement that evaluation is a natural transformation between two presheaves on that preorder. That is the statement of agreement which the three repeated proofs could not express: two composition structures agree when a family of maps between them is natural. What theorem 141.61 does for one variable, theorem 141.63 does for two; the contexts that represent families of terms whose types depend on earlier variables belong to the later treatment of dependent categorical semantics.
Bibliographic notes.
Categories, functors, and natural transformations were introduced by Eilenberg and Mac Lane [EML45], who defined categories in order to define naturality. The lemma of section 141.9 is named for Yoneda; Mac Lane [ML98a] records its origin in a conversation with him in 1954, and proves the characterization of equivalences, theorem 141.46, as his Theorem IV.4.1. The treatment of monomorphisms and epimorphisms by test objects, and the example of proposition 141.31, follow Asperti and Longo [AL91], whose book develops category theory from typed lambda calculi. The representability of the presheaf of terms by a one-variable context, proposition 141.60, is the elementary case of the representable natural transformations that Awodey uses to define natural models of dependent type theory [Awo18].
Suggested first pass.
None of these problems is a prerequisite for later chapters. Begin with exercise 141.12, exercise 141.17, continue with exercise 141.15, exercise 141.20, and finish by building 𝐂𝐭𝐱 in exercise 141.23.
★☆☆ Let Γ =𝑢 :𝟐 →𝟐, Δ =𝑦 :𝟐 →𝟐, 𝑣 :𝟐, and Θ =𝑧 :𝟐. Take 𝜎 =(𝜆𝑤 :𝟐. 𝑢 𝑤, 𝑢 𝗍𝗍) and 𝜏 =(𝑦 𝑣). Compute 𝜏 ∘𝜎, then compute (𝜆𝑢 :𝟐. 𝑧)[𝜏 ∘𝜎] and (𝜆𝑢 :𝟐. 𝑧)[𝜏][𝜎] separately, choosing bound names explicitly at each step, and confirm lemma 141.5 on this instance. Say at which step a bound name had to be changed and why.
Referenced from 6 locations
★★☆ In 𝐑𝐞𝐥, show that (𝑆 ∘𝑅)⌣ =𝑅⌣ ∘𝑆⌣ and (id𝐴)⌣ =id𝐴, and that 𝑅 ↦𝑅⌣ is an isomorphism of categories 𝐑𝐞𝐥 →𝐑𝐞𝐥op that is the identity on objects. Write each equation as a quantified statement before proving it.
Referenced from 3 locations
★★☆ Show that the product category 𝑃 ×𝑄 of two preorders is the preorder on pairs with (𝑎,𝑏) ≤(𝑎′,𝑏′) iff 𝑎 ≤𝑎′ and 𝑏 ≤𝑏′, and that the hom bifunctor of proposition 141.55 on a preorder 𝑃 is the functor 𝑃op ×𝑃 →𝐒𝐞𝐭 sending (𝑎,𝑏) to a one-element set if 𝑎 ≤𝑏 and to the empty set otherwise. Given a functor 𝑃op ×𝑃 →𝐒𝐞𝐭 whose values are empty or one-element sets, show that it is naturally isomorphic to the canonical functor determined by the monotone map 𝑃op ×𝑃 →{0 ≤1} that records whether each value is inhabited. Show that the hom bifunctor corresponds in this sense to the map sending (𝑎,𝑏) to 1 exactly when 𝑎 ≤𝑏, whose monotonicity is transitivity of ≤.
Referenced from 3 locations
★★★ Prove directly, without passing through Cop, that for objects 𝑟,𝑠 of C the function 𝑔 ↦homC(𝑔, −) is a bijection homC(𝑠,𝑟) →Nat(homC(𝑟, −),homC(𝑠, −)). Give the inverse explicitly and verify both composites, displaying the component types throughout. Conclude that 𝑟 ↦homC(𝑟, −) is a fully faithful functor Cop →[C,𝐒𝐞𝐭].
Referenced from 4 locations
★☆☆ Verify that [C,D] satisfies (141.2): state each law as an equation between natural transformations, reduce it to an equation between components at an arbitrary object 𝑎, and discharge it by the corresponding law in D.
Referenced from 3 locations
★★☆ For a context Γ =𝑥1 :𝐴1,…,𝑥𝑛 :𝐴𝑛 and a type 𝐴, the weakening 𝑤:=(𝑥1,…,𝑥𝑛) :Γ,𝑥 :𝐴 ⟶Γ is a substitution. Show that 𝑤 is an epimorphism in 𝐂𝐭𝐱, because its action on terms is injective, but not a monomorphism, and that it is not an isomorphism. Explain why the global-element argument of proposition 141.29 does not transfer to 𝐂𝐭𝐱.
Referenced from 4 locations
★★☆ A category with a terminal object 1 has enough points if for all 𝑓,𝑓′ :𝑎 ⟶𝑏 with 𝑓 ≠𝑓′ there is a global element 𝑢 :1 ⟶𝑎 with 𝑓 ∘𝑢 ≠𝑓′ ∘𝑢. Show that this holds exactly when the functor homC(1, −) is faithful. Show that 𝐒𝐞𝐭 has enough points and that 𝐂𝐭𝐱 does not: exhibit two distinct substitutions out of ⟨𝑃⟩, for an atomic type 𝑃, that agree on every environment.
Referenced from 3 locations
★★☆ Let 𝐹 :C →D be an equivalence with inverse functors 𝐺 and 𝐺′, each with its pair of natural isomorphisms. Construct a natural isomorphism 𝐺 ⇒𝐺′ from the given data, and verify its naturality.
Referenced from 3 locations
★☆☆ Deduce from proposition 141.65, lemma 141.27 that a representing object is unique up to isomorphism, the consequence stated in corollary 141.59, and check that an isomorphism in ∫𝐾 projects to an isomorphism in C.
Referenced from 4 locations
★☆☆ For a covariant functor 𝐾 :C →𝐒𝐞𝐭, define ∫𝐾 with objects (𝑎,𝑢), 𝑢 ∈𝐾(𝑎), and arrows (𝑎,𝑢) ⟶(𝑏,𝑣) the 𝑓 :𝑎 ⟶𝑏 with 𝐾(𝑓)(𝑢) =𝑣. Describe ∫Env for the functor of proposition 141.36: its objects, its arrows, and its initial object.
Referenced from 3 locations
★★☆ Let 𝐾 be the presheaf on 𝐂𝐭𝐱 with 𝐾(Γ):={0,1} for every Γ and 𝐾(𝜎):=id{0,1} for every 𝜎. Show that 𝐾 is not representable. Hint: if 𝐾 ≅y(Δ) then hom𝐂𝐭𝐱( ⋅,Δ) has exactly two elements; count the closed terms of a type, distinguishing an atomic type 𝑃 from an inhabited type.
Referenced from 3 locations
★★★ Practical project.ctx-category Implement the category 𝐂𝐭𝐱 of example 141.9 for the calculus of chapter 2: terms with named binders, contexts, substitutions as lists of terms, the typing check of definition 141.1, the action 𝑒[𝜎] with capture-avoiding renaming, and the composition and identities of definition 141.4. Maintain the invariant that every constructed substitution is well typed at its declared source and target and that no action captures a free variable. The program must print each composite it computes. The acceptance test consists of the following named inputs and outcomes:
𝜏 ∘𝜎 of (141.1) prints 𝜆𝑤 :𝟐. 𝑓 𝑥 up to the bound name;
the two bracketings of exercise 141.1 print 𝛼-equal lists;
the two actions of example 141.6 print an abstraction whose body is the free variable 𝑥, and agree;
idΔ ∘𝜎 and 𝜎 ∘idΓ for the 𝜎 of (141.1) both print 𝜎;
the two actions of exercise 141.12 agree;
for 𝑏:=𝑥 𝗍𝗍 with 𝑥 :𝟐 →𝟐 ⊢𝑏 :𝟐, the component of theorem 141.61 at Γ =𝑓 :𝟐 →𝟐, 𝑥 :𝟐 applied to 𝑓 prints 𝑓 𝗍𝗍;
evaluating that component family at the variable 𝑥 in the context ⟨𝟐 →𝟐⟩ prints 𝑥 𝗍𝗍;
for Γ =𝑓 :𝟐 →𝟐, 𝑥 :𝟐, the renaming (𝑓,𝑥) :Γ ⟶(𝑥1 :𝟐 →𝟐, 𝑥2 :𝟐) of proposition 141.48 and its inverse (𝑥1,𝑥2) compose to the two identities.
acting with 𝜎 =(𝑓 𝑥) :Γ ⟶Δ on 𝗂𝖿(𝗍𝗍;𝑦;𝖿𝖿) prints 𝗂𝖿(𝗍𝗍;𝑓 𝑥;𝖿𝖿) and preserves its Boolean type;
attempting to compose 𝜏 with an identity whose target is not the source of 𝜏 is rejected before a substitution is constructed;
if the avoid-set contains 𝑥,𝑥′,…,𝑥(16), where 𝑥(𝑘) denotes 𝑥 followed by 𝑘 primes, freshening returns a name outside that seventeen-element set.
Referenced from 6 locations