Langage et concepts catégoriques pour les mathématiques et l’informatique

De Wiki du LAMA (UMR5127)

This is a wiki for a course at the MSTII "École doctorale" of Grenoble.

Students are encouraged to participate by extending the wiki, adding proofs, corrections for exercices etc. To be able to modify the wiki, you need to register (upper right corner). Please use your real name...


Sommaire

News

Courses are on wednesdays morning, 9'00 to 12'00 in room F218 at the "UFR IMAG".

  • first course on the 25th of February: categories, functors, natural transformations.
  • March 4. : monads, adjunctions.
  • March 11. : limits and colimits.

Basic Concepts

Categories

Definition. A concrete category is given by:

  • a collection of sets with structure,
  • for any pair of such sets, a set of morphisms preserving the structure.

Morphisms should compose, and the identity should be a morphism.

This definition is a little informal, but here are some examples:

  • Grp: groups and group morphisms
  • Top: topological spaces and continuous functions
  • Ring: rings and rings morphisms
  • Vect: vectors spaces and linear maps
  • CPO: CPOs and continuous functions
  • ...
  • Set: sets and functions (ie sets with no structures, and arbitrary functions)

Generalizing the definition, we obtain the official definition of category:

Definition. A category \mathcal{C} is given by:

  • a collection \mathcal{C}_o of objects, (notation: A,B,C,X,Y,...)
  • for each pair A,B of objects, a collection \mathcal{C}[A,B] of morphisms from A to B, (notation  f : A\to B)
  • for any object A, a special morphism i_A : A\to A
  • for all objects A,B,C, a composition \circ : \mathcal{C}[B,C] \times \mathcal{C}[A,B] \to \mathcal{C}[A,C],

such that:

  • f \in \mathcal{C}[A,B] \implies f\circ i_A = i_B\circ f = f
  • f\circ(g\circ h) = (f\circ g)\circ h whenever it makes sense.


All concrete categories are categories, and here are some examples that are not obviously concrete:

  • Graph: graphs and graph morphisms
  • Rel: sets and relations
  • Set×Set: pairs of sets, pairs of functions
  • Setop: opposite of Set
  • P, whenever (P,<) is a preorder (at most one morphism between objects)
  • M, whenever (M,e,×) is a monoid (a single object)

We sometimes write gf instead of g \circ f.

In a given category \mathcal{C}, there are analogues of the notions of injective and surjective functions in Set. We will see that on concrete categories, they are actually slightly more general. The idea of injectivity gives rise to monomorphisms, and surjectivity gives rise to epimorphisms.

Definition.

A morphism f \colon A \to B is a monomorphism iff for all object C and morphisms g,h \colon C \to A, we have fg = fh implies g = h.

The morphism f is an epimorphism when it is a monomorphism in \mathcal{C}^{op}. Explicitly, when for all object C and morphisms g,h \colon B \to C, we have gf = hf implies g = h.

 isomorphism


Exercice

  1. Prove that in Set, epic is equivalent to surjective and monic is equivalent to injective.
  2. Prove the same thing in Ab, the category of commutative groups. (One thing is not obvious.)
  3. Prove the same thing in Grp, the category of (non necessarily commutative) groups. (One thing is not obvious at all.)
  4. Prove that i : \mathbf{Z} \to \mathbf{Q} is an epimorphism in the category of rings with multiplicative neutral. (Note that it is not surjective.)
  5. In Set, we saw that f is a monic iff \forall x,y : 1 \to A, f\circ x = f\circ y \implies x=y, where 1 is any singleton set. Can you find a set C such that f is epic iff \forall p,q : B \to C, p\circ f = j\circ f \implies p=q?
  6. In Group, can you find an object playing a role similar to 1, ie a group G s.t. f is monic iff \forall x,y : G \to A, f\circ x = f\circ y \implies x=y. (We saw that we cannot use the singleton group ({e},e,×) to do that...)

Functors

Informally, a functor is a map between two categories which somehow preserves the structure of categories (namely, composition).

Definition. A functor F from a category \mathcal{C} to a category \mathcal{D}, noted F \colon \mathcal{C} \to \mathcal{D}, is given by:

  • a map which sends every object A of \mathcal{C} to an object FA in \mathcal{D}, and
  • a map which sends every morphism f \colon A \to B in \mathcal{C}, to a morphism Ff in \mathcal{D}[FA, FB],

such that:

  • F preserves identities, i.e., F(idA) = idFA, and
  • F preserves composition: F(f \circ g) = F(f) \circ F(g).


Exercice

  1. Take a functor F \colon \mathcal{C} \to \mathcal{D}, f,g,h three morphisms in \mathcal{C}, and f' = Ff, g' = Fg, h' = Fh. When h' = f' \circ g', can we say something interesting about f, g and h?
  2. Do functors preserve monomorphisms? Do functors preserve epimorphisms?
  3. Let F be a functor and F(f) = g, if g is a mono (resp. epi), is f a mono (resp. epi)?

If not, try to find some simple and natural condition on the functor to make that true.

Answer

  1. No, since f and g may not even compose! This is the case when f has type A \to B, and g \colon C \to D, with F collapsing D and A (i.e., FA = FD).
  2. Functors in general do not preserve mono- nor epimorphisms. We build a counter-example for monomorphisms. Let \mathbf{2} be the category with two objects \star and \bullet, and exactly one morphism m \colon \star \to \bullet. This is a preorder, so m is monic. Now take \mathcal{C} with two objects \star and \bullet, exactly one morphism m \colon \star \to \bullet, and one extra morphism n \colon \star \to \star, different from the identity. Because of n \neq id_\star, yet m \circ n = m \circ id, m is not monic in \mathcal{C}. The functor which sends \star to \star, \bullet to \bullet and m in \mathbf{2} to m in \mathcal{C}, does not preserve monomorphisms.
  3. In general, the answer is (again) no. For monos, take for example the functor \mathcal{C} \to \mathbf{2} which sends n to the identity. Yet, when F is faithful, then f is monic (or epic).

Definition. A functor F is faithful when, for any two morphisms f,g, Ff = Fg implies f = g (F is injective on morphisms).

Definition. A functor F is full when, for any two objects A,B, if g is a morphism FA \to FB, then there exists f \colon A \to B with Ff = g (F is surjective on morphisms).


Exercice

Find an "interesting" functor from Set to Group.

Answer Let F be the functor which sends:

  • every set X to the free group generated by X, and
  • every function f \colon X \to Y to a group morphism defined by: Ff(x_1^{\alpha_1}\times\dots\times x_k^{\alpha_k})=f(x_1)^{\alpha_1} \times \dots \times f(x_k)^{\alpha_k}.


Exercice

If \mathcal{C} is a locally small category and A one of its objects, let Y_A : X \mapsto \mathcal{C}[X,A]. Show that this operation from objects of \mathcal{C} to sets can be extended into a contravariant functor \mathcal{C} to Set.

Answer Let f\colon X \to Y be a morphism in \mathcal{C}, then YA(f) is expected to be a function from the set \mathcal{C}[Y, A] to the set \mathcal{C}[X, A]. We can take, for any morphism m \in \mathcal{C}[Y,A]: Y_A(f)(m) = m \circ f.

This extends YA to a contravariant functor, since Y_A(id_X) = id_{\mathcal{C}[X, A]} and Y_A(f \circ g)(m) = m \circ (f \circ g) = (m \circ f) \circ g = (Y_A(g) \circ Y_A(f))(m).

Natural Transformations

Definition. Let F and G be two functors \mathcal{C} \to \mathcal{D}. A natural transformation α from F to G is given by:

  • a morphism \alpha_A \colon FA \to GA in \mathcal{D} for every object A in \mathcal{C},
  • such that, for any morphism f \colon A \to B, we have Gf \circ \alpha_A = \alpha_B \circ Ff.


Exercice

If P(X) is the set of permutation of a (finite) set X; and L(X) the set of its linear orderings, we have \#(L(X)) = \#(L(X)) = n! where n = \#(X). Thus, there is a bijection (iso in Set) between P(X) and L(X).

  1. Show that we can extend P and L to functors from B to Set, where B is the category of finite sets and bijections,
  2. Show that there can be no natural transformation from P to L,
  3. Conclude that there is no natural isomorphism between P and L.


Adjunctions and Monads

2-categories and their diagrammatic calculus

This part is just to make the definitions of monads and adjunctions easier: we do not give the full details, and only intend to provide a few intuitions.

Definition. A 2-category is like a category: it has objects and morphisms between them. But it also has 2-cells, which are 'morphisms between morphisms':

A 2-cell

These 2-cells must compose vertically and horizontally, satisfying the interchange law:

Interchange law


There is a more comfortable representation than the '2-diagrams' above. In pictures:

String diagram example

In words, the idea is to consider:

  • objects as background colors,
  • morphisms as vertical frontiers between them, and
  • 2-cells as labelled dots.

Then, both compositions correspond to horizontal and vertical juxtaposition, respectively. For example, the interchange law corresponds to the two ways of parsing:

Interchange law in a string diagram

There are technical subtleties hidden behind this nice diagrammatic calculus, but we will stick to bare intuitions for now.

Cat as a 2-category

The prime example of a 2-category is of course Cat, the category of (small) categories. It has:

  • objects: small categories,
  • morphisms: functors,
  • 2-cells: natural transformations.

Vertical composition of 2-cells is the obvious notion of composition of natural transformations.

Define the horizontal composition:

Vertical composition
by

(\beta \bullet \alpha)_a = f' (f (a)) \xrightarrow{f' (\alpha_a)} f' (g (a)) 
\xrightarrow{\beta_{g (a)}} g' (g (a))

or equivalently


(\beta \bullet \alpha)_a = f' (f (a)) \xrightarrow{\beta_{f (a)}} g' (f (a)) 
\xrightarrow{g' (\alpha_a)} g' (g (a)).

The two coincide by naturality. Observe that what we have actually done is:

  • define whiskering, i.e., composing with an identity, both to the left and to the right, and
  • observe that the two ways of defining horizontal composition from whiskering coincide.

This yields an equivalent definition of 2-categories.


Monads

  • Free constructions in algebra: monoid, group, etc
  • Definition of a monad
  • Eilenberg-Moore's category of algebras
  • Kleisli's category of free algebras
  • The category of resolutions of a monad

Adjunctions

  • Definition with η
  • Definition with hom-sets
  • Definition with η and ε
  • Adjunctions in a 2-category

Other basic examples

  • Discussion: any syntax defines the free something
  • The issue of variable binding.
  • Adjunction between partial orders = Galois connection
  • \times and \Rightarrow in logic
  • Sets/graphs and categories

Properties

  • Composition
  • Preservation of limits/colimits
  • Freyd's existence theorem, the locally presentable case
  • Beck's monadicity theorem

Limits and Colimits

Limits

Example. Cartesian product.

Definition. Binary product.

Theorem. The product of X and Y, if it exists, is unique up to isomorphism. (with proof)

Examples. Set, Grp, Ab, Part.

Examples. Preorder, Subset(E), Prop with entailment.

Definition. Diagram. Cone. Limit.

Example. Limits in Set.

Examples. Shape of diagrams for products, pullbacks, equalizers.

Example. Monos as pullbacks.

Theorem. The limit of a diagram d, if it exists, is unique up to isomorphism.

Theorem. A category with "all" products and equalizers has "all" limits.

Theorem. A category with a terminal object and all binary products and all equalizers has all finite limits.

Colimits

Definition. Cocone. Colimit.

Examples. Sums in Set, Grp, Ab.

Examples. Shape of diagrams for sums, initial objects, pushouts, coequalizers.

Example. Epis as pushouts.

Theorem. The colimit of a diagram d, if it exists, is unique up to isomorphism.

Example. The most general unifier (of two terms) is a coequalizer in the "category of substitutions".

Theorem. A category with "all" sums and coequalizers has "all" colimits.

Theorem. A category with an initial object and all binary sums and all coequalizers has all finite colimits.

Limits, colimits and adjunctions

Theorem. A right adjoint preserves limits. A left adjoint preserves colimits. (with proof of existence)

Example. The adjunction between Set and Grp

Sums and products

A category is distributive if the canonical map from AxB+AxC to Ax(B+C) is an isomorphism.

A category is extensive if the canonical functor + from C/A x C/B to C/(A+B) is an equivalence.

Example. "if..then..else.." from B=1+1 and extensivity.

Monoidal categories

Definition and graphical calculus

  • Definition
  • Graphical calculus
  • The 2-category of monoidal categories, strong monoidal functors, and monoidal transformations
  • Coherence and its many definitions

From planar to symmetric monoidal categories

A teaser for the whole enchilada of variations on monoidal structure.

  • Braided
  • Balanced
  • Symmetric
  • Compact closed
  • Traced monoidal categories and the Int/GoI construction

Monoidal categories for linear logic

  • Linear logic
    • Sequent calculus
    • Intuitionnistic variant
    • Proof nets
  • Symmetric monoidal closed categories
  • Star-autonomous categories
    • Symmetric monoidal closed category with a dualising object
    • Symmetric monoidal category \mathcal{C} with:
      • a full and faithful contravariant endofunctor \mathcal{C}^{op} \xrightarrow{(-)^*} \mathcal{C} , and
      • an isomorphism
        \mathcal{C} (A \otimes B, C^*) \cong \mathcal{C} (A, (B \otimes C)^*).
  • Trimble-Hughes' free star-autonomous category
    • Split star-autonomy
    • The free star-autonomous category as a category of proof nets
    • Trimble rewiring

Perspectives

  • Premonoidal categories and side effects
  • Products and coproducts
  • Monoidal 2-categories, monoidal double categories.

Presheaves and sheaves

Yoneda

  • A few presheaf categories \hat{\mathcal{C}} := \mathcal{C}^{op} \to \mathbf{Set}:
    • \mathcal{C} is a graph (no composition): graphs.
    • \mathcal{C} is a preorder: Kripke-style modal logic.
    • \mathcal{C} is an order: presheaves on a topological space.
    • \mathcal{C} is free: presheaves on an algebraic theory.
  • Representable presheaves yA(B) := \mathcal{C}(B, A), and their meaning in each of the examples.
  • The Yoneda lemma: for any object A of \mathcal{C}, and presheaf F, there is an isomorphism
F (A) \cong \hat{\mathcal{C}} (yA, F),

natural in A and F.

  • A consequence: y is a 'full embedding', or how \mathcal{C} is a full subcategory of \hat{\mathcal{C}}.
  • Presheaves as a colimit completion
    • The Grothendieck construction, or the category of elements of a presehaf.
    • Example: graphs.
    • Every presheaf is a colimit of representables.
    • Example: graphs.
    • The universal property of y.

Topos structure

  • Limits and colimits in functor categories.
  • Exponentials. If it exists, the exponential GF must satisfy, for any object A of \mathcal{C}:
    \begin{array}{lcl}
G^F(A) & \cong & \hat{\mathcal{C}} (yA, G^F) \\
& \cong & \hat{\mathcal{C}} (yA \times F, G).
\end{array}

Taking this as a definition indeed yields an exponential.

  • Computation of the exponential in Gph.
  • The very special presheaf Ω.
  • The isomorphism
    \mathit{Sub}(F) \cong \hat{\mathcal{C}} (F, \Omega).
  • The official definition of a subobject classifier and a topos.

Sheaves

  • Sheaves on a space, a few examples and counterexamples:
    • functions,
    • continuous functions,
    • bounded functions.
  • The (\cdot)^+ construction and its convergence in two steps. The counterexample of constant presheaves.
  • Sheaves on a site. Example of sheaves for the dense topology on an algebraic theory and its coincidence with the double negation topology.

Sketches (esquisses)

Linear sketches

"A linear sketch is a generator for a category"

Examples. Linear sketch for graphs, for sets, for a split mono-epi.

Definition. A linear sketch is a graph with some potential idenitites and composed arrows

Definition. The category of models of a linear sketch S in a category C, Mod(S,C), or Mod(S) when C is Set.

Note. The set-valued models of S are the presheaves over F(S)^op

Theorem. A linear sketch has a terminal model, made of singletons, and an initial model, made of empty sets.

Definition. The category of linear sketches LinearSk and the underlying functor U:Cat->LinearSk

Theorem. There is a left adjoint to U, F:LinearSk->Cat. F(S) is the category generated by S

Example. "Implementation of Bool by Nat" : fractions of morphisms of linear sketches

Definition. The Yoneda contravariant model of S with values in Mod(S)

Limit sketches

"A limit sketch is a generator for a category with limits"

Examples. Limit sketch for monoids, "for naturals".

Definition. A limit sketch is a linear sketch with some potential limits

Definition. The category of models of a limit sketch S in a category C, Mod(S,C), or Mod(S) when C is Set.

Theorem. A limit sketch has a terminal model, made of singletons, and an initial model, made of the closed terms.

Definition. The category of limit sketches LimSk and the underlying functor U:LimCat->LimSk

Theorem. There is a left adjoint to U, F:LimSk->LimCat. F(S) is the category with chosen limits generated by S

Theorem. There is still a Yoneda contravariant model of S with values in Mod(S)

Sketches

"A sketch is a generator for a category with limits and colimits"

Example. Sketch for fields.

Definition. A sketch is a limit sketch with some potential colimits

Definition. The category of models of a sketch S in a category C, Mod(S,C), or Mod(S) when C is Set.

Note. A sketch has no terminal model and no initial model, in general.

Theorem. [Guitart-Lair] A sketch with only discrete potential colimits has an initial family of models.

Definition. The category of sketches LimSk and the underlying functor U:LimColimCat->Sk

Theorem. There is a left adjoint to U, F:Sk->LimColimCat. F(S) is the category with chosen limits and colimits generated by S

Remark. The proof of this theorem (and the previous similar ones) can be done by first constructing a limit sketch E1 for Sk, a limit sketch E2 for LimColimCat, and a morphism of limit sketches P:E1->E2, and then applying Ehresmann's theorem below, which is a fundadmental theorem about limit sketches.

Theorem. [Ehresmann]. For each morphism of limit sketches P:E1->E2 there is an adjunction (F,U) where U:Mod(E2)->Mod(E1) is the composition by P.

Note. There is no Yoneda contravariant model of S with values in Mod(S)

Sketches and logic

"A sketch is an alternative to a logical theory"

From the point of view of (set-valued) models:

finite products sketches <-> equational logic

finite limits sketches <-> a logic strictly more expressive than the logic of universal Horn theories

sketches  <->  first order logic

Generalization of sketches to higher order logic?

Course Complements, references

One of the best books about category theory is

  • Saunder MacLane, "Categories for the Working Mathematician".

It is a little "dry", in the sense that learning categories from it is not the easiest task on earth, but it still is one of the best references.

I haven't really read it carefully, but here is what Wikipedia has to say on category theory.

Outils personnels