Notes on Higher Categories and Categorical Logic

Lectures by Mike Shulman and Peter LeFanu Lumsdaine; Notes by Jacob Alexander Gross August 12, 2016

Contents

1Preface 1

2Preliminaries 2

3SyntaxandFreeObjects 7

4TypeTheoryforCategorieswithProducts 11

5MotivatingExample(MonoidObjects) 15

6Multicategories 16

7Type-TheoreticProofofUniquenessofInverses 20

8HeytingAlgebras 23

9First-OrderLogic 26

10 First-Order Theories 28

11 Quantifiers as Adjoints 29

12 First-Order Hyperdoctrines 33

13 Bi-Initiality 36

14 More on Bi-Initiality 42

15 The Classifying of an Algebraic Theory 45

16 From Regular Categories to Regular Hyperdoctrines 49

17 The Logic of Presheaves 51

1 18 Cartesian Closed Multicategories 56

19 On Completeness 61

20 Intuitionistic Higher-Order Logic 66

21 The Free Topos 70

22 Some Dependent Types 74

23 References 77

1 Preface

The “ 2016” conference was held during August 2016 at Dal- housie University, located in the Canadian provence of Nova Scotia. During the month prior to this conference Mike Shulman and Peter LeFanu Lumsdaine, as part of the AARMS summer school, gave a series of lectures each morning comprising a course called “Higher Categories and Categorical Logic.” These are one of the participants’ notes. The lectures could be summarized as saying that the goal is to prove things in (1-/higher/multi-)categories with the syntax of type theory by using type theories to present free structures. The first 10 lectures were given by Shulman and the next 10 by Lumsdaine. The first lecture begins at Section 3. The section after this one, “Preliminaries” breezes over a couple of defini- tions/facts about monads, monoidal categories, equivalences and graphs which are essential to digesting the material. A solid grounding in categories, functors, natural transformations, (co)limits, adjoints and Yoneda’s lemma is assumed. Multicategories, especially cartesian multicategories, are used often. All the multicategorical theory is introduced as needed throughout the notes. That aside, the reader may still find it helpful (as the note-taker did) to give the occasional glance at Tom Leinster’s book [Lei03] when more details are desired. Lastly, at the end of some sections there are exercises. There were three homeworks and one final exam given by the instructors. The exercises are all taken from the collection of these four documents and put at the end of whatever lecture the problem seemed most appropriate to. This will allow the reader to, if desired, their hands dirty with pens, paper, chalk, coffee, etc. And of course, any inaccuracies are entirely my own.

Conventions That two objects A, B are isomorphic will be written A = B. • ∼ That two categories C , D are equivalent will be written C D. • ≃ The natural numbers start at 0. •

2 2 Preliminaries

We try to bring to the forefront of the readers mind, who may be somewhat fresh to category theory, some of the key definitions and theorems from elementary category theory relevant to the notes.

Adjoints Definition 2.1. A cartesian closed category C is category with finite prod- ucts such that for every X C , the functor X : C C has a right adjoint. ∈ −× → Theorem 2.2. (Freyd’s Adjoint Functor Theorem) Let G : D C be a continuous functor. The following conditions are sufficient for G to admit→ a left adjoint

1. (General) D is complete and locally small and G satisfies the solution condition: For each object X C there is a small set I and an I-indexed ∈ family of arrows fi : X GAi such that every arrow h : X GA can be written as a composite h→= Gt f , some some i I and some→t : A A. ◦ i ∈ i → 2. (Special) C is locally small and D is locally small, complete and well- powered with a cogenerating set: asetS of objects such that the D( ,S ) − α are jointly faithful (where Sα ranges over all elements of S).

Equivalence Definition 2.3. The skeleton of a category C ,writtenskC ,isthefull isomorphism-dense subcategory of C for which no two distinct objects are iso- morphic.

Theorem 2.4. The following are equivalent

there is an equivalence of categories C D • ≃ there is a functor F : C D that is full, faithful and essentially surjective • → C and D have isomorphic skeleta skC = skD • ∼ Definition 2.5. An adjoint equivalence is an adjunction F G for which the unit and counit are natural isomorphisms. ⊣

Proposition 2.6. An adjoint equivalence is an equivalence of categories.

Proposition 2.7. If two categories C and D are equivalent, then there exists an adjoint equivalence between them.

3 Graphs

Definition 2.8. A (directed) graph G consists of a set of objects G0, together with for each object pair of objects X, Y, a set of arrows G (X, Y ).

There is a forgetful functor U : Cat Gr taking a category to its underlying graph. This functor admits a left adjoint→

F Gr Cat.

U

Definition 2.9. A multigraph G consists of a set of objects G0, together with for every object X a finite list of objects A1,...,An a set of arrows G (A1,...,An; X)

Monads Definition 2.10. A functor U : D C is monadic if it has a left adjoint → F : C D and the canonical comparison functor D C T is an equivalence of → → categories (where C T denotes the Eilenberg-Moore category).

Definition 2.11. A split coequalizer is a collection of objects and arrows t t f A B h C g such that f s =1 • ◦ B g s = t h • ◦ ◦ h t =1 , and • ◦ C h f = h g • ◦ ◦ Definition 2.12. Let U : C D be a functor. Then, a U-split pair is a → parallel pair of morphisms f,g in C for which there exists a split coequalizer

t t Uf UA UB h C Ug in D.

Definition 2.13. (Beck’s Monadicity Theorem) A functor U : C D if monadic if and only if → 1. U admits a left adjoint 2. U reflects isomorphisms 3. C has coequalizers of U-split pairs and U preserves them

4 Monoidal Categories Definition 2.14. A strict is a category C along with a product functor : C C C and a unit object I such that ⊗ × → A (B C)=(A B) C, ⊗ ⊗ ⊗ ⊗ A I = A, ⊗ I A = A, ⊗ for all A, B, C C . ∈ Definition 2.15. A monoidal category is a category C along with a functor : C C C ,aunit object I along with natural isomorphisms ⊗ × → associators αA,B,C : A (B C) (A B) C, left unitors λA : I A A and right unitors ρ : A⊗ I ⊗A satisfying→ ⊗ the⊗pentagon ⊗ → ⊗ →

αA,B C,D (A (B C)) D ⊗ A ((B C) D) ⊗ ⊗ ⊗ ⊗ ⊗ ⊗ α 1 1 α A,B,C ⊗ D A ⊗ B,C,D ((A B) C) D A (B (C D)) ⊗ ⊗ ⊗ ⊗ ⊗ ⊗ αA B,C,D ⊗ αA,B,C D ⊗ (A B) (C D) ⊗ ⊗ ⊗ and triangle

α (A I) B A,I,B A (I B) ⊗ ⊗ ⊗ ⊗

ρA 1B 1 λ ⊗ A ⊗ A A B ⊗ identities.

Theorem 2.16. (Coherence for Monoidal Categories) Given a monoidal category (C , ,I,α,ρ,λ), any well-typed equation constructed only from α,λ,ρ and their inverses⊗ holds.

Definition 2.17. Let C and D be monoidal categories. A lax monoidal functor (F,φ):C D is a functor F : C D along with coherence morphisms → → φ : FA FB F (A B),φ: I FI A,B ⊗ → ⊗ I → such that, for all A, B, C C the following diagrams commute ∈

5 φA,B 1FC φA B,C (FA FB) FC ⊗ F (A B) FC ⊗ F ((A B) C) ⊗ ⊗ ⊗ ⊗ ⊗ ⊗

αFA,FB,FC FαA,B,C

1FA φB,C φA,B C FA (FB FC) ⊗ FA F (B C) ⊗ F (A (B C)) ⊗ ⊗ ⊗ ⊗ ⊗ ⊗

1 φ φA,I FA I FA ⊗ FA FI F (A I) ⊗ ⊗ ⊗ ρFA

FρA FA

φ 1 φI,A I FA ⊗ FA FI FA F (I A) ⊗ ⊗ ⊗ λFA

FλA FA

Definition 2.18. A colax monoidal functor (F,φ):C D is a functor → F : C D together with coherence morphisms → φ : FA FB F (A B),φ: FI I A,B ⊗ → ⊗ I → satisfying conditions dual to those required of coherence morphisms for lax monoidal functors.

Definition. 2.19. A weak (resp. strict) monoidal functor is a lax monoidal functor (F,φ) for which all coherence morphisms are isomorphisms (resp. iden- tities).

Theorem 2.20. (Strictification) For every monoidal category C there is a weak monoidal functor out of C into a strict monoidal category, which is an equivalence of categories.

Definition 2.21. A braided monoidal category is a monoidal category along with a natural isomorphism

σ : A B B A, A,B ⊗ → ⊗ called braiding, such that the hexagon identities hold:

6 σA,B C A (B C) ⊗ (B C) A ⊗ ⊗ ⊗ ⊗

1 1 αA,B,C− αB,C,A− (A B) C B (C A) ⊗ ⊗ ⊗ ⊗ σ 1 1 σ A,B ⊗ C B ⊗ A,C

α (B A) C B,A,C B (A C) ⊗ ⊗ ⊗ ⊗

σA B,C (A B) C ⊗ C (A B) ⊗ ⊗ ⊗ ⊗

αA,B,C αC,B,A

A (B C) (C A) B ⊗ ⊗ ⊗ ⊗ 1 σ σ 1 A ⊗ B,C A,C ⊗ B

1 α− A (C B) A,C,B (A C) B. ⊗ ⊗ ⊗ ⊗ Definition 2.22. A symmetric monoidal category is a bradied monoidal category (C ,σ) such that

σB,A σA,B =1A B ◦ ⊗ for all objects A, B C . In this case we call σ the symmetry. ∈ Definition 2.23. Let V be a symmetric monoidal category. A V-category is the following data :

A C of objects • 0 for all objects A, B C , an hom object C (A, B) V • ∈ 0 ∈ for all objects A, B, C C a composition morphism in V • ∈ 0 c : C (A, B) C (B,C) C (A, C) A,B,C ⊗ → for every object A C ,aV-morphism u : I C (A, A) • ∈ A → such that the diagrams

7 (C (A, B) C (B,C)) C (C, D) ∼= C (A, B) (C (B,C) C (C, D)) ⊗ ⊗ ⊗ ⊗ c 1 1 c A,B,C ⊗ ⊗ B,C,D C (A, C) C (C, D) C (A, B) C (B,D) ⊗ ⊗ cA,C,D cA,B,D

C (A, D)

I C (A, B) ∼= C (A, B) ∼= C (A, B) I ⊗ ⊗ u 1 1 u A ⊗ ⊗ B

cA,B,C C (A, A) C (A, B) C (A, B) C (A, B) C (B,B) ⊗ cA,B,C ⊗ commute.

3 Syntax and Free Objects

The first lecture begins here.

A “free object” is something in the image of a left adjoint. Syntax describes free objects for the use of proving things about all objects. To help clarify this, let us begin with the following claim.

h 1 Proposition 3.1. Let G be a group. Define g = hgh− , for g, h G. Then, ∈ h h h (g1g2) = g1 g2 . Proof.

h h 1 1 g1 g2 =(hg1h− )(hg2h− ) 1 = hg1g2h− 1 = h(g1g2)h− h =(g1g2) .

In what sense in this proof “wrong?” Well, the group axioms only tell us how to multiply two things, but we are multiplying three things. We were also overly liberal about parenthesis and so on. But, we all secretly know such details can be filled in. We’ll give a second proof now, using the idea of free groups e.g. those in the image the the left adjoint to the forgetful functor into Set

8 F Grp Set.

U The idea is that it will suffice to know the theorem for free groups.

Proposition 3.2. The free group on a set X consists of of el- ements of X and their formal inverses (without cancellable pairs), the binary operation is given by concatenation of strings. Proof. (Sketch). For a set X we shall define FX as described in the claim. First, it must be shown that FX is a group. For strings M,N, we shall define multiplication by induction on the length of N: Suppose l(N) = 0. Then, MN = M. • 1 Suppose l(N)=p + 1. Then, N = N ′h (or N = N ′h− , but that case • 1 1 is left easily to the reader) and if MN′ ends in h− ,sayMN = Qh− , define M(N ′h)=Q otherwise M(N ′h)=(MN′)h.

Associativity, unitality, etc. are left to the reader. It remains then to check the universal property. Say we are given a map φ : X UG,defineφ¯ : FX G inductively → → φ¯(empty) = e • φ¯(Mh)=φ¯(M)φ(h). •

Slick Remark 3.3. You just proved the cut-elimination theorem!

Category theoretically, Proposition 3.2. is a “coherence theorem.” So, why does it suffice to prove Proposition 1.1. for free groups? h h h Well, let g1,g2,h X. Suppose, g1 g2 =(g1g2) in FX.Then,ifg1′ g2′ h′ G, ∈ ¯ ∈ given φX UG with g1g2h g1′ g2′ h we have φ : FX G and moreover that h h →h h *→h h → g g (g′ ) (g′ ) and (g g ) (g′ g′ ) . 1 2 *→ 1 2 1 2 *→ 1 2

Logic Now we turn our attention to the following adjunction

F Cat Gr.

U

9 Gr denotes the category whose objects are directed graphs (e.g. the data of a category without the operations) and whose arrows are graph homomorphisms. For a graph G ,wehave ob F G = obG • F G (A, B) = strings A A A ... B in G . • → 1 → 2 → → We shall write

f g A B C h D

as

x : A h(g(f(x))) : D. (1) ⊢ (1) is called a sequent or judgement. The left hand side of (1) is called the antecedent or context and the right hand side is called the consequent or succedent. A “type theory” is a collection of sequent/judgment forms (what they may look like) and rules (how to derive judgements).

A Type Theory for Categories Under G

There are two rules:

x : A M : B f : B C in G x : A ⊢f(M):C → x : A x : A ⊢ ⊢ Remark 3.4. We are choosing here not to put “f : A B” in the context, → but have “if f : B C in G ” as a side judgement. This is because f is just an edge in a graph. →

Example 3.5. (Side judgements omitted)

x : A x : A x : A ⊢f(x):B ⊢ x : A g(f(x)) : C ⊢ x : A h(g(f(x))) : D ⊢

10 A Different Type Theory for Categories Under G

It is possible also to use a more category-theoretic syntax. M : A BN: B C N→ M : A C → ◦ → Example 3.6.

1 : A Af: A B A → → f 1 : A Cg: B C ◦ A → → g (f 1 ):A C ◦ ◦ A → Remark 3.7. This does not correspond to the free category! There is no associativity or unitality. We have to quotient out by the axioms

P (N M) (P N) M • ◦ ◦ ≡ ◦ ◦ 1 M M • B ◦ ≡ M 1 M. • ◦ A ≡ We will say more about ‘ ’nexttime. ≡

Categories With Products We will now concern ourselves with categories with products. In particular we mean categories with chosen binary and nullary products e.g. we select one from each isomorphism class. Then, by PrCat we mean the category whose objects are categories with (chosen) binary and nullary products (or equivalently, finite products and terminal object) and whose morphisms are product-preserving and choice-preserving functors. So, this is the adjunction we care about now

F PrCat Gr.

U

Type Theory for Categories with Product Under G judgement forms: A type (objects) x : A M : B (morphisms) • ⊢ ⊢ rules: • A type B type A ObG ⊢ ⊢ A type ∈ 1 type A B type ⊢ ⊢ ⊢ × x : A M : B f : B C in G x : A x : A x : A ⊢f(M):B → ⊢ ⊢

11 as well as product rules

x : X M : A B x : X M : A B x : X M : Ax: X N : B ⊢ × ⊢ × ⊢ ⊢ x : X π (M):A x : X π (M):B x : X M,N : A B ⊢ 1 ⊢ 2 ⊢⟨ ⟩ ×

and one for the terminal type

X type ⊢ x : X : 1 ⊢∗ relations • π ( M,N ) M 1 ⟨ ⟩ ≡ π2( M,N ) N P ⟨π (P )⟩,π≡(P ) ≡⟨ 1 2 ⟩

4 Type Theory for Categories with Products

Here is an example of a derivation in our type theory corresponding to a category with products:

x : A x : A x : A x : A x : A ⊢f(x):A x : A ⊢g(x):C . ⊢ ⊢ x : A f(x),g(x) : B C ⊢⟨ ⟩ × x : A πBC f(x),g(x) : B. ⊢ 1 ⟨ ⟩ This tree contains the same information as this simplified tree

A A A A A ⊢ B A ⊢ C ⊢A B C⊢ ⊢ × A B. ⊢ This is because one can write down the entire tree given only the term BC π1 f(x),g(x) , because at each stage there is only one thing that could have⟨ happened⟩ prior. Things were set up this way. This is a kind of type-checking. So, in this set up there is a bijection between terms and derivations.

12 Rules for Equalities Between Morphisms

Binary product rules x : X M : Ax: X N : B x : X M : Ax: X N : B ⊢ ⊢ ⊢ ⊢ x : X πAB( M,N ) M : A x : X πAB( M,N ) N : B ⊢ 1 ⟨ ⟩ ≡ ⊢ 2 ⟨ ⟩ ≡ x : X P : A B ⊢ × x : X P πAB(P ),πAB(P ) : A B ⊢ ≡⟨ 1 2 ⟩ × nullary product rule x : X P : 1 x : X P⊢ : 1 ⊢ ≡∗ reflexivity, symmetry and transitivity

x : X M : A x : X M N : A x : X M⊢ M : A x : X ⊢ N ≡M : A ⊢ ≡ ⊢ ≡

x : X M N : Ax: X N P : A ⊢ ≡x : X M P : A⊢ ≡ ⊢ ≡ rules that respects the operations ≡ x : A M N : A x : X M N : A B ⊢ ≡ f : A B ⊢ ≡ × x : X f(M) f(N):B → x : X πAB(M) πAB(N):A ⊢ ≡ ⊢ 1 ≡ 1

x : X M N : A B x : X M M ′ : Ax: X N N ′ : B AB⊢ ≡ AB× ⊢ ≡ ⊢ ≡ x : X π (M) π (N):B x : X M,N M ′,N′ : A B ⊢ 2 ≡ 2 ⊢⟨ ⟩≡⟨ ⟩ × Definition 4.1. We define the category F G as follows:

– objects: derivable judgements A type ⊢ – morphisms: derivable judgements x : A M : B (some M)modulo the relations M N iff x : A M N ⊢: B ∼ ⊢ ≡ Proposition 4.2. F G is the free category with products generated by G .

Proof. (Sketch). First, we need to show that F G is a category. For compo- sition, given x : A M : B and x : B M : C we need some x : A P : C – it will be defined⊢ by inducting on the⊢ derivation tree of N: ⊢

i. x : B x : B.Then,P = M. ⊢

13 ii. N = f(N ′) for some f : C′ C in G . By induction, obtain x : A → ⊢ P : C′.Then,P = f(P ′).

iii. π1 – do the same as above.

iv. π2 – do the same as above.

v. N = N1,N2 for some x : B N1 : C1 and x : B N2 : C2.By induction,⟨ obtain⟩ x : A P : C⊢ , x : A P : C ,so⊢P = P ,P ⊢ 1 1 ⊢ 2 2 ⟨ 1 2⟩ vi. N = .Then,P = . ∗ ∗ Note: On terms, this substitutes. In fact, this defines substitution induc- tively

i. x[M/x]=M

ii. f(N ′)[M/x]=f(N ′[M/x])

iii. π1(N ′)[M/x]=π1(N ′[M/x])

iv. π2(N ′)[M/x]=π2(N ′[M/x]) v. N ,N = N [M/x],N [M/x] ⟨ 1 2⟩ ⟨ 1 2 ⟩ vi. [M/x]= ∗ ∗

There is presently no composition operation built into the type theory, we have admissibility x : A M : Bx: B N : C . ⊢x : A N[M/x]:C⊢ ⊢ This is not a primitive rule of the type theory it is a so-called admissible rule e.g. whenever we have derivations of its premises, we can construct a derivation of its conclusion. Our theorem is then admissibility of substi- tution a.k.a we can translate a derivation using substitution as a rule into one not using substitution as a rule a.k.a. cut elimination!

Back to our proof, associativity of composition is left to the reader. It remains now to check the universal property. Let M be a category with products and φ : G UM .Defineφ¯ : F G → → M by induction on derivations — φ¯(A B)=φ¯(A) φ¯(B), φ¯(f(M)) = × × φ(f) φ¯(M) (for f : A B in G ) and φ¯( M,N )= φ¯(M), φ¯(N) . ◦ → ⟨ ⟩ ⟨ ⟩ Moreover, the rules for are satisfied by literal equality in M . It can then be shown that φ¯ preserves≡ composition and chosen products – it is unique because its definition was forced at every stage.

14 Exercises.

4.1. Suppose we have

f G (A, B) g G (A, C) h G (B,D) k G (C, E) ∈ ∈ ∈ ∈ Consider the following two derivations of A D E in the unary type theory for categories with products. Note⊢ both× use the admissible cut/substitution rule.

A A B B A A C C f h g k A ⊢ B B ⊢ D A ⊢ C C ⊢ E cut cut ⊢ A D ⊢ ⊢ A E ⊢ ⊢ ⊢ I A D I × ⊢ × B C B C B C B C × ⊢ × E1 × ⊢ × E1 A A A A B C B × B C C × f g × ⊢ h × ⊢ k A ⊢ B A ⊢ C B C D B C E ⊢ ⊢ I × ⊢ × ⊢ I A B C × B C D E × ⊢ × × ⊢ × cut A D E ⊢ × Write down the terms corresponding to these two derivations and show directly that they are related by . ≡ 4.2. Let M be a fixed category; then we have an induced adjunction be- tween the slice categories Cat/M of categories over M and Gr/M of directed graphs over (the underlying graph of) M .Describea cut-free type theory for presenting the free category-over-M on a directed-graph-over-M , and prove the initiality theorem. Note that you will have to prove that cut is admissible first. (Hint: index the judgments by arrows in M , so that for instance A B represents ⊢α an arrow lying over a given arrow α in M .) 4.3. A functor P : A M is called a fibration if for any b A and → ∈ f : x P (b),there exists a morphism φ : a b in A such that P (φ)=→f and φ is cartesian, meaning that for→ any ψ : c b and g : P (c) x such that P (ψ)=fg,thereexistsauniqueχ→: c a such that→P (χ)=g and φχ = ψ. The object c is usually denoted→ f ∗(b). a. Write down a type theory for fibrations of categories over a fixed base category M ,withβ and η conversion rules, and prove its initiality theorem. − − ≡ b. Use this type theory to prove that in any fibration P : A M → i. For any f : x y in M , f ∗ is a functor from the fiber over y to the fiber→ over x. ii. For any B A and f : xy, g : y P (B)inM ,wehave ∈ → f(g(B)) ∼= (gf)∗(B).

15 5 Motivating Example (Monoid Objects)

“There are many advantages to simply ‘postulating’ what we want. They are the same as the advantages of theft over honest toil.” - Bertrand Russell

Our motivating example will be that of the uniqueness of inverses in a monoid.

Proposition 5.1. Let M be a monoid. Then, inverses in M (if they exist) are unique.

Proof. y = ye = y(xz)=(yx)z = ez = z.

This proof can be generalized to internal monoids.

Definition 5.2. A monoid object (or internal monoid) in a category C with products is an object M along with morphisms m : M M M and e :1 M such that the diagrams × → →

m 1 1 e × × M M M M M M M M e 1 M × × × × × 1M 1 m m m × 1M M M M m M M × × commute.

Example 5.3. A monoid object in Top is a topological monoid.

Definition 5.4. Let M be a monoid object in a category C . An inverse operator for M is a morphism i : A A such that the diagram →

1 i M M × M M × × ∆ m

M M ! e

1

16 commutes.

Now, the following diagram witnesses the fact that any two inverse oper- ations i, j for an monoid object M must be equal

π A A 1 A × 1 1 ∆ (1,e) × (i, 1) A A A A A × × × 1 1 j 1 m × × × m (i, 1,j) A A A A A × × i 1 1 m 1 m × × × (1,j) A A A A A × × × ∆ 1 (e, 1) × 1 π A A 2 A × Our goal is to be able to do this proof in the syntax of type theory instead of with a large commutative diagram as above.

Vision 5.5. Build the free category with products containing a monoid and two inverse operators such that for any another such category there is a unique functor into it preserving the inverse operations (and so they will be equal there as well). We will need to generalize Proposition 2.2., by using a more general thing than a directed graph for G , to allow morphisms in G to have arbitrary types as domain and codomain (as per m : A A A). × → This more general G will be called a unary finite product theory. We will be able to have something like

m : A A Ae:1 A × → → x : X M : A A x : X M : 1 ⊢ × ⊢ x : X m(M):A x : X e(M):A ⊢ ⊢ x : A m( e, ) x : Ax: A m( ,e ) x : A ⊢ ⟨ ∗⟩ ≡ ⊢ ⟨∗ ⟩ ≡

x : A A A m( π1(x),m( π1(π2(x)),π2(π2(x)) ) ) × m(×m(⊢π (x⟨),π (π (x))⟨ ),π (π (x)) ):A ⟩ ⟩ ≡ ⟨ ⟨ 1 1 2 ⟩ 2 2 ⟩

6 Multicategories

Recall last time we had a horrible looking rule

17 x : A A A m( π1(x),m( π1(π2(x)),π2(π2(x)) ) ) ×m(×m( ⊢π (x)⟨,π (π (x))⟨ ),π (π (x)) ):A. ⟩ ⟩ ≡ ⟨ ⟨ 1 1 2 ⟩ 2 2 ⟩ Our aim is to instead be able to write something like

x : A, y : A, z : A m(x, m(y, z)) m(m(x, y),z):A. ⊢ ≡ To this end, we will need to use multicategories instead of standard cate- gories.

Definition 6.1. A multicategory M has

i. a class of objects

ii. for objects A1,A2,...,An,B, a class M (A1,A2,...,An; B), n N ∈ 1 k1 1 kn iii. functions M (A1,...,An; B) M (A1,...,A1 ; B1) ... M (An,...,An ; Bn) 1 k1 1 k×n × × → M (A1,...,A1 ,...,An,...,An ; B) called composition.

iv. for each object A, an identity 1A : A A such that f (1A1 ,...,1An )= f =1 f → ◦ A ◦ 1 k1 1 kn v. associativity: f (f1 (f1 ,...,f1 ),...,fn (fn,...,fn )) = (f (f1,...,fn) 1 k1 ◦1 ◦ kn ◦ ◦ ◦ (f1 ,...,f1 ,...,fn,...,fn )).

Irrelevant Remark 6.2. There is a notion of comulticategory,where arrows have one object in the domain and multiple in the codomain. There is also the notion of polycategory where arrows have multiple objects in both the domain and codomain.

Example 6.3. Declare objects to be vector spaces and morphisms to be multilinear maps e.g. f : V1,V2,...,Vn V is a map f : V1 V2 ... Vn V (linear in each argument). → × × × →

Example 6.4. Let V be a monoidal category. Define a multicategory by declaring its objects to be objects of V and

V(A ,...,A ; B)=V(A ... A ,B). 1 n 1 ⊗ ⊗ n

Example 6.5. Let C be a category with finite products. C has cartesian monoidal structure and so we get

C (A ,...,A ; B)=C (A ... A ,B). 1 n 1 × × n

18 Type Theory for Multicategories

We need some sort of adjunction

F

MultiCat MultiGr.

U

Judgements will look like

x : A, x : A, .., x : A M : B 1 2 n ⊢ Example 6.6. Given f : A, B C, g : C, D E,wehave → → x : A, y : B,z : D g(f(x, y),z):E. ⊢ Remark 6.7. This type theory will be “linear” (each variable will appear exactly once in the term).

Rules x : A x : A ⊢

Γ1 M1 : A1 ... Γn Mn : An ⊢ ⊢ f G (A1,...,An; B) Γ ,...,Γ f(M ,...,M ):B ∈ 1 n ⊢ 1 n Some comments

1. Γs are contexts (x1 : C1,...,xn : Cn)

2. Γ1,...,Γn is concatenation 3. Γs all have distinct variables

Example 6.8.

x : A x : Ay: B y : B ⊢ ⊢ x : A, y : B f(x, y):Cz: D z : D ⊢ ⊢ x : A, y : B,z : D g(f(x, y),z):E ⊢ A word about variables: Now that we have allowed ourselves more than one variable we must say something about situations like

x : A f(x):B ⊢

19 y : A f(y):B. ⊢ We shall mod out by swapping variables, this is called α-equivalence.

Lemma 6.9. (Cut-Admissibility) If Γ1 M1 : A1...Γn Mn : An and x : A ,...,x : A N : B,then ⊢ ⊢ 1 n n ⊢

Γ ,...,Γ N[M /x ,...,M /x ]:B 1 n ⊢ 1 1 n n Proof. Induct on derivations.

Theorem 6.10. The types and terms of this type theory form the free multicategory generated by a multigraph G .

Proof. Induct on derivations.

Symmetric and Cartesian Multicategories

A multicategory is to a monoidal category as a symmetric multicategory and to symmetric monoidal category.

Definition 6.11. A symmetric multicategory is a mutlicategory M with for any bijection σ : 1,..,n 1,..,n , functions σ∗ : M (A ,...,A ; B) { }→{ } σ1 σn → M (A1,...,An; B) such that

a. σ∗τ ∗ =(στ)∗,1∗ = 1 and

b. g (f σ∗,...,f σ∗ )=(g (f ,...,f ))(σ ... σ )∗. ◦ 1 1 n n ◦ 1 n 1 ⊕ ⊕ n We want something like x : A, y : B f(x, y):C for f : A, B C in G . So we will need to a rule allowing ⊢ →

y : A y : Ax: B x : B ⊢ ⊢ y : A, x : B f(y, x):C ⊢ x : B,y : A f(y, x):C ⊢ or more generally

Γ M : B ⊢ exchange Γσ∗ M : B ⊢ But, terms are then no longer uniquely determined by derivations.

Definition 6.12. A cartesian multicategory is a multicategory M with for any bijection σ : 1,..,n 1,..,m functions σ∗ : M (A ,...,A ; B) { }→{ } σ1 σm → M (A1,...,An; B) such that

20 a. σ∗τ ∗ =(στ)∗,1∗ =1,

b. g (f σ∗,...,f σ∗ )=(g (f ,...,f ))(σ ... σ )∗ and ◦ 1 1 n n ◦ 1 n 1 ⊕ ⊕ n c. gσ∗ (f ,...,f )=g (f ,...,f ) ◦ 1 n ◦ σ1 σn

Example 6.13. σ : 1, 2 1 , M (A ,A ) M (A, B) gives a map { }→{ } σ1 σ2 → M (A, A; B) M (A; B) →

A A B 1 × 1 ∆

A1.

Example 6.14. σ : 1 , M (; B) M (A; B) given by ∅→{ } →

1 B

! A.

Exercise.

6.1. A functor between multicategories is, of course, a map on objects and a map on morphisms preserving domains, codomains, identities, and composition. If the multicategories are symmetric or cartesian, we also require the corresponding actions on the domains of mor- phisms to be preserved. Prove that any functor of cartesian multi- categories must preserve tensor products up to isomorphism. That is if A, B A B has the universal property of the tensor prod- uct, e.g. has→ a morphism⊗ χ : A, B A B such that all χ : → ⊗ −◦ M (B1,...,Bk,A B,C1,...,Cm; D) M (B1,...,Bk, A, B, C1,...,Cm; D) are bijections, then⊗ so does F A, F B→ FA FB. → ⊗

7 Type-Theoretic Proof of Uniqueness of In- verses

We need structural rules

Γ, A, B, ∆ C Γ, ∆ C Γ, A, A, ∆ C ⊢ exchange ⊢ weakening ⊢ contraction Γ, B, A, ∆ C Γ, A, ∆ C Γ, A, ∆ C ⊢ ⊢ ⊢

21 General Solution: Make all of these rules admissible instead of primi- tive (e.g. an operation on derivations).

In the Cartesian Case: Make all contexts the same in all rules.

Example 7.1. Consider f : A, B C in a multigraph G . We have → Γ M : A Γ M : B ⊢ 1 ⊢ 2 Γ f(M ,M ):C ⊢ 1 2 This builds in weakening and contraction. In general,

Γ M1 : A1...Γ Mn : An ⊢ ⊢ f : A1,...,An B in G Γ f(M ,...,M ):B → ⊢ 1 n x : A in Γ Γ x : A ⊢ Theorem 7.2. Exchange, weakness and contraction are all admissible.

Proof. Induction on derivations.

Corollary 7.3. Every derivable term represents a unique derivation.

Corollary 7.3. can be thought of as giving “the uniqueness of type- checking.”

Theorem 7.4. The free cartesian multicategory generated by a multi- graph G is described by this type theory e.g. morphisms A1,...,An B are given by derivable x : A ,...,x : A M : B. → 1 1 n n ⊢

Theorem 7.5. A finite product theory is a multigraph G together with a set of pairs of parallel morphisms in F G , along with appropriate axioms.

Those with background in model theory may wish to think of G here as the “signature.”

Example 7.6. (Monoids) One object A, arrows m : A, A A, e :() A. → →

Axioms:

1. x : A, y : A, z : A m(m(x, y),x) m(x, m(y, z)) : A ⊢ ≡ 2. x : A m(x, e) x : A ⊢ ≡

22 3. x : A m(e, x) x : A ⊢ ≡ For monoids with inverses, add an arrow i : A A and the axioms → 4. x : A m(i(x),e) e : A ⊢ ≡ 5. x : A m(e, i(x)) e : A ⊢ ≡ We extend with rules for (reflexivity, symmetry, transitivity, substitu- tion), plus axioms and this≡ presents the free cartesian multicategory such that the axioms holds.

Example 7.7. (Uniqueness of Inverses for Monoid Objects) Consider the type theory for monoids with two inverse operators i, j.Wehave

x : A i(x) m(i(x),e) ⊢ ≡ m(i(x),m(x, j(x))) ⊢ m(m(i(x),x),j(x)) ⊢ m(e, j(x)) ⊢ j(x). ⊢ So, x : A i(x) j(x):A and thus the two are equal in the free mul- ticategory⊢ on this≡ theory. Therefore, they are also equal in any image of it.

Exercises.

7.1. A “distributive near-ring” is like a ring but without the assumption that addition is commutative; thus we have a monoid structure ( , 1) and a group structure (+, 0) such that distributes over + on· both sides. · a. Prove that every distributive near-ring is actually a ring, i.e. that addition is commutative. b. Define a “distributive near-ring object” in a category with fi- nite products, and prove using diagrams that its addition is commutative. c. Write down a finite-product theory for distributive near-ring objects, and use it to prove the same result. (It will be easier if you use the non-unary version.) 7.2. Use the type theory for categories with products (unary or non- unary, your choice) to prove that in any category with products we have

A B = B AA(B C) = (A B) CA1 = A 1 A = A. × ∼ × × × ∼ × × × ∼ × ∼

23 That is, in each case use type theory to define morphisms forwards and back- wards and show that their composites are equal to iden- tities.

7.3. Let E be a category with finite products, and A an object of E equipped with two monoid structures (m, e) and (m, e), such that the following diagram commutes, where σ : A A A A is the symmetry isomorphism. × → ×

m m A A A A × A A × × × × 1 σ 1 × ×

A A A A m′ × × ×

m′ m′ × A A m A ×

a. Show that e = e′. b. Show that in fact m = m, and moreover this operation is com- mutative.

Hint: for the second part, it may be helpful to contemplate the following diagrams, where the two monoid operations are “hor- izontal concatenation” and “vertical concatenation” of regions :

8 Heyting Algebras

Logic, for us, will be the type theory corresponding to posets. Let us think about the type theory of cartesian closed posets (a.k.a. Heyting algebras). Posets do not care about terms as terms distinguish between different derivations (different parallel morphisms).

Rules We have

24 A Γ Γ A1 ... Γ An ⊢ ⊢ A1,...,An B in G Γ A ∈ Γ B ≤ ⊢ ⊢ plus product rules

Γ A B Γ A B Γ A Γ B ⊢Γ A∧ ⊢Γ B∧ ⊢Γ A B⊢ Γ ⊢ ⊢ ⊢ ∧ ⊢⊤ as well as exponential and coproduct rules

Γ,A B Γ A B Γ A Γ ⊢ ⊢ → ⊢ ⊢ ⊥ Γ A B Γ B Γ C ⊢ → ⊢ ⊢ Γ A Γ B Γ,A C Γ,B C Γ A B ⊢ ⊢ ⊢ ⊢ ⊢ ∨ . Γ A B Γ A B Γ A B ⊢ ∨ ⊢ ∨ ⊢ ∨

What does this have to do with logic? Well, observe that F T := 2 is a Heyting algebra: { ≤ }

– = and ∧ – = or ∨ – =F ⊥ – =T ⊤ – = → ⇒ Theorem 8.1. This type theory presents the free Heyting algebra on a multigraph.

Proof. Exercise.

Note, obG = propositional variables and G (A1,...,An; B) = axioms. So, a map G 2 takes propositional variables to truth values and the ax- ioms “become→ true.” Using the adjunction schema one then obtains a map FHeytG 2 and here types/propositional formulas are sent to truth values and derivable→ judgements “become true.” In this respect, where maps out of G are thought of as models, Theorem 8.1. is a soundness theorem. We do not have completeness in this exam- ple because there are things true about 2 that are not true about every Heyting algebra, considering maps into the free Heyting algebra will give us our “completenesss theorem.” We return to completeness in Section 19. Note also that negation was not explicitly included. This is because negation will be defined as

A := (A ). ¬ →⊥

25 To see why this is a reasonable definition of negation look at the following derivations

Γ,A Γ A Γ A ⊢ ⊥ ⊢¬ ⊢ . Γ A Γ ⊢¬ ⊢⊥ It should be said however that we do not get

Γ, A ¬ ⊢ ⊥ . Γ A ⊢ In “baby logic” this along with the first rule for negation are both called “proof by contradiction.” However, the logic of a Heyting algebra does not correspond, in general, to classical logic but intuitionistic or constructive logic. Intuitionistically, the latter is not true in general. The former is just how one proves a negation. Presently, we will not be concerned with arguments between mathematicians from the early 20th century. This is not because they are not interesting, but because right what we care about is just that not all Heyting algebras are Boolean. Now, although A A is no longer a derivable, but A A still is ¬¬ → →¬¬

A, A A A, A A ¬ ⊢ ¬ ⊢¬ A, A ¬ ⊢ ⊥ A A () A⊢¬¬ A. ⊢ →¬¬ Constructive logic does not assert that A A is false. In fact, ( A A) is a theorem in constructive¬¬ logic.→ What is does is re- mains¬¬ ¬¬ silent→ on this matter and not allow us to assert it in general.

Bottom Line 8.2. It is harder to be true than to be not false.

Exercises.

8.1. In classical logic, the “law of contraposition” states that any impli- cation P Q is equivalent to its contrapositive Q P . Con- structively,→ one direction is provable, but the other¬ may→ fail.¬ a. Give a derivation of P Q Q P in the type theory for Heyting algebras (for arbitrary→ ⊢¬P,→ Q).¬ b. Find a Heyting algebra containing elements P,Q for which P Q =( Q P ). → ̸ ¬ →¬

26 9 First-Order Logic

Let us pick up where we left offlast time by giving some examples of Heyting algebras.

Example 9.1. (Boolean Algebras) Let B be a lattice such that x B, x¯ B such that x x¯ = and x x¯ = . Define the right adjoint∀ ∈ to ∃product∈ by ∧ ⊥ ∨ ⊤ (x y):=¯x y. → ∨ For example, for a set A,itspowersetP(A) is a Boolean algebra.

Before giving our first non-Boolean example, we will need a little lemma.

Lemma 9.2. (Freyd’s Adjoint Functor Theorem for Posets) If A, B are complete lattices and if f : A B preserves all joins, then it has a right adjoint g : B A. → → Proof. (Idea). Define g(y)= x A f(x) y . ∨{ ∈ | ≤ } Example 9.3. Let X be a set, A, B X. Note i ⊂ A B = x X x A and i, x B ∩∪i i { ∈ | ∈ ∃ ∈ i} and (A B )= x X i I such that x A B . ∪i ∩ i { ∈ |∃ ∈ ∈ ∩ i} Thus, P(X) is a cartesian closed poset. Moreover, any sub-poset of P(X) closed under finite and arbitrary is also a Heyting algebra. In other words, any topology∩ on X, is a Heyting∪ algebra.

Now, onto first-order logic (FOL).

FOL = propositional logic + quantifiers + equality (+ atomic predicates).

Here we will be starting with the type theory/logic and then defining the appropriate categories. The idea is we’ll have:

Judgements

1. A type ⊢ 2. Γ M : A (Γ= list of types with variables) ⊢ 3. Γ φ prop ⊢

27 4. Γ θ φ (θ = list of propositions in context Γ). | ⊢ Some Rules

A type Γ M : A Γ φ prop ⊢ ⊢ ⊢ Γ M : A ... Γ M : A Γ M : A ... Γ M : A ⊢ 1 1 ⊢ n n ⊢ 1 1 ⊢ n n Γ f(M ,...,M ):B Γ P (M ,...,M ) prop ⊢ 1 n ⊢ 1 n Γ φ prop Γ ψ prop Γ φ prop Γ ψ prop ⊢ ⊢ ⊢ ⊢ Γ φ ψ prop Γ φ ψ prop ⊢ ∧ ⊢ ∨ Γ φ prop Γ ψ prop ⊢ ⊢ Γ φ ψ prop Γ prop Γ prop ⊢ → ⊢⊤ ⊢⊥ Γ,x: A φ prop Γ,x: A φ prop ⊢ ⊢ Γ ( x : Aφ) prop Γ ( x : Aφ) prop ⊢ ∃ ⊢ ∀ Γ M : A Γ N : A ⊢Γ (M = N)⊢ prop ⊢ A

Remark 9.3. Each atomic proposition P has a context A1,...,An as- signed.

Exercises.

9.1. Work in (intuitionistic) first-order logic over a multigraph G ; suppose φ is a formula in context Γ,x : A. Show that Γ ( x : A,φ) ( x : A, φ). ⊢ ¬∃ ⇐⇒ ∀ ¬ 9.2. Yet another classical tautology that is intuitionistically only partly provable. a. Find a Heyting algebra containing an element P for which P P is not the top element. ∨ ¬ b. Prove that (P P ) is an intuitionistic tautology, i.e. derive () (P ¬¬P )∨ in¬ the type theory for Heyting algebras. ⊢¬¬ ∨¬ 9.3. Of the four “de Morgan’s laws”, three are intuitionistically provable and one is not. In class we proved this one: P Q (P Q) ¬ ∨¬ ⊢¬ ∧ and remarked that its converse is not provable. a. Prove the other two of de Morgan’s laws intuitionistically (i.e. give derivations of them in the type theory for Heyting algebras) (P Q) P Q ¬ ∨ ⊢¬ ∧¬ P Q (P Q). ¬ ∨¬ ⊢¬ ∨

28 b. Find an example of a Heyting algebra in which the fourth de Morgan’s law (P Q) P Q fails. ¬ ∨ ⊢¬ ∨¬ c. Prove that the open-set lattice of a topological space (regarded as a Heyting algebra) satisfies the fourth de Morgan’s law if and only if the space is extremally disconnected (the closure of every open set is open).

10 First-Order Theories

Definition 10.1. A first-order theory consists of

1. a set of objects 2. a set of morphisms each with a domain being a list of objects and a codomain being an object 3. a set of atomic propositions each with an arity being a list of objects 4. a set of axioms each with a. a context = list of objects b. an antecedent = list of propositions in that context c. a consequent = single proposition in that context 5. rules for entailment Γ Θ φ Γ Θ,φ ψ | ⊢ | ⊢ cut Γ Θ ψ | ⊢ Γ M : A Γ,x: A Θ φ ⊢ | ⊢ substitution Γ Θ[M/x] φ[M/x] | ⊢ 6. generator/axioms rules: every axiom is an entailment 7. rules for logic a. propositional logic: the same rules for , , , , as with the type theory for Heyting algebras with∧ an∨ arbitrary⊥ ⊤ → context Γ b. universal quantifier Γ,x: A Θ φ | ⊢ x variable in φ not in Γ Γ Θ x : A.φ | ⊢∀ Γ Θ x : A.φ | ⊢∀ x not in Γ Γ,x: A Θ φ | ⊢ c. existential quantifier

29 Γ M : A Γ Θ φ[M/x] ⊢ | ⊢ Γ Θ x : A.φ | ⊢∃ Γ,x: A Θ,φ ψ | ⊢ x not in Γ, Θor ψ Γ Θ, x : A.φ ψ | ∃ ⊢ c. equality Γ,x: A Θ[x/y] φ[x/y] | ⊢ Γ,x: A Θ x =A x Γ,x: A, y : A Θ,x= y φ | ⊢ | A ⊢ Remark 10.2. Because the intended semantics is for in a poset, we no longer care about having multiple derivations for the≤ same entailment – hence why cut is stated as primitive

Example 10.3. (Symmetry of Equality)

x : A () (x = x) | ⊢ A x : A, y : A (x = y) (y = x) | A ⊢ A Example 10.4. (Transitivity of Equality)

x : A, z : A (x = z) (x = z) | ⊢ x : A, y : A, z : A (x = y), (y = z) (x = z) | ⊢ Exercises.

10.1. Write out a careful proof that the type theory for Heyting algebras presents the free Heyting algebra on a relational multigraph.

11 Quantifiers as Adjoints

Idea: Let S be a cartesian multicategory and C be any category. A C -valued presheaf on S is

a. for A ,...,A in ob(S ), a P(A ,...,A ) C , 1 n 1 n ∈ b. for f (A ,...,A ) B in S , P(B ,...,B ) P(A ,...,A ), i 1 n → 1 n → 1 n c. σ∗ actions on P’s and d. some axioms

30 Example 11.1. S ( ; B), for any B ob(S ), is a Set-valued presheaf − ∈ on S .

This chart should give an idea for where it is we are going:

A type object of S ⊢ Γ M : A morphism of S ⊢ Γ φ prop object of P ⊢ Γ θ φ prop morphism of P | ⊢ Theorem 11.2. Let S be a cartesian multicategory. Define F S by

– objects are finite lists of objects of S

m – F S ((A1,...,Am), (B1,...,Bm)) = Πi=1S (A1,...,An; B).

Then, F S is the free category with products on S .

Example 11.3. Let S be the free cartesian multicategory on a finite product theory. Then, F S is called the category of contexts of that the- ory.

Observation 11.4. A C -valued presheaf on S is an arbitrary functor F S op C . →

Definition 11.5. Let S be a category with finite products. An S - indexed poset is a functor P : S op Poset. →

The idea is that objects of S correspond to contexts, morphisms of S correspond to terms, objects of P(Γ) correspond to propositions and mor- phisms of P(Γ) correspond to entailments and the functorial action of P corresponds to substitution.

Example 11.6. Let S = Set and P(Γ) = powerset of Γ. So, for exam- ple, Γ φ prop corresponds to x Γ φ(x) . ⊢ { ∈ | }

Example 11.7. Let S be a category with finite limits and P(Γ) be the poset of subobjects of Γ.

Example 11.8. Let H be any Heyting algebra, S = Set and P(Γ) = HΓ.

31 We say that an indexed poset P : S op Poset has meets/joins/expo- → nentials if each P(Γ) does and they are preserved by all the f ∗ (where by f ∗ we mean P(f)). Example 11.6. always has this structure, example 11.7. sometimes does and example 11.8. does if H does.

Slogan 11.9. (Lawvere) Quantifiers are adjoints!

Definition 11.10. Suppose P : S op Cat is a functor (actually even → a pseudo-functor will do here). Now, consider a commutative square in S

f A B

h k g C D

and suppose that f ∗ and g∗ have left adjoints f! , g!. The above square is said to satisfy the Beck-Chevalley condition if the map

f!h∗ f!h∗g∗g! ∼= f!f ∗g!k∗ k∗g! is an isomorphism. Similarly, if h∗, k∗ have right adjoints h , k ,we have ∗ ∗ an arrow g∗k h f ∗. This arrow is an isomorphism if and only if ∗ → ∗ f h∗ k∗g is. ! → !

We will often be concerned in particular with pullback squares satisfying the Beck-Chevalley condition.

Definition 11.11. We say a functor P : S op Poset has s if → ∀

1. for any Γ,A S , the functor π∗ : P(Γ) P(Γ A) has a right adjoint π . ∈ → × ∗ 2. these adjoints satisfy the Beck-Chevalley condition with respect to

f 1 Γ A × ∆ A × × π π f Γ ∆

for any f :Γ ∆. → The idea is something like

32 Type Theory Category Theory Γ,x: A Θ φ π∗Θ φ | ⊢ ≤ Γ Θ x : A.φ Θ π φ Γ|Θ ⊢∀x : A.φ Θ ≤ π∗φ | ⊢∀ ≤ ∗ Γ,x: A Θ φ π∗Θ φ | ⊢ ≤ For the existential quantifier the rule what we had was

Γ,x: A Θ,φ ψ | ⊢ x not in Γ, Θ,ψ Γ Θ, x : A,φ ψ | ∃ ⊢ However, forgetting about Θgives

Γ,x: A φ ψ | ⊢ x not in Γ,ψ Γ x : A,φ ψ |∃ ⊢ which corresponds to

φ π∗ψ ≤ π φ ψ ! ≤ whereas remembering Θcorresponds to

π∗Θ φ π∗ψ ∧ ≤ . π φ ψ ! ≤ So, we need to impose an extra condition.

Definition 11.12. Let C , D be monoidal categories and F : C D be a colax monoidal functor which admits a strong monoidal right→ adjoint G (e.g. GA GB ∼= G(A B)). Then, we say that F G is a Hopf adjunction if⊗ the map ⊗ ⊣

F (GA B) F (GA GF B) = FG(A B) A FB ⊗ ⊗ ∼ ⊗ ⊗ is an isomorphism, and similarly on the other side. If C and D are also cartesian monoidal, this is sometimes called Frobenius reciprocity.

Definition 11.13. A functor P : S op Meet-Semilattice is said to have s if → ∃

1. each π∗ : P(Γ) P(Γ A) has a left adjoint π → × ! 2. these adjunctions are Hopf (for as ) ∧ ⊗

33 3. the Beck-Chevalley condition is satisfied with respect to

Γ A ∆ A × ×

Γ A

Recall the other rule for was ∃ Γ M : A Γ Θ φ[M/x] ⊢ | ⊢ Γ Θ x : A.φ | ⊢∃ This rule is in fact interderivable with

Γ Θ, x : A.φ ψ | ∃ ⊢ Γ,x: A Θ,φ ψ | ⊢ 12 First-Order Hyperdoctrines

An example of a Hopf adjunction:

Example 12.1. Let M be a multicategory with coproducts, i.e. M (C1,...,CN ,A+ B,D ,...,D ; E) M (C ,...,C , A, D ,...,D ; E) M (C ,...,C ,B,D ,...,D ; E), 1 m ≃ 1 N 1 m × 1 N 1 m then ∆: M M M has a Hopf left adjoint. → ×

Definition 12.2. P : S op Poset has equality if →

1. each ∆∗ : P(Γ A A) P(Γ A) has a left adjoint at × × → × ⊤ 2. the Hopf adjunction condition is satisfied 3. the Beck-Chevalley condition is satisfied for

Γ A ∆ A × ×

Γ A A ∆ A A × × × ×

Theorem 12.3. If P has and equality then it actually has nice left ∃ adjoints to all functors f ∗.

Proof. Exercise.

Definition 12.4. A first-order hyperdoctrine is

34 1. a category S with finite products 2. an indexed poset P : S op Poset → 3. P has , , , , preserved by f ∗ ∧ ⊤ ∨ ⊥ → 4. P has , and equality ∀ ∃ Proposition 12.5. The free first-order hyperdoctrine on a first-order theory is constructed by the type theory

– obj S = contexts of types – mor S = lists of terms – ob P(Γ) = propositions Γ φ prop ⊢ – mor P(Γ) = derivable entailments propositions Γ θ φ prop | ⊢ This category is called the category of contexts.

Example 12.6. Let S = Set, P(Γ) = powerset of Γ. For f :Γ ∆a → , f ∗ : P(∆) P(Γ) is the inverse image: →

f (φ) = image of φ = y ∆ x φ, f(x)=y ! { ∈ |∃ ∈ } f (φ) = dual image of φ = y ∆ x Γ,f(x)=y x φ ∗ { ∈ |∀ ∈ → ∈ } We have adjunctions f! f ∗ f ⊣ ⊣ ∗ Example 12.7. Let H be a complete Heyting algebra. Take S = Set and P(Γ) = HΓ. This gives a first-order hyperdoctrine.

Example 12.8. Let S be a category with finite limits and P(Γ) be the poset of subobjects of Γ.

– P always have , , equality ∧ ⊤ – S is regular if P has ∃ – S is coherent if P has , , ∃ ∀ ⊥ – S is Heyting if P has , , , , i.e. is a first-order hyperdoctrine ∃ ∨ ⊥ → ∀ The freeness theorem is modular. This means regular logic ( , , ) can ∧ ⊤ ∃ be interpreted in this P for any regular category.

Definition 12.9. A strong epi is a morphism e : A B such that given →

35 A C

e m B D with m a monomorphism, there is unique filler for the above diagram.

Exercise. Prove that for categories with finite limits, strong epis are epi- morphisms.

Definition 12.10. S is regular if

1. it has finite limits

2. every morphism factors as a strong epi followed by a mono 3. strong epis are preserved by pullbacks

If S is regular, its subobject poset has and the preservation of pullbacks gives the Beck-Chevallay and Hopf adjunction∃ conditions.

Definition 12.11. S is coherent if

1. it is regular

2. Sub(Γ), for each Γ, has finite joints preserved by pullback

Definition 12.12. S is Heyting if

1. it is coherent

2. each f ∗ :Sub(∆) Sub(Γ) has a right adjoint → The question then arises: Are they any such categories?

Proposition 12.13. If S has finite limits and finite colimits and is lo- cally cartesian closed (e.g. each slice S /Γis cartesian closed), then S is Heyting.

Corollary 12.14. Any topos is Heyting.

Theorem 12.15. In a regular category, strong epis are coequalizers.

Proof. (Idea). Let f be a strong epi. Consider the pullback

36 p K B

q f f A B.

f is the coequalizer of its kernel pair p,q : K A. →

Exercises.

12.1. Suppose P : S op Heyt is a first-order hyperdoctrine, with adjoints to reindexing→ only given along projections and diagonals. Prove (using type theory or commutative diagrams, your choice) that in fact the reindexing functor f ∗ : P(∆) P(Γ) has a left → adjoint for all morphisms f :Γ ∆inS . (Hint: in the hyper- doctrine of subsets over Set, these→ left adjoints can be defined by f (φ)=y ∆ x Γ.(x φ f(x)=y)). ! ∈ |∃ ∈ ∈ ∧ 12.2. Recall: a coherent category is a regular category whose subobject posets have finite joins, which are stable under pullback.

a. Prove that an object A of a coherent category E is initial if and only if its greatest subobject 1A : A A is also its small- est subobject (and hence it has only one→ isomorphism class of subobjects). b. Use this to conclude that any morphism in a coherent category whose codomain is initial is an isomorphism.

(You may use coherent logic, i.e. logic with , , , , and .) ∧ ⊤ ∨ ⊥ ∃

13 Bi-Initiality

Recall we had a unary type theory for categories with products and a monoid in them “TMon” and a theorem that TMon is the initial category with products and a monoid object. To be more precise, it was the initial object in the category with

– objects as category with chosen products and a monoid objects – morphisms as functors strictly preserving the chosen products and terminal object

37 This category will be written FPCatMonstr.

A “simplicial set” is a combinatorial model of spaces. Along with these comes a functor sSet Top called the “geometric realization” and it preserves products. Given→ a simplicial monoid A,wehave

F A | | F TMon Top

strict weak sSet

Issue. Need to be able to reason about

1. weak functors (i.e. preserving products and terminal object up to isomorphism) out of F TMon 2. natural transformations between them

Definition 13.1. A 2-category K consists of

– a class K0 of objects or 0-cells – for objects x, y K ,asetK (x, y) of arrows x y or 1-cells ∈ 0 1 → – for any x, y K , f,g K (x, y)asetK (x, y; f,g) of 2-cells with ∈ 0 ∈ 1 2 a. for each x, y a category structure on K (x, y) and K (x, y; , ) 1 2 − − b. for x, y, z K0 a functor K(x, y) K(y, z) K(x, z) and an objects 1 ∈ K(x, x) satisfying associativity× → x ∈ K(x, y) K(y, z) K(z,w) K(x, y) K(y, z) × × ×

K(x, z) K(z,w) K(x, w) ×

and also the evident unit laws with respect to 1x.

Remark 13.2. For those who know enriched category theory – this is just a category enriched over Cat.

Example 13.3. Declare objects to be (small) categories, 1-cells to be functors and 2-cells to be natural transformations.

Example 13.4. Declare objects to be categories with finite products, 1-cells to be functors preserving products up to isomorphism and 2-cells

38 to be natural transformations.

There is a weak version of a 2-category.

Definition 13.5. A bi-category B is the following data:

– a collection B0 of objects or 0-cells

– for each A, B B0 and category B(A, B) whose objects are called 1-cells and whose∈ elements are called 2-cells – for each A, B, C B , functors ∈ 0 c : B(B,C) B(A, B) B(A, C) A,B,C × → and I :1 B(A, A). A → – for each A, B, C, D B , natural isomorphisms ∈ 0 a : c c 1 c 1 c , A,B,C,D A,B,D ◦ B,C,D × → A,C,D ◦ × A,B,C r : c 1 I ρ , A,B A,A,B ◦ × A → A,B

where ρA,B denotes the canonical isomorphism B(A, B) 1 B(A, B), and × → l : c I 1 λ , A,B A,B,B ◦ B × → A,B where λ denotes the canonical isomorphism 1 B(A, B) A,B × → B(A, B). – coherence conditions

a 1 ((kh)g)f ∗ (k(hg))f

a a (kh)(gf) k((hg)f) a 1 a ∗ k(h(gf))

(gI)f a g(If) r 1 ∗ 1 l ∗ gf

39 Definition 13.6. An object x K is 2-initial if for each y K ∈ ∈ K(x, y) ∼= 1.

There is a slightly weaker notion of bi-initiality requiring only

K(x, y) 1. ≃ Any 2-category K has an underlying 1-category UK

– ob(UK) = ob(K) – UK(x, y) = ob(K(x, y))

Proposition 13.7. An object x is 2-initial in K if and only if x is bi-initial in K and x is initial in UK.

Proof. This boils down to: for a category C , C 1 if and only if ob(C ) ∼= 1. ≃

Theorem 13.8. fTMon is bi-initial in FPCatMon2, which is the 2- category of finite product categories with a monoid object, functors pre- serving products up to isomorphism and monoids strictly and natural transformations.

Lemma 13.9. A category C is equivalent to 1 if and only if it has some object c C such that for any two objects c, c′ C , C (c, c′) 1. 0 ∈ ∈ ≃ Proof. Exercise.

Proof. (Of Theorem 13.8.) Want to show K(fTMon, E ) 1, for each E . ≃ Certainly, for each E FPCatMon2 we can get some F in K(fTMon, E) by choosing binary products∈ and taking the unique induced strict map

fTMon E . →

So, we need for any E FPCatMon2, with monoid (A,m,e) and functors ∈

F ′

fTMon E , F a unique natural transformation between them.

This is done by induction over syntax:

40 a. for each type X type, we need to get by induction an isomorphism ⊢ F (X) F ′(X). For → 1type , ⊢

F (1) F ′(1) because F, F ′ preserve 1 weakly. For ≃ X type Y type ⊢ ⊢ , X Y type ⊢ × we have

αX F (X) F ′(X)

F (π1)

F ′(π1)

αX αY F (X Y ) × F ′(X Y ) × × Fπ2

F ′(π2)

αY F (Y ) F ′(Y )

Write αX Y := αX αY for the unique map such that × ×

(F ′π ) (α α )=α Fπ . 1 ◦ X × Y X ◦ 1 b. for each term x : X M : Y , we must show naturality ⊢

F (X) F ′(X)

F (M) F ′(M)

F (Y ) F ′(Y )

There are no nasty surprises showing naturality and so it is left as an exercise.

Exercises.

13.1. A pointed category (C ,c ) is a category C together with a cho- ∗ 0 sen object c C 0 ∈ A (weakly) pointed functor (F,φ):(C ,c ) (D,d )isafunc- ∗ 0 → 0 tor F : C D together with an isomorphism φ : Fc = d → 0 ∼ 0

41 For weakly pointed functors (F,φ), (F ′,φ′):(C ,c ) (D,d ) ∗ 0 → 0 a pointed transformation α :(F,φ) (F ′,φ′) is a natural → transformation α : F F ′ such that φ′ α 0=φ. → ◦ c a. Show that small pointed categories, pointed functors, and pointed transformations form a 2-category Cat . ∗ b. Show that Cat has a bi-initial object. ∗ c. Show that Cat does not have a 2-initial object. ∗ 13.2. Let C and D be 2-categories; we start with some definitions. A pseudofunctor F : C D consists of ∗ → A function F : ob(C ) ob(D). · 0 → For each A, B C , a functor F : C (A, B) D(F A, F B). · ∈ → 0 0 For each A C , an isomorphism F (1 ) = 1 . · ∈ A ∼ F0A For each A, B, C C and f C (A, B) and g C (B,C), · ∈ ∈ ∈ an isomorphism F (g f) ∼= F (g) F (f), natural in f and g. ◦ ◦ For each f C (A, B), the following diagrams commute: · ∈ F (1 f) F (f) B ◦ ∼= F (1 ) F (f) ∼= 1 F (f) B ◦ FB ◦ F (f) F (f 1 ) ◦ A ∼=

F (f) 1FA F (f) F (1A) ◦ ∼= ◦ For each f C (A, B) and g C (B,C) and h C (C, D), · the following∈ diagram commutes:∈ ∈ F (h g f) ∼= F (h) F (g f)) ◦ ◦ ◦ ◦ ∼= ∼= F (h g) F (f) ∼= F (h) F (g) F (f) ◦ ◦ ◦ ◦ If F, G : C D are pseudofunctors, an icon α : F G can ∗ → ⇒ exist only when F0 = G0, and in that case it consists of For each A, B C , a natural transformation α from F : · ∈ C (A, B) C (F0A, F0B)toG : C (A, B) C (G0A, G0B) (which have→ the same codomain, by assumption).→ For each A C , the following diagram commutes: · ∈

42 α1A F (1A) G(1A)

∼= ∼=

1F0A =1G0 A For each f C (A, B) and g C (B,C), the following · diagram commutes:∈ ∈

αg f F (g f) ◦ G(g f) ◦ ◦ ∼= ∼=

F (g) F (f) α α G(g) G(f) ◦ g ◦ f ◦ Let G be a directed graph, and F G the free category on it. Note that any 2-category C has an underlying directed graph UC consisting of its objects and arrows (discarding the 2-cells). On the other hand, any category (such as F G ) can be regarded as a 2-category with only identity 2-cells. a. Prove that for any 2-category C and any map of directed graphs D : G UC , there exists a pseudofunctor H : F G C such → → that H(f)=D(f) for all arrows f in G . b. Prove that given D : G UC and two pseudofunctors H, K : → F G UC that acts as D on objects and arrows in G ,there exists→ a unique icon α : H K such that α =1 for all ⇒ f D(f) arrows f in G . Moreover, show that each component of α is invertible. (Hint: induct over the construction of F G using unary type theory.)

14 More on Bi-Initiality

Aside 14.1. Let C , D be categories with finite products. Then, F : C → D preserves products weakly up to isomorphism if either

a. for any product diagram

X1 X X2

in C ,

F (X1) F (X) F (X2)

is a product diagram in D. Actually, this makes sense even if D does not have all products. It can be required just for the products that exist.

43 b. given chosen products, the canonical comparison map

Fπ ,Fπ : F (X X ) F (X ) F (X ) ⟨ 1 2⟩ 1 × 2 → 1 × 2 is an isomorphism and similarly the comparison map F (1) 1is an isomorphism →

Exercise. Prove a. b. ⇐⇒

We give a second proof of our result from yesterday

Proof. Define I(F, F ′) as the category with

– objects: one object X0 fTMon along with an isomorphism α : ∈ FX F ′X → – morphisms: maps f : X Y such that F ′ α = β → ◦

We claim that I(F, F ′) is a finite product category with a monoid. For the terminal object, we use 1 from fTMon

F (1) F ′(1). →

For the product of α : F (X ) F ′(X ),α : F (X ) F ′(X ), we use 1 1 → 1 2 2 → 2 X1 X2 in fTMon ×

α1 F (X1) F ′(X1)

Fπ1

F ′π1

α1 α2 F (X F ) × F ′(X X ) 1 × 2 1 × 2 Fπ2

F ′π2

α2 F (X2) F ′(X2)

α α is an isomorphism because F, F ′ both preserve products. The 1 × 2 monoid is given by F (A)=A A = F ′(A). → Now, there is a functor

u I(F, F ′) fTMon, that forgets the isomorphism, and this is a strict map (e.g. strictly pre- serving products) and we also have α : F (U) F (U) given by: for → (x, α) I(F, F ′), FU(x, α)=FX F ′X = F ′U(X,α). ∈ →

44 Since syntax is (1-categorically) initial in the category with strict maps, there is a strict map fTMon I(F, F ′) →

and by the uniqueness of initiality 1f Mon = U J : fTMon fTMon. So, T ◦ → α : F F ′ is an isomorphism. J →

Side Note: I(F, F ′) is a certain 2-categorical limit called an iso-inserter.

Now, it remains to show uniqueness. So given α,β : F F ′, we want α = β. This can be done easily by induction on syntax. ⇒

The typical picture is as follows:

– syntax is (1-categorically) initial in some category that is “a bit too strict” – syntax is bi-initial in the 2-category where our natural examples really live

Now, write f(G , T) for the initial cartesian multicategory with a model of T. A map F G M has FM¯ = FN¯ for each axiom M N of T. → ≡ So, we have (1-)categories CartMult and G /CartMult. More naturally, we might look for models on categories with finite products; these are naturally seen in the 2-category FPCat2 (with weak maps).

To compare CartMult and FPCat2, one may look at CartMult as a locally discrete 2-category. This gives

U CartMult FPCat2

that sends each E FPCat to the multicategory whose objects are the ∈ objects of E and with morphisms given by UE(A1,...,An; B)=E(A1 ... A ,B). × × n Finally, since U ought to be a 2-functor, we define for F : C D, → UF : UC UD on objects by UF(A)=FA and on morphisms by UF(f)=Ff→ φ,whereφ is the canonical isomorphism between products. ◦

Exercises.

14.1. Let G be a graph; we saw that FPrCatG , presented by the unary type theory for categories with products, is initial among finite-product preserving functors. Prove that any functor FPrCatG M that weakly preserves products is isomorphic to a strict one.→ Do this without using induction on derivations, but rather using the univer- sal property of FPrCatG .

45 Hint: go via a category whose objects are triples (X,Y,α), where X is an objects of F G , Y an object of M and α : FX Y is an PrCat → isomorphism in M (the “iso-comma” category F M ). |≃

15 The Classifying Category of an Algebraic Theory

Last time we used the locally discrete 2-category of a cartesian multicat- egory. This time we shall replace this with the 2-category of cartesian multicategories, (multi-)functors and (multi-)natural transformations.

Remark 15.1. We could call them “functors” instead of “multifunctor” because there is no other notion of functor between multicategories.

Definition 15.2. Let M be a multicategory. An isomorphism x y in → M is a map f : x y with an inverse g : y x such that f g = 1 and g f = 1. → → ◦ ◦

Definition 15.3. Let M , N be multicategories and F, G : M N be → functors. A natural transformation α : F G is, for each x M , an ⇒ ∈ arrow αx : Fx Gx in D such that for each f C (x1,...,xn; y)the arrow Gx ,...,Gx→ Gy equals the arrow α Fx ,...,∈ α Fx Gy.A 1 n → x1 1 xn 2 → natural isomorphism is one where each αx is an isomorphism.

Proposition 15.4. Multcategories and cartesian multicategories form 2-categories Mult2 and CartMult2 with objects as (cartesian) multicat- egories, 1-cells as functors and 2-cells as natural isomorphisms.

Definition 15.5. We have a 2-functor U : FPCat CartMult 2 → 2 (where CartMult2 denotes the 2-category of finite product categories, weak maps and natural isomorphisms) given on objects as we defined in Section 14, on 1-cells also as defined in Section 14 and on natural isomor- phisms α : F G,by(Uα) = α . ⇒ x x

Definition 15.6. Given 2-categories L, K and 2-functors F, G : L K a pseudonatural transformation φ : F G assigns to each object X →L → ∈ 0 a morphism φX : FX GX of K and to each morphism f : X Y of L an invertible 2-cell φ→(f):φ(X) F (f) G(f) φ(Y ) of K respecting→ composition, unit and naturality laws.◦ → ◦

Definition 15.7. A biadjunction between 2-categories K and L is a pair of 2-functors F : L K, G : K L such that for each object X K → → ∈

46 and each object Y L an equivalence of categories ∈ K(FX,Y) L(X, GY ) ≃ which is pseudonatural in both X and Y .

Maps f(G , T) UG give “models of a theory in a finite product category → C ” e.g. maps F (f(G , T)) C . In fact we will have a biadjunction →

CartMult2(f(G , T)) FPCat2(F (f(G , T), C )). ≃ We wish to define a 2-functor F : CartMult FPCat by for M 2 → 2 ∈ CartMult2, F M has finite x1,...,xn lists of objects of M as objects and as maps F M ((x1,...,xn), (y1,...,yn)) = Π1 i nM (x1,...,xn; yi). Compo- sition and identities are defined using composition≤ ≤ and the cartesian struc- ture of M .

Proposition 15.8. This forms a category with finite products given by

(x ,...,x ) (y ,...,y )=(x ,...,x ,y ,...,y ) 1 n × 1 n 1 n 1 n and 1=().

Proposition 15.9. It holds that

CartMult (M ,UC ) FPCat (F M , C ). 2 ≃ 2 Proof. (Sketch). Given a functor H : M UC ,defineHˆ : F M C by → →

– Hˆ (x1,...,xn)=Π1 i nHxi ≤ ≤

– Hˆ (f1,...,fn)= Hf1,...,Hfn :ΠiHxi ΠjHyj (using the univer- sal property) ⟨ ⟩ →

Fact 15.10. F U is a bi-adjunction. ⊢

Proposition 15.11. Let G be a multigraph and T an algebraic theory over G .Then,F (f(G , T)) is isomorphic to the category of contexts of (G , T).

Its objects are lists x1 : X1,...,xn : Xn (where xi Type, over G and x all distinct variables) up to α-equivalence. Its⊢ mapsx ¯ : X¯ y¯ : Y¯ i →

47 are judgements x¯ : X¯ M : Y ,uptoα-equivalence and modulo the ⊢ i equivalence relationx ¯ : X¯ M N : Y (provable from T). ⊢ ≡ ! " Remark 15.12. We will identify

x : X, x : X f(x ):Y 1 2 ⊢ 1 and x : X, x : X f(x ):Y 2 1 ⊢ 2 but we will not identify

x : X, x : X f(x ):Y 1 2 ⊢ 1 and x : X, x : X f(x ):Y. 1 2 ⊢ 2 We must rename in the term and context together.

Recall: Left adjoints preserve colimits and dually, right adjoints preserve limits. The former fact is often called “RAPL.” The latter fact does not have as cool of an abbreviation.

Proof. (Sketch). Let F G be an adjunction and (A ):I D be a ⊢ i → diagram and λ : A A a limit for it in D .Then, i → i C (X, GA) D(FX,A) ≃ lim D(FX,A ) ≃ i i lim C (X, GA ). ≃ i i

Example 15.13.

C (X, G1) D(FX,1) ≃ 1 ≃ and dually

D(F 0,Y) C (0,GY) ≃ 1 ≃

Similarly, 2-adjunctions K(C, GD) ∼= L(FC,D) preserve 2-limits and bi- adjunctions preserve bi-limits. These statements are of course just to give a feel, since these terms have not yet been precisely defined. In particular, if A is bi-initial in K and

48 F K L U

with K(C, GD) L(' FC,D)thenFA is bi-initial ≃ L(F A, X) K(A, GX) ≃ 1. ≃

In particular, we get for (G , T) an algebraic theory, the category of contexts of T Cl(G , T) ∼= F (f(G , T)) is bi-initial in the 2-category of finite product categories C with a map G → UC , functors preserving products weakly and the map from G strictly and natural transformations acting as 1 on G (“finite product categories with G -structure”). Similarly, given a G -structure in C , we get a map F (f(G )) C . So, we → can define when this G -structure satisfies the axioms of T.aT-model in C , and Cl(G , T)isbi-initial in the 2-category of finite product categories with T-models. Concretely, if C if a finite product category, for for each A G , an object A of C and for each arrow f : A ,...,A B in G ∈ 1 n → a map f :Π A B , so a map :Cl(G ) C (canonical up to i i → − → isomorphism). Moreover,! " if this satisfies the axioms of T in that ! " ! " ! " ! " x : X M : Y = x : X N : Y ⊢ ⊢ for each axiom x : X M N : Y , then this extends to a map ! ⊢ ≡" ! " Cl(G , T) C . We refer to Cl(G , T) as the classifying category of T (since → maps out of Cl(G! , T) are models of T). "

Exercises.

15.1. Let G be a multigraph, and T an algebraic theory over G (i.e. in the type theory for cartesian multicategories). Suppose C is a finite- product category, and F, G :Cl(T) C two (weakly) finite-product → preserving functors. Suppose also that for each object A of G , we are given a map α : F (A) G(A), and these are natural with respect A → to the arrows of G ; that is, for each arrow f : A1,...,An B of G , the square →

F (f) ∼= ΠiF (Ai) F (A1,...,An) F (B)

ΠiαAi αB G(f) ∼= ΠiG(Ai) G(A1,...,An) G(B)

49 Show that the arrows i extend uniquely to a natural transformation α : F G. → (This is the main step of showing that FPCat(Cl(T),E ) ModelE (T), where these are taken to include all natural transformations/homo-≃ morphisms as maps, not just isomorphisms.)

16 From Regular Categories to Regular Hy- perdoctrines

Yesterday, for a multigraph G and (algebraic) theory T over G , we got a finite product category Cl(G , T) (or perhaps to be more precise, we could call it ClAlg(G , T)). This had the property

FPCat(Cl(G , T),E) CartMult(f(G , T),UE) ≃ Model (E). ≃ T

Example 16.1. FPCat(Cl(TGrp), Top) topological groups . ≃{ }

Example 16.2. FPCat(Cl(TGrp), sMan) Lie (the category of Lie groups). ≃

One can also consider models of one theory in the classifying category of another theory.

Example 16.3. There is a functor Cl(TMon) Cl(TGrp). To define this, → we need to give an object of ModelTMon (Cl(TGrp)). We have A A (or x : A ) and we want U(m):U(A) U(A) U(A)i.e.[x ,x*→: A × → 1 2 ⊢ m(x1,x2):A]. We use U(m)=m and U(e)=e.

! All the" axioms of TMon are still then in Tgrp. This gives a map

Cl(TMon) C (TGrp). →

Then, for any G :Cl(TGrp) E , GU :Cl(TMon) E is the underlying monoid of G. → →

Maps Cl(G , T1) Cl(G , T2) can be viewed as translations of theories and induce translations→ on models

U FPCat(TGrp, E ) −◦ FPCat(TMon, E )

iso iso U ModelTGrp (E ) ModelTMon (E ).

50 Similarly, we will give classifying categories for theories in predicate logic assigning at least regular logic (i.e. , , , =). In other words, we will have bi-adjunctions ⊤ ∧ ∃

HeytHyp HeytCat

CohHyp CohCat

RegHyp RegCat

We write F : RegHyp RegCat for the above left bi-adjoint. For C , P → a regular hyperdoctrine, we construct F (C , P) as follows:

– objects: pairs (X,φ)whereX C and φ P(X) (think of this as “ x : X φ(x) ”) ∈ ∈ { | } – maps: (X,φ) (Y,ψ) are predicates Φ P such that x : X, y : Y Φ(x, y) φ(→X) ψ(Y ) (x : X) y(∈x) !y : Y,Φ(x, y)with | ⊢ ∧ ⇐⇒ | ⊢∃ ! y : Y,Φ(x, y) means y : Y,Φ(x, y) y : Y,(Φ(x, y) Φ(x, y′) ∃ ∃ ∧∀ ∧ → y = y′) but... we do not have foralls (that is how we ideally would state it in Heyting logic) instead we write

x : X φ(x) y : Y,Φ(x, y) | ⊢∃ x : X, y, y′ : Y Φ(x, y), Φ(x, y′) y = y′ | ⊢ It is easily checked that F (C , P) is in fact a category.

Facts:

– F (C , P) is a regular category. – If (C , P) was coherent (resp. Heyting), then F (C , P) is coherent (resp. Heyting). – This is the object part of a 2-functor RegHyp RegCat. → – It is left bi-adjoint to U for (C , P) a regular/coherent/Heyting hy- perdoctrine.

51 17 The Logic of Presheaves

Yesterday we showed that for a regular/coherent/Heyting theory T, over a multigraph G ,

RegHyp(Cl(G , T),E)=F (f(G ), T) RegHyp(f(G , T), SubE , E ) ≃ Model (E ). ≃ T The tough step in the equivalence is

RegCat(F (C , P), E ) RegHyp((C , P), (E , Sub )). ≃ E We want to show that given a regular hyperdoctrine morphism : − (C , P) (E , Sub ), it may be extended it a functor F (C , P) E . → E → ! " First, we recall the following definition:

Definition 17.1. A morphism of hyperdoctrines F :(C ,P) (C ′, P′) is →

– a functor F : C C ′ → – functors (i.e. monotone maps) F : P(X) P(X′) X → – commuting with all the operations of the hyperdoctrine

We, define this functor on

– on objects (X,φ) F (C , P) as (X,φ) = the domain of φ ∈ ∈ SubE ( X ) ! " ! " – on morphisms by, given Φ:(X, Y ) (φ,ψ)inF (C ,P)(i.e.Φ ! " → ∈ P(X Y ), ×

Φ

φ X Y ψ × ! " X X Y Y ×

Remarks 17.2. ! " ! " ! " ! "

– restriction gives maps Φ φ , Φ ψ → →

! " 52 ! " ! " ! " – existence axioms for Φimplies that Φ φ is a regular epimor- phism → – uniqueness axiom implies that Φ ! "φ is! a" monomorphism → – simultaneous regular epimorphisms and regular monomorphisms are isomorphisms, this gives us the! inverses" ! " needed φ Φ , ψ Φ → → ! " ! " ! " Surely! we" owe now an example of a Heyting category. We shall offer presheaf categories as this example. Let C be a small category write

Cˆ := [C op, Set].

Proposition 17.3. A map α : F G in Cˆ is a monomorphism (resp. → epimorphism) if and only if each αX : FX GX is a monomorphism (resp. epimorphism) in Set. →

Proposition 17.4. A subpresheaf A of F Cˆ is for each x C some ∈ ∈ subset A(x) F (x) closed under restriction (i.e. for f : x x′ in C , ⊂ → x A(x)impliesx f A(x′)). ∈ | ∈

Example 17.5. Take C =(N, )op ≤

0 1 2 3 ...

A subpresheaf of a sheaf on C looks like

F 0 F 1 F 2 F 3 ...

A0 A1 A2 A3 ...

The pullback on subobjects

F ∗ A

f F ′ F

is given pointwise i.e. f ∗A(x)=fx∗(Ax)

53 1 f − (Ax) Ax ∗

fx F ′x Fx

(just the inverse image). So, we have SubCˆ : Cˆop Pos. Operations → such as , , , , are again all pointwise on SubC op(F ). For example, take A, B∧ ⊤Sub∨ ⊥(F∃ ), ∈ Cˆ (A B)(x)=A(x) B(x) ∧ ∧ F (x). ⊂

Implication is more subtle. For example, take A, B SubC op (F ). Then, if we just took A B to be defined point wise, it∈ would not be closed under restriction. →

Counterexample 17.6. Let C =(N, )op ≤

A : 0 1 1 1 ...

B : 0 0 0 1 ...

“A B” pointwise : A 1 0 0 1 ... → Instead we take (A B)(x):= x FX f : x x, x f A x f B . → { ∈ |∀ → | ∈ ⇒ | ∈ } So, the actual (A B)(withA, B) defined as in counterexample 15.6. would be →

0 0 0 1.

For the universal quantifier, let F, G Cˆ,A F G.Then, ∈ ⊂ ×

( A)x = x Fx f : x′ x, y Gx′, (x fy) Ax′ . ∀E { ∈ |∀ → ∀ ∈ | ∈ }

Simple Type Theory: This is an extension of the type theory for carte- sian multicategories. Let Σ0 be any set (these will be our “base types”). Ty(Σ0) are the “types over Σ0” generated by

54 Xtype Y type A Σ0 ⊢ ⊢ . A type ∈ X Y type ⊢ ⊢ →

A signature ΣisasetΣ0 together with a multigraph whose objects are Ty(Σ0)i.e.setsΣ1(X1,...,Xn; Y ). We have the following rules for terms

Γ M1 : X1 ... Γ Mn : Xn ⊢ ⊢ f Σ(X1,...,Xn; Y ) Γ f(M ,...,M ):Y ∈ ⊢ 1 n Γ M : X Y Γ N : X app/ -elim ⊢ Γ →M.N : Y ⊢ → ⊢ Γ,x: X M : Y ⊢ λ-abstraction/ -intro . Γ (λx : X, M):X Y → ⊢ → There are also rules for .One ≡ Γ N : X β Γ (λx : X, M⊢).N M[N/x]:Y ⊢ ≡ called β-reduction and the other

Γ M : X Y η Γ M (λ⊢x : X, M.x→):X Y ⊢ ≡ → is called η-reduction.

Example 17.7. (Defining the identity function) Let X type. ⊢

x : X x : X λ-abs. (λx : X, x⊢):X X ⊢ → Exercises.

17.1 Work in a simple type theory over a signature Σ.

a. Let X, Y and Z be types over Σ. Write down a term f1 : X Y X Y ,f2 : Z cX,Y,Z : Z representing composition of func- tions. ⊢ b. Let X, Y, Z, W be types over Σ. Show that your composition is associative. 17.2. a. Write down terms in the simply typed λ-calculus (with the only type constructor) that have the following types (for→ arbi- trary A, B, C) A A →

55 A B A → → (A B C) (A B) (A C) → → → → → → Remember that the type operator associates to the right X Y Z means X (Y Z). → → → → → b. Let CL denote the type theory obtained from the simply typed λ- calculus and instead adding axioms called I,K and S

A type A type B type ⊢ ⊢ ⊢ Γ I : A A Γ K : A B A ⊢ A → ⊢ AB → → A type B type C type ⊢ ⊢ ⊢ . Γ S :(A B C) (A B) (A C) ⊢ ABC → → → → → → Prove that the λ-abstraction rule is admissible in CL. That is, given a derivation in CL of Γ, x : A M : B, we can construct a derivation in CL of Γ [x]M : A B for⊢ some term [x]M (so this is a defined operation on⊢ the terms→ of CL, like substitution).

c. Write down some -laws satisfied by I,K and S for show that when they are used as generators≡ for an on CL it also presents a free closed cartesian multicategory. One≡ way to do this is by a direct in- duction on derivations; another way is to exhibit a bijection between its terms and those of the simply typed λ-calculus. 17.3. Let A be a type in the simply-typed λ-calculus.

a. For any n N, construct a term [n]A of type (A A) (A ∈ → → → A) such that [n]A(f)isthen-fold iterate of f. b. Construct a term P of type

((A A) (A A)) ((A A) (A A)) ((A A) (A A)) → → → → → → → → → → →

such that for any n, m N we have P ([n]A)([m]A)=[n + m]A. ∈ c. Construct two types B and C and a term M of type

((B B) (B B)) ((C C) (C C)) ((A A) (A A)) → → → → → → → → → → →

such that for any n, m N we have M([n]B)([m]C )=[nm]A. ∈ 17.4. (Constructive theories of fields). Work in predicate logic over the multigraph G with a single sort A, two binary arrows p, m : A, A A, one unary arrow n : A A, and two nullary arrows i, o :() A→. → → Let T0 be the theory of a commutative ring, i.e. with the usual axioms:

56 x, y, z : A p(p(x, y),z)=p(x, p(y, z)) x : A p(x, o)=x |· ⊢ |· ⊢ x, y : A p(x, y)=p(y, x) x : A p(o, x)=x |· ⊢ |· ⊢ x : A p(n(x),x)=o |· ⊢ x, y, z : A m(m(x, y),z)=m(y, x) x : A m(x, i)=x |· ⊢ |· ⊢ x, y : A m(x, y)=m(y, x) x : A m(i, x)=x |· ⊢ |· ⊢ x, y, z : A m(x, p(y, z)) = p(m(x, y),m(x, z)) |· ⊢ x : A m(x, o)=o. |· ⊢

Take T1 to be T0 plus the axiom

x : A (x = o) y : A, m(x, y)=i. |· ⊢ ∨

Take T2 to be T0 plus the axiom

x : A (x = o) y : A, m(x, y)=i. |¬ ⊢∃ (In Set, these two theories have the same models: fields.)

Take E to be the Sierpi´nski topos: the arrow category Set→,i.e. presheaves on the category with two objects and a single non-identity arrow between them. So an object of E consists of a pair of sets with a map between them, χ : X0 X1; and a map in E consists of a commutative square in Set. →

a. Show that models of T1 in E consist precisely of pairs of fields with a field homomorphism: f : F F 2. (Hint: the “do- 1 → main” and “codomain” functors E Set both preserve coher- ent logic.) → b. Consider the ring of dual numbers R[x]/(x2), along with the homormorphism R[x]/(x2) R sending a+bx to a. Show that 2 → R[x]/(x ) R is a model of T2 in E . → (So this gives an example of theories that are equivalent under classical logic, but not in constructive logic.)

18 Cartesian Closed Multicategories

Presheaves and Models

Let’s look at predicate logic over a signature with a single base sort A and a single atomic predicate P .

57 Consider the theory T over G () x : A, P (x) x : A, P (x) . { |¬ ⊢∃ ¬ } To see that T is not provable in intuitionistic logic, we need to give a model where it fails. Heyting categories are a good place to look because they are the kinds of places where we can interpret this amount of logic. In Set, classical logic holds so any structure for G will also model T. Explicitly, () x : A.P(x) () x : A. P(x) |¬∀ ≤ |∃ ¬ in SubSet( () )=SubSet(1). This will not give us a countermodel. Let us ! op " ! " look in a topos model Nˆ =[(N, ), Set] ≤ ! "

X0 X1 X2 ...

P0 P1 P2 ...

The interpretation of the universal quantifier is

x.P(x) = 1 m n, x A ,x x : A P(x) ∀ n {∗ ∈ n|∀ ≥ ∀ ∈ m ∈ | m} 1, if m n, x A n,x x : A P (x) m ! " = ∀ ≥ ∀ ∈ ! " ∈ ! | " ! 0, otherwise. ! " ! " So,

() ( x.P(x)) = x.P(x) |¬ ∀ n ∀ →⊥ n = 1n m n, x.P(x) m ( 1 m) ! " {∗! ∈ |∀ ≥ "∗∈ ∀ → ∗∈ } = 1n m n, x.P(x) m {∗ ∈ |∀ ≥ ∗∈!∀ " →⊥} ! " = 1n m n, ( x.P(x) m) {∗ ∈ |∀ ≥ ¬ ∗∈! ∀ " } = 1n m n, ( x A m,x x : A P(x) m) {∗ ∈ |∀ ≥ ¬ ∀ ∈! ∈" | } = 1n m n, m′ m, x A m′ ,x / x : A P(x)m′ {∗ ∈ |∀ ≥ ∃ ≥ ! ∃" ∈ ! ∈ " | } 1, if m n, m′ n, x Xm′ ,x / Pn = ∀ ≥ ∃ ≥ ∃ ∈ ! " ∈ ! ! 0, otherwise.

Similarly,

() x. P(x) = 1 x A ,x x : A P(x) |∃ ¬ n {∗ ∈ n|∃ ∈ n ∈ |¬ n} = 1n x Xn, m, x m / x : A P(x) m ! " {∗ ∈ |∃ ∈ ! " ∀ |! ∈ | " } 1, if x Xn, m n, x m Pm = ∃ ∈ ∀ ≥ | ! ∈ " ! 0, otherwise.

58 This gives an explicit description of () x.P(x) and () x.P(x) in terms of subobjects of 1. |¬∀ |¬∀ To countermodel, we want some choice! of P X "such that! " ⊂

−|¬∀− ̸⊂ −|∃¬− We can get this by taking X = a, b , for all n 1 (just some 2 element ! n " ! " set) and X = b . { } ≥ 0 { }

a · · ·

b · · · ·

() x, P(x) 1 1 1 1 |¬∀ ! " () x, P(x) 0 1 1 1 |∃ ¬

Thus, () !x.P(x) ()" x. P(x) . This G -structure is a model of T |¬∀ ̸≤ |∃ ¬ and so () x.P(x) x. P(x) is not provable. { |¬∀ ⊢∃ ¬ } ! " ! "

– Our system from last time was the simply-typed lambda calculus (there is a closely related system called “Godel’s T”).

– Eventual semantics: cartesian closed categories (universally known as CCC’s) and cartesian closed functors between them. We will go via cartesian closed multicategories.

Definition 18.1. A cartesian multicategory M is closed if for any Y,A ∈ M there is an object Y A such that

A M (X1,...,Xn; Y ) ∼= M (X1,...,Xn,A; Y ) naturally in X1,...,Xn (but not necessarily in Y ).

Theorem 18.2. The syntax of the simply-typed lambda calculus over some (Σ0, Σ1)with forms a cartesian closed multicategory and this is initial in the (1 )category→ of cartesian closed multicategories with chosen exponentials and− functors strictly preserving the exponentials.

59 Proof. (Sketch). Objects of f(Σ) are types over Σ0 and arrows (X1,..,Xn; Y ) are terms [x1 : X1,...,xn : Xn M : Y ] up to [––– M M ′ : Y ] and variable renaming. The cartesian⊢ multicategorical structure⊢ ≡ is given by substitution in the syntax (as usual). For exponentials, consider A type, Y type. So, A, Y ob(f(Σ)) ⊢ ⊢ ∈ yA := (A Y ), → recalling the rule A type Y type ⊢ ⊢ A Y type. ⊢ → This gives us the universal property of Y A x : X ,....,x : X M : A Y 1 1 n n ⊢ → x1 : X1,....,xn : Xn,a: A N : Y x : X ,....,x : X ,a: A ⊢ N : Y 1 1 n n ⊢ x : X ,....,x : X M : A Y 1 1 n n ⊢ → gives the correspondence

M M a (λx : A,*→ N) · N. ← So, f(M) is indeed a cartesian closed multicategory. Initiality is done by # induction on syntax just as with initiality for the algebraic syntax.

Notation 18.3. We write CCC2 for the 2-category of cartesian closed categories, functors weakly preserving the cartesian closed structure and natural isomorphisms.

Theorem 18.4. There is a biadjunction

F

CCMult2 CCC2

U

Here, F and U have the same construction as for

F

CartMult2 FPCat2.

U

So, we need to show that

60 – for M a cartesian closed multicategory, F (M ) FPCat2 is carte- sian closed ∈

– for C FPCat , UC CartMult is closed ∈ 2 ∈ 2 – the correspondence

CartMult (M ,UC ) FPCat (F M , C ) 2 ≃ 2 restricts to

CCMult (M ,UC ) CCC (F M , C ) 2 ≃ 2 This all comes down to: given any Y,A in M CartMult , Y A is an ∈ 2 exponential in M if and only if it is in F (M ) and similarly for Y,A in C FPCat . ∈ 2 Exercises.

18.2. A (cartesian) multicategory M has binary coproducts if for any two objects A, B there is an object A + B with injections A A + B and B A + B, composing with which induces bijections→ → M (C ,...,C ,A+ B,D ,...,D ; E) 1 n 1 m → M (C ,...,C , A, D ,...,D ; E) M (C ,...,C ,B,D ,...,D ; E) 1 n 1 m × 1 n 1 m

for all C1,...,Cn and D1,...,Dm and E. Similarly, an initial object in M is an object 0 such that for any C1,...,Cn and D1,...,Dm and E, there is a unique morphism C ,...,C , 0,D ,...,D E. 1 n 1 m → Let G be a multigraph, and consider the type theory with the fol- lowing rules:

A G A type B type ∈ ⊢ ⊢ A type 0 type A + B type ⊢ ⊢ ⊢ Γ M1 : A1 ... Γ Mn : An ⊢ ⊢ f G (A1,...,An; B) Γ f(M ,..,M ):B ∈ ⊢ 1 n Γ M : 0 Γ M : A Γ abort(⊢ M):C Γ inl(⊢M):A + B ⊢ Γ N : B⊢ Γ inr(⊢N):A + B ⊢ Γ M : A + B Γ,u: A P : C Γ,v : B : C ⊢ ⊢ ⊢ Γ case(M,u.P,v.Q):C ⊢ Here Γdenotes an arbitrary finite list of types with distinct variables attached. In the term case (M,u.P,v.Q) the variables u and v are

61 bound in P and Q respectively, just like the variables that occur in a quantifier. You may assume that this type theory satisfies cut-elimination; the defining clauses of substitution are

x[M/x]=M y[M/x]=y (y a variable = x) ̸ f(N1,...,Nn)[M/x]=f(N1[M/x],..,Nn[M/x]) abort(N)[M/x] = abort(N[M/x]) inl(N)[M/x]=inl(N[M/x]) inr(N)[M/x]=inr(N[M/x]) case(N,u.p,v.Q)[M/x] = case(N[M/x],u.P[M/x],v,Q[M/x]) (x = u and x = v and u, v / M) ̸ ̸ ∈ The reduction equalities are

case(inl(M),u.P,v.Q) P [M/u] case(inr(M),u.P,v.Q) ≡ Q[M/v] ≡ case(M,u.P[inl(u)/y],v.P[inr(v)/y]) P [M/y] abort(M) P [M/y] ≡ ≡ Let F G be the cartesian multicategory whose objects are the types and whose morphisms are the term judgments Γ M : B modulo the equality , with composition given by substitution.⊢ Prove that FG is the free cartesian multicategory with binary coproducts and an initial object generated by G ; i.e. for any cartesian multicategory M with chosen binary coproducts and an initial object, any map of multigraphs G M extends to a unique functor F G M preserving the chosen→ coproducts and initial object strictly. →

19 On Completeness

Last time, we discussed the biadjunction

F

CCMult2 CCC2.

U

So, for a signature Σin the simply-typed lambda calculus, f(Σ) CCMult2, we will write ∈ Cl(Σ) := F (f(Σ)) CCC . ∈ 2

62 As per our biadjunction

CCC (Cl(Σ), C ) CCMult (fΣ,UC ) 2 ≃ 2 Model (C ). ≃ Σ Models are meant in the sense of

– a map :Σ obC − 0 → – for each f : x ,...,x y in Σ , a map Π x y in C (where 1 n → 1 i i → x , y! "are induced by :Σ C ) i i − 0 → ! " ! " Just as! before," ! " this can be extended! " to theories over Σ(T: a set of pairs of terms-of-the-same-type/context “Γ M M ′ : Y ”; generators: on ⊢ ≡ ≡ terms – hence F (Σ, T)=f(Σ)/ ).Then, the universal properties hold for ≡ f(Σ, T) and cl(T) exactly as for f(Σ), cl(Σ).

Soundness and Completeness

One view on the soundness and initiality results: They can be viewed as soundness and completeness.

Soundness Completeness

If something is provable/derivable then it must hold in all models If something holds in all models, it is derivable.

The basic data of a model (on generators of) the signature/theory) extends to a map on the whole of f(Σ, T) (or Cl(T)). A statement about a particular class of models.

For example, (intuitionistic) first order logic (IFOL) is not complete for models in Set because Set has classical logic. For example in a signature with (a single sort, and) a single unary predicate P ,“x : A P(x) |⊢ ∨ P(x)” is not provable – but it does hold in all models in Set. ¬ Typically, given the “general categorical semantics” (e.g. Heyting cat- egories for IFOL, CCC’s for the simply-typed lambda calculus (STλC), etc.) completeness holds, purely formally (or nearly so), for logic with respect to all categorical models.

Jargon 19.1. By the statement that a Heyting category believes Γ φ ,...,φ | 1 n ⊢ ψ we mean that for any Heyting functor :Cl(Σ) E , Γ y − → ∧i | i ≤ Γ ψ Sub ( Γ ). We write this as E =(Γφ ,...,φ φ) read as “E | ∈ E | | i n ⊢ believes Γ φ ,...,φ ψ” or “E models Γ φ ,...,φ ψ.” | 1 n ⊢ | !1 " n ⊢ ! " ! " ! "

63 Theorem 19.2. For IFOL, given a signature Σ,aΓa context over Σ, Γ φ1,...,φn ψ prop and suppose every model in any Heyting category believes⊢ that ⊢ Γ φ ,...,φ ψ. | 1 n ⊢ Then, Γ y ,...,y ψ is derivable in IFOL. | 1 n ⊢ Proof. Apply the hypothesis to (the model corresponding to) to the iden- tity functor

Cl(Σ) 1 Cl(Σ)

(the universal model of Σ). Then, this tells us (r, y ) (r, ψ)i.e. ∧i i ≤ (Γ, y )=(Γ,ψ)inSub (Γ, ) ∧i i Cl(Σ) ⊤ y ψ in P (Γ) ⇐⇒ ∧ i i ≤ Σ F y ψ is derivable in IFOL ⇐⇒ |∧i i ⊢ Γ y ,...,y ψ. ⇐⇒ | 1 n ⊢

Joke 19.3. The universal model is God because it creates all other mod- els in its image.

This gives a template for the “purely formal” categorical completeness results.

Example 19.4. Regular logic is complete for models in regular categories.

Example 19.5. Coherent logic is complete for models in coherent cate- gories.

Example 19.6. Propositional logic is complete for models in Heyting algebras.

Example 19.7. Classical logic is complete for models in Boolean algebras.

This can also give versions of completeness for type theory with a propo- sitional gadget.

Example 19.8. In algebraic logic (i.e. type theory for cartesian multi- categories over G ),

64 a. given Γ M,M′ : X, and “every model of G is any cartesian multi- ⊢ category (or finite product category) believes Γ M M ′ : X”(i.e. ⊢ ≡ for every cartesian :Cl(G ) C , M = M ′ : Γ X ) − → → then, Γ M M ′ : X is derivable. ⊢ ≡ ! " ! " ! " ! " ! " Proof. Again, look at the universal model 1 : Cl(G ) Cl(G ), or → 1:f(G ) f(G ). → So, algebraic logic is complete for in models in finite products categories and also in models in cartesian≡ multicategories. b. There are two forms of completeness of the term judgement 1. (weaker) Given G suppose in every model of G in a cartesian multicategory : fG M , we have some arrow A ,..., A − → 1 n → B . Then, there is some term in the syntax x1 : A1,...,xn : A M : B. n ⊢ ! " ! " ! " ! " Proof. Use the hyperdoctrine, in 1 : fG fG this is an arrow → A ,...,A B which must come from some term M . 1 n → 2. (stronger) Suppose we have, in each : fG M , some − M → arrow A ,..., A B , natural in M in that for F : M 1 1 → → M ′ (with F = e.g. respecting the interpreta- ◦ − M − M ′ ! " tions) ! " ! " ! " ! " F!(fM" )=fM ′, F A ,...,F A F B . Then, there is some term 1 M m M → M A ,...,A M : B such that for all : fG M , f = 1 n ⊢ − M → M M! M". ! " ! " ! " Proof. Take M to be some term representing the arrow f , ! " F (G ) induced by

1f fG G fG .

Then, for any : fG M we have − M → ! " fG 1f − M G ! " M fG . − M So, by the naturality hypothesis,! " we have

M M = fF G M

= fM ! " ! "

65 The stronger version can be sloganized as “Anything that happens natu- rally in all models, must be definable in the syntax.”

Disappointing Remark 19.9. If we had an extra week, we cold say something similar involving pseudonaturality! But alas, we do not have an extra week (this follows immediately from the definition of extra).

Theorem 19.10. Let C be any small category. Then, Cˆ is cartesian closed.

Proof. Let Y,A Cˆ, we need to define an exponential presheaf Y A such that ∈ Cˆ(X, Y A) = Cˆ(X A, Y ). ∼ × By Yoneda’s lemma, if there is an exponential presheaf, then it must satisfy (for all objects C) A ˆ A Y (C) ∼= C (yC, Y ) = Cˆ(yC A, Y ), ∼ × naturally in C. So, we define Y A(C):=Cˆ(yC A, Y ) × with functorial action : f : C C′ → Y A(C) = Cˆ(yC A, Y ) × A y (f) (y(f) A)∗ × A = Y (C′) Cˆ(yC A, Y ). × That this actually works is straightforward to see once written down.

Example 19.11. Our go to topos Nˆ op.

y(0) = A 1 1 1 ...

y(2) = Y 0 0 1 ...

Then,

y(n)=0 0 0 ... 0 1 1 ...

X y(n)=0 0 0 ... 0 X X ... × n n+1

66 So,

ˆ op (yA)n = N (y(n) A, Y ), ∼ × e.g. the set of natural transformations

0 ... 0 An An+1 ...

Y0 ... Yn 1 Yn Yn+1 ... − which is isomorphic to the set of natural transformations

An An+1 ...

Yn Yn+1 ...

For A = y(0), Y = y(2)

A 1 1 1 1 ...

Y 0 0 1 1 ...

Y A 0 0 1 1 ...

Now, in any CCC E

E (1,YA) = E (1 A, Y ) ∼ × ∼= E (A, Y ). The things in E (1,YA) we call the global sections of Y A. This should give some feel for the difference between the “internal hom” (exponential object) and the “external hom” E op E Set. × →

20 Intuitionistic Higher-Order Logic

Today we will begin to delve into (intuistionistic) higher-order logic (IHOL). To overview our logical systems so far

67 T.T. for multicats. (linear algebraic theories)

T.T. for cart. multicats. (algebraic theories)

T.T. for Heyting algs. (IPL)

STλC IFOL

IHOL (topos logic)

In IHOL, we have one new ingredient: power types.ItisIFOLplusnew rules: a type former rule for power types X type ⊢ PX type, ⊢ Γ,x: X φ prop ⊢ “comprehension” Γ x : X φ : PX ⊢{ | } (in comprehension, φ binds x) as well as “membership laws” Γ s : PX Γ:a : X ⊢ Γ a s prop ⊢ ∈X Γ s : PX “extensionality” Γ θ s = ⊢ x : X x s | ⊢ PX { | ∈X } Γ,x: X φ prop Γ a : X ⊢ ⊢ Γ θ φ[a/x] a x : X φ prop | ⊢ ⇐⇒ ∈X { | } the latter is similar to the β-rule (λx, M)a M[a/x] and extensionality is similar to the η-rule f λx, fx. ≡ ≡

Remark 20.1. Be aware that “comprehension” can mean many things other than what we are using it here to mean.

So, IHOL is

68 – all of the rules for IFOL – all of the rules for STλC, except with rules restated as “Γ θ M N” ≡ | ⊢ ≡X – rules for ,1 × – rules for P

Remark 20.2. To be more specific, this is IHOL , ,P . → ×

What are signatures here?

– asetΣ0 of base types

– a multigraph Σ1 whose objects are Ty(Σ0) (with all the types oper- ations , , 1, P) → × – for each list x1,...,xn from Ty(Σ0), a set Σpr(x1,...,xn) of basic predicates

Note also here the ways that the rules make judgements interdependent

types X type ⊢

terms Γ a : X props Γ φ prop ⊢ ⊢

Terms and propositions are mutually recursive! Entailment however, still does not feed back into the other judgements.

Remark 20.3. In dependent type theory, they will all depend on each other. More on this later.

A theory T over Σis for each context Γ, a relational multigraph on propositions-in-context-Γ(i.e. a set of axioms/“basic entailments” Γ θ | ⊢ φ). So, we have now managed to define IHOL , ,P over a signature with a theory. → ×

Categorical Analogue

Definition 20.4. Given a category E , with finite limits, and X E a ∈ power object for X is an object PX such that for all Y E ∈ E (Y,PX) = Sub (X Y ) ∼ E ×

69 naturally in Y .

The functorial action of Sub (X Y ) is pullback. For, f : Y Y ′, E × →

(X f)∗ A ×

X Y ′ X Y. × ×

This is a definition in terms of a universal property. Thus, like all defini- tions in terms of universal properties, this can be rephrased in terms of a universal object. So, equivalently a power object for X, is an object PX along with a morphism

ϵX

X PX × such that for any monomorphism A X Y , there is unique map χ : ! × A Y PX (called the classifying map) such that →

A ϵA

X χ X Y × A X PX. × ×

More specifically, we would call this a chosen power object (PX,ϵX ).

Definition 20.5. Givn a signature Σand a theory T (in IHOL , ,P ), × → there is a category Cl(Σ, T)with

– objects: pairs (X,φ), with X type and x : X φ prop ⊢ ⊢ – morphisms: Φ:(X,φ) (Y,ψ) are propositions x : Xy: Y Φ prop such that restriction→ to φ,ψ, existence and uniqueness are⊢ all derivable over T – modulo the identification Φ=Θ:(X,φ) (Y,ψ) → if x : X, y : Y () Φ Θprop is derivable (over T). | ⊢ ⇐⇒ Theorem 20.6. Cl(Σ, T) is a Heyting category, cartesian closed and with chosen power objects.

70 Proof. (Sketch). The Heyting structure is given just as for IFOL. The exponential is done by

(x, φ)(Y,ψ) := (P(X Y ) r : P(X Y ) “r is a functional relation”ψ φ) × | × ⊢ → and the power object by

P(X,φ):=(PX S : PX “S Y ”) | ⊢ ⊂ i.e. S : PX x : X, x S φ prop. ⊢∀ ∈X →

21 The Free Topos

Definition 21.1. An elementary topos E is a cartesian closed Heyting category with power objects.

Indeed it turns out that Theorem 20.6. will be enough to show that Cl(Σ, T) is an elementary topos.

Definition 21.2. A logical functor F : E E ′ is a functor that (weakly) preserves the power objects as well as the→ Heyting and cartesian close structure. What is meant by weak preservation is, for example, if

X Y × π2 π1 X Y is a product diagram, so is

F (X Y ) × π2 π1 FX FY and for any power object

ϵX

X PX ×

71 in E ,

FϵX

F (X PX) × is a power object for FX in E ′. There is a 2-category Log consisting of elementary toposes, logical func- tors and natural isomorphisms between them.

Theorem 21.3. For every IHOL signature/theory (Σ, T) and any ele- mentary topos E

Log(Cl(Σ, T), E ) Model (E ). ≃ T

Corollary 21.4. Take (Σ, T)empty.Then,Cl( ) is the bi-initial elemen- tary topos. ∅

For a 1-categorical universal property, see Lambek and Scott [LS86]. For more details of the 2-categorical universal property see volume 2 of the elephant [Joh02]. By models we mean:

a. given an interpretation :Σ E of Σ in E an induced map − 0 →ob 0 TyΣ E 0 →ob ! " b. an interpretation of Σin E is :Σ obE together with a − 0 0 → map :Σ UE (over Ty(Σ obE )). This induces a map of − 1 1 → 0 → multigraphs Tm(Σ) E also → ! " ! " pr Σ SubE (Πi Xi ) X1,...Xn → and ! " Prop(Σ) Sub (Π X ). X1,...,Xn → E i i c. given an interpretation of Σin ,itisamodel of if, for each E ! " T axiom, Γ, Θ φ in T, Θ φ in SubE Γ . ⊢ ≤ d. an ismorphism of models , ′ (of Σ, T in E ) is: for each A E0, an isomorphism ! " − ! −" ! " ∈ α : A A′ ! A" ! " → such that the induced isomorphisms αX : X X′ commute with , . ! " ! " → − 1 − pr ! " ! " ! " ! " 72 Now, we call this Cl( )thefree topos. It is commonly written by any of: ∅ Efree, E0, E or even f. ∅

Definition 21.5. A subobject classifier in E is an object Ωalong with a map :1! Ωsuch that for any monomorphism A ! X in E there is a unique⊤ map χ : X Ωsuch that A → A 1

X Ω

is a pullback square.

In other words, there is a natural isomorphism

E (X, Ω) ∼= SubE (X). One piece of intuition for Ωis that it is an object of truth values.

Example 21.6. In Set,Ω= 0, 1 . For A X, { } ⊂ 1,x A χA(x)= ∈ 0,x/A. ! ∈

Another way to look at it is as PX, because

E (X, P1) = Sub (X 1) ∼ E × ∼= SubE (X). Proposition 21.7. If E has finite limits and power objects, then P1isa subobject classifier.

We can also go the other way.

Proposition 21.8. If E is cartesian closed and has a subobject classifier, then it has power objects given by

PX =ΩX . Proof.

E (Y,ΩX ) = E (Y X, Ω) ∼ × = Sub (Y X). ∼ E ×

73 Theorem 21.9. If E is Heyting and has power objects, then it is cartesian closed.

Proof. Construct XY := r : PX “r is a functorial relation X Y ” | → Proposition 21.10. An elementary topos has finite colimits ! " Proof. First, we claim that there is an adjunction

P E E op

P To see this, observe

E (X, PY ) = Sub (X Y ) ∼ E × = Sub (Y X) ∼ E × ∼= E (Y,PX) op ∼= E (PX, Y ). This adjunction, by the mondacity theorem, can be shown to be monadic. op op So, as AlgTE always has any limits that E has, E does too (as per E = AlgP(P( ))E ). Thus, E has finite colimits. − Remark 21.11. If this fact (Proposition 21.10.) was not known, surely we would define a topos to have colimits. Thus, one could define them as what they really are, deep down in our hearts, as cartesian closed Heyting categories with power objects and coproducts; then have a theorem that says in order to know a cartesian closed Heyting category is an elementary topos, it suffices to know it has power objects.

Theorem 21.12. (Disjunction and Existence Properties) For IHOL (over any signature, no axioms) if φ ,φ are any closed propositions, () φ ,φ prop. 1 2 ⊢ 1 2 If () () φ1 φ2 prop is derivable, then either () () φ1 or () () φ2 is derivable. Moreover,| ⊢ if∨x : X φ prop and () () x : X| φ,⊢ then there| is⊢ some definable x : X, x : X x φ. ⊢ | ⊢∃ | ⊢ These properties have quite difficult proof theoretic proofs, but slick cate- gorical proofs due to Freyd. The idea is as follows: 1. replace the goals as indecomposability/projectivity of 1 in Cl(Σ) (recall projectivity means

A ! ∃ epi 1 B

74 ). 2. take Γ= Cl(Σ)(1, ):Cl(Σ) Set, construct its comma category, show it is a topos and then− juggle→ for a moment with functors between these and universal properties of Cl(Σ) 3. the result falls out by categorical sleight of hand! This is called “Freyd’s sconing proof.” There is a good write-up of it on the nLab.

Fact 21.13. N is also projective in Efree(N) the free topos with a natural numbers object. Proof. Attributed to Mukkai/Freyd-Sˇcedrov...ˇ the proof has been totally lost!

22 Some Dependent Types

To close off, we will say something about dependent type theory. This has foun- dational motivation: to make our logical system closed to actual mathematical practice. All type theories are this way, in mathematics whenever a something is introduced one always says one kind of thing it is – for example: “Let M be compact ...” or “Let n be a natural number...” One never lumps all sets together with statements like “If S is a compact manifold, then P holds and if S is a natural number, then Q holds.” Now, sometimes it is desirable to have the type of a variable refer back to another.

Example 22.1. “For all n N, ...” and then “For all x Rn,...” ∈ ∈ So, judgement forms all now involve a context (except the judgement of actually being a context). The judgement forms are the following: Γcxt ⊢ Γ A type ⊢ Γ A A′ type ⊢ ≡ Γ a : A ⊢ Γ a a′ : A. ⊢ ≡ These will all be defined by a big mutual recursion. Some of the rules:

75 Structural Γcxt Γ A type ⊢ ⊢ () cxt Γ,x: A cxt ⊢ ⊢ this one is like “ n : N,x: Rn cxt” ⊢ Γ A A′ type Γ a : A ⊢ ≡ ⊢ Γ a : A′ ⊢ this is like x : R3,y : R4 x.y : R3+4 Γ R3+4 R7 ⊢ ⊢ ≡ x : R3,y : R4 x.y : R7 ⊢ Type Constructors This first one it certainly just does not feel like dependent type theory without – they are call “Π-types.” They are sometimes also called “dependent functions” or “dependent products” (although “dependent function” is probably more ap- propriate than “dependent product”). Γ A type Γ,x: A B type ⊢ ⊢ Π-form Γ Π B type ⊢ x:A there is also another popular notation for this associated with Agda Γ A type Γ,x: A B type ⊢ ⊢ Π-form Γ (x : A) B type ⊢ → Remark 22.2. This particular type theory one can really get some hands- on practice with because it is implemented in proof assistants like Agda, Coq and Lean.

n n Example 22.3. The identity matrix function I :(n : N) R × .The codomain depends on the domain. →

The rest of the rules Γ,x: A b : B ⊢ Π-intro Γ λx : A, b :Π B ⊢ x:A Γ f :(x : A) B Γ a : A ⊢ → ⊢ Π-app Γ f a : B[a/x] ⊢ · Γ,x: A b : B Γ a : A ⊢ ⊢ Π-comp Γ (λx : A, b)a b[a/x]:B[a/x] ⊢ ≡

76 n n 3 3 Example 22.4. I(3) : R × [3/n] R × . ≡ Example 22.5. Let C be any category

C type ⊢ 0 and x, y : C C (x, y)type. 0 ⊢ 1 Then, composition : (x : C ) (y : C ) (z : C ) C (x, y) C (y, z) 0 → 0 → 0 → 1 → 1 C (x, z). → 1 This can also be written out using full Π-notation as

Πx: C0,y:C0,z:C0,f:C1(x,y),g:C1(y,z)C1(x, z) or with a hybrid notation as

Π C (x, y) C (y, z) C (x, z). x,y,z:C0 1 → 1 → 1 Remark 22.6. Non-dependent function types A B are a special case of dependent function types. →

So, we put in Π-types, binary product types and get IFOL for free! We represent propositions as types.

A B represents φ ψ → → A B represents φ ψ × ∧ 1represents ⊤ using coproduct types would give us disjunction as well. For quantification, if Γ,x : A y prop is represented by Γ,x : A B type, then x : A,φ is represented by⊢ ⊢ ∀ Γ Π B type. ⊢ x:A This transfers the question of whether a proposition has a proof to whether a type has an element propositions φ terms [φ] φ terms t :[φ] assuming φ assuming variable of [φ]

This is called the Curry-Howard correspondence.

Example 22.7. Commutativity of addition would be some term of type

Πx,y:NIdN(p(x, y),p(y, z)) which is type that represents the proposition

77 “p(x, y)=N p(y, x).” Now, a bit of history: reading the literature it might appear that dependent type theory sprang fully-formed out of the head of Per Matin-L¨ofabout 1978. There were two main forms: extensionsal and intensional. This distinction has it roots in philosophy. For example, “rational beings” and “featherless bipeds” have (modulo Kangaroos) the same extension, meaning roughly that they refer to same things in the world, but a different intension (something like the meaning or the way of presenting an object). Depending on which philosopher you talk to, this is much like Frege’s distinction between sense and reference. The idea of extensional type theory (ETT) is that identifies things ex- tensionally and the idea of intensional type theory (ITT)≡ is that identifies things intensionally. Due to an incredible amount of terminological≡ confusion surrounding extension/intension in type theory, we would much rather call these definitional and propositional equality. ETT is modeled is locally cartesian closed categories (LCCC) and one can extend ETT to get a dependently typed language for toposes. Intensional type theory is proof-theoretically nicer, but a bit weird. At least this was the initial impression, due to the behavior of equality was poorly understood for a while. When this was sorted out, it gave rise to homotopy-theoretic models (equiva- lently, -categorical models) a.k.a. homotopy type theory (HoTT). ∞ 23 References References

[Joh02] Johnstone, P. T. Sketches of an Elephant: A Topos Theory Com- pendium: Volume 2. Clarendon Press, 2002. [Lie03] Leinster, T. Higher , Higher Categories. London Mathematical Society Lecture Note Series 298. Cambridge University Pres, 2003.

[LS86] Lambek, J. and P.J. Scott. Introduction to Higher Order Categorical Logic. Cambridge University Press, 1986.

78