Lecture 3: Functors


See exercises below for clarification of some of the discussions during the video lecture, especially the discussions at the end of the lecture.

3.1. An Abstract Notion of a Dynamical System

We begin this lecture with an abstract notion of a dynamical system. After recalling this notion, we will try to express it using the language of categories. This process will lead us to a general notion of a mapping between categories: the notion of a functor.

A dynamical system is a mathematical structure that consists of a set "X" of states (of a real-life system being modeled), and for each time laps represented by a (non-negative) real number "t", a mapping of members of "X" to members of "X", i.e., a function from the set "X" to the set "X", which we will write as "f" with a subscript "t".

The effect of this function on members of the set "X", i.e., on the states, represents the following. For each state "x", the value
represents the state to which the given system will transition from state "x", after "t" time elapses. For the data just described to constitute a dynamical system, the following two axioms need to be satisfied:
In the first axiom, the subscript at "f" is the number 0. This axiom says that if if the system is at state "x", then after 0 time lapse, the the system will still be at state "x" - a very natural requirement, of course! The second axiom is written in the language of composition of functions. It can be illustrated by the following diagram:
 

In this diagram, the vertices marked by small balls represent the states. An arrow represents transition of states associated with the lapse of time given by the label of the arrow. The diagram shows that if the system transitions from state "x" to state "y" in time t', and from state "y" to state "z" in time t, then it must have transitioned from state "x" to state "z" in time t+t'. Again, a natural requirement! In the functional language, this condition says that mapping "x" by the "f" subscript t' function (recall that this function describes the effect of state transition for time lapse t'), and then mapping the result "y" further by the "f" subscript t function, we get the same result as directly mapping "x" by the "f" subscript t+t' function. Writing this compositionally, we get precisely the second of the two equalities above.

Thus, a dynamical system consists of a set "X" and a function from "X" to "X" denoted by "f" with subscript "t", which is specified for each non-negative real number "t", such that these functions satisfy the two axioms discussed above. 

To describe a dynamical system in the language of categories, we first need to prepare some ground work. In particular, we need to set up two categories. The time category and the category of sets. The first category is similar to one of the examples of categories we discussed in the first lecture. The second category is similar to the category of natural numbers we discussed in the second lecture. In the time category, there is only one object. All arrows in this category are thus looping arrows. The arrows are given by non-negative real numbers. Composition of arrows is given by addition of numbers. The number 0 is the special arrow of the unique object. The two axioms of the category are then fulfilled because addition of numbers is associative and the number 0 has the property that its sum with any other number gives back that number (irrespective of the order of addition). In the following illustration of the time category, 
four arrows are shown explicitly - the numbers 0, 1, 1.5, and 2. The equality with addition shows how composition is defined in the category. There are of course infinitely many arrows in the time category, since there are infinitely many non-negative real numbers. Notice a curious contrast: in the time category, numbers are arrows, whereas in the category of natural numbers considered in the second lecture, numbers were objects/vertices of the category.

Let us now turn to the second category required to describe a dynamical system categorically. The category of sets is nothing other than a natural extension of the category of natural numbers discussed in detail in the second lecture. Instead of the natural numbers, let us now consider arbitrary sets as objects of the category, and not just the finite sets. The arrows are defined, as in the case of the category of natural numbers, to be functions between sets, with composition of arrows given by composition of functions. Both axioms of a category would be fulfilled for this directed graph with composition, for similar reasons that they were fulfilled for the category of natural numbers. 

Side remark: As it was shown more than a hundred years ago, set theory can be used as a foundation for all of mathematics. This means, in some very precise sense (elaboration of which is beyond the scope of these lectures), that the category of sets holds within it all of the mathematically describable universe! In short: the category of sets is a VERY IMPORTANT category.

3.2. The Notion of a Functor

It is a habit of mathematics that as soon as two different mathematical structures of the same type are being considered, one ends up investigating some sort of structure-preserving mappings (functions) between them. Well, in some sense, this is how category theory naturally emerges in basically any area of abstract mathematics: mathematical structures of the same type along with structure-preserving mappings between them usually form a category. But categories are themselves mathematical structures! And there is, in this case too, a notion of a structure-preserving mapping between categories - it is called a functor. We will now give a general definition of a functor and then illustrate this definition by showing that a dynamical system is nothing other than a functor from the time category to the category of sets.

Given two categories, let us refer to them as the left-hand side category (LHS category) and the right-hand side category (RHS category), a functor from the LHS category to the RHS category maps objects and arrows of the LHS category to objects and arrows, respectively, of the RHS category, in such a way that the following axioms are fulfilled. Firstly, this mapping should preserve source and target of arrows. Say for instance we have an arrow "f" in the LHS category with source "A" and target "B". Then the functor should map this arrow to an arrow in the RHS category whose source is the effect of the functor on the object "A" and whose target is the effect of the functor on the object "B". To describe this principle better, let F(A) denote the object in the RHS category to which A is mapped by the functor (where F is the name of the functor in question); let F(B) denote the object in the RHS category to which B is mapped by the functor; finally, let F(f) denote the arrow in the RHS category to which the arrow "f" is mapped by the functor. Then, the first functor axiom requires that the source of F(f) is F(A) and the target of F(f) is F(B). And this must be true for all objects "A", "B" and every single arrow "f" with source "A" and target "B" (in the LHS category). Thus, after applying the functor, the left-hand side picture below should always result in the right-hand side picture.
A category is more than just the information of what are sources and targets of the arrows. This information alone only describes the directed graph portion of a category. A category also has composition, and we must not forget either about the existence of the special looping arrows. A functor needs to preserve both of these pieces of data too. The two equalities below summarize these principles:
The second axiom for a functor states that the first of the two equalities above must always hold, whenever the arrows "g" and "f" are composable, of course. Notice that since a functor must preserve source and target of arrows, if "g" and "f" are composable then so will be F(g) and F(f). Here is an illustration for this:
The LHS and the RHS categories are illustrated here by the two bags, on the left and on the right, respectively. The functor F is shown as an arrow between those bags. The mappings given by the three arrows that move across the bags describes the effect of the functor F on objects. Observing that the "g" and the "f" on the left are composable (i.e., the target of "f" matches with the source of "g"), as well as that F preserves sources and targets of arrows, we notice on the right that F(g) and F(f) are composable too. Preservation of composition by the functor means that the effect of F on the composite of "g" and "f" must equal to the composite of the effects of F on "g" and "f" -- this precisely what the first of the two equalities displayed above expresses. The second of these equalities states nothing other than that the special arrows from the LHS category must map to the special arrows in the RHS category. This is the third functor axiom. 

Thus, a functor is a mapping of objects and arrows between categories that: (i) preserves sources and targets of arrows; (ii) preserves composition of arrows; (iii) preserves the special arrows.

Let us now see what happens if we specialize the definition of a functor to the case where the LHS category is the time category and the RHS category is the category of sets: that is, let us describe what are functors from the time category to the category of sets. The time category has only one object, so the effect of the functor on objects is completely determined by specifying a single object in the category of sets -- that is, a sing set. We can think of this set as the set "X" of states. Since all arrows in the time category are loops of its unique object, preservation of the source and the target means that these arrows will be mapped by the functor to functions from the set "X" to itself. Each of these functions F(t) will then correspond to what in a dynamical system we denoted by "f" subscript "t". Since composition in the time category is given by addition of numbers, preservation of composition by F becomes the law
which, rewritten in the subscript notation, is nothing other than its second axiom. The first axiom of the dynamical system, which in the language of the functor notation says that F(0) must transition any state to itself, can be written as nothing other than the second functor axiom
where "A" denotes the unique object of the time category. Indeed, the left-hand side of the equality above is precisely F(0) (recall that 0 is the special arrow of the time category), whereas the right-hand side is the special arrow of the object F(A)=X in the category of sets: recall that in this category, the special arrows are the identity functions, i.e., functions which map each member "x" to the same "x". So the equality above is another way of saying that 0 time laps retains the system that was in state "x", in the same state "x". 

Putting all of the above together we get that a functor from the time category to the category of sets is, up to change of notation, the same as a dynamical system. We should remark that in dynamical systems that arise in practice, the set "X" of states may have some additional mathematical structure, and the transition functions F(t) would then be required to preserve (at least some of) that structure. These situations can still be modeled using the notion of a functor: we would then consider a functor from the time category to a suitable category of those mathematical structures that have the same type as the structure that the set "X" of states is endowed with.

3.3. Some Forgetful Functors

If categories abound in mathematics (and they certainly do), then functors abound even more. Dynamical systems provide only one, very very special type of functors. Another type of functors is given by so-called forgetful functors. These are functors between two categories of two different types of mathematical structures, where one of the two structures is richer structure (has more data) than another, and the functor "forgets" that richer structure. An excellent of example of such functor is given by the forgetful functor from the category of vector spaces to the category of groups. Before describing this functor, let us first say a few words about these two categories.

Note: in what follows, we assume that the reader is well familiar with the notions of a vector space and of a group. If, however, you are not too familiar with these notions, it should nevertheless be possible to gain some insight about forgetful functors. Let us know in the comments if you need any help unpacking what you will read below.

Objects in the category of vector spaces are vector spaces (say, for instance, over the field of real numbers). Arrows are linear maps (aka linear transformations) between vector spaces. Composition of arrows is given by the usual composition of linear maps, which is defined basically the same way as composition of functions. In fact, a linear map between two vector spaces is nothing other than a function mapping points of one vector space to points of the other vector space -- but not an arbitrary function: the function must preserve linear combinations. To ensure that composition is well defined in the category of vector spaces we just need to check that the composite of two linear maps itself ends up being a linear map. This is of course true: it is in fact one of the fundamental (but simple) facts about linear maps. The special arrows in this category are given by the identity functions: the functions that map a point in a vector space to itself. Such functions indeed preserve linear combinations, so they are linear maps (hence, they are indeed arrows in our category of vector spaces). Thus, the category of vector spaces is given by vector spaces as objects, linear maps as arrows and the usual composition of linear maps as the composition of the category. 

The fact that linear maps between vector spaces are defined as special types of functions between the underlying sets of points of the vector spaces can be exhibited as a functor. This functor will be a functor from the category of vector spaces to the category of sets. It will map every vector space to the set of its points, and every linear map, to the same function now seen merely as a function between sets. Preservation of sources and targets of arrows is then immediate. Preservation of composition comes out trivially from how composition of linear maps was defined in the first place. Even special arrows are preserved: the special arrow of the vector space was defined as the identity function of the underlying set of points, but identity functions are precisely what special arrows are in the category of sets. The functor from the category of vector spaces to the category of sets that we get is an example of a "forgetful functor". In this case, we are "forgetting" the entire structure of a vector space and leaving only the set of its points. 

The forgetful functor we set out to describe, however, was not this one. Addition of points (vectors) in a vector space gives rise to an (additive) group. Recall that a vector space has an extra structure -- scalar multiplication. If we forget only the scalar multiplication, rather than the entire structure of the vector space, then we will land not in the category of sets, but in the category of groups. Objects in this category are groups, while arrows are group homomorphisms. Composition is the usual composition of group homomorphisms, and so on -- similar story here as with the description of the category of vector spaces! So we have a forgetful functor from the category of vector spaces to the category of groups. 

We also have a forgetful functor from the category of groups to the category of sets! Again, it is described similarly as the forgetful functor from the category of vector spaces to the category of sets: the functor is given by forgetting the group structure of a group and retaining just the underlying set of the group.  

Now... functors can be composed too! This is a story for some other time, but let us at least mention that the composite of the forgetful functor from the category of vector spaces to the category of groups with the forgetful functor from the category of groups to the category of sets results in nothing other than the initially considered forgetful functor from the category of vector spaces to the category of sets:
This composition law has an intuitive demonstration: if we forget first the scalar multiplication (so follow the forgetful functor F' from the picture) and then the vector addition (follow afterwards the forgetful functor F''), it is the same as if we, in one go, forget about both the scalar multiplication and the vector addition simultaneously (i.e., follow the forgetful functor F).

Dynamical systems and forgetful functors are two special types of functors. There are many more types. Exploration of some others are left as exercises.

3.4. Conclusion

There are two things one can do with categories: work inside them, or establish relations (functors) between them. An example of working inside a category was given in the second lecture, where we defined a notion of product of two objects inside a category and saw how it conceptualizes arithmetic in a category-theoretic language. In this lecture we saw how relating two categories conceptualizes dynamical systems in a category-theoretic language. We also saw how functors, used in this conceptualization, may have other examples of completely different nature: e.g., the forgetful functors. This shows once again a feature of category theory -- abstracting from one concrete situation, we arrive at notions that are applicable widely in other, entirely different situations. This phenomenon is similar to how in the second lecture, the notion of a product, abstracted from multiplication of natural numbers, turned out to give addition of natural numbers as an entirely different type of example. 

The power of the category-theoretic language is precisely this: it allows abstraction of ideas in such a way that they become immediately applicable in a range of other scenarios, entirely different from the original one.

Side remark: The product of two vector spaces (seen as objects in the category of vector spaces) is given by the cartesian product of vector spaces. In fact, in the category of vector spaces, product of two vector spaces gives remarkably the same object as their coproduct (can you imagine arithmetic where addition and multiplication are the same thing?). This phenomenon is somewhat manifested in the well known fact that when we take cartesian product of vector spaces, the dimensions add: the dimension of the cartesian product of two vector spaces is equal to the sum of the dimensions of those vector spaces.

3.5. Exercises

Exercise 1. Come up with a notion of a structure-preserving map between dynamical systems, in a way to enable formation of the category of dynamical systems and of a forgetful functor from this category to the category of sets.

Note: the rest of the exercises require familiarity with the mathematical notion of a vector space.

Exercise 2. In the video lecture, it was claimed (41:18 to 42:00) that scalar multiplication turns a vector space into a dynamical system. This is actually, not quite true. There are two problems. Firstly, scalar multiplication makes use of all real numbers and not only the non-negative ones. Secondly, both axioms of a dynamical system fail! However, it is possible to "fix" this erroneous claim, by considering only the non-negative real numbers and defining F(t) to map a vector "v" not to the scalar product "tv", but to the scalar product "exp(t)v". Check that we then indeed get a dynamical system. Note that there is also a more general notion of a dynamical system where instead of the time category we could have any category having a single object. With this more general notion, the claim made in the lecture is no longer invalid.

Exercise 3. Consider a vector space as a category where objects are points in the space and arrows are "vectors" connecting the points. So there will be exactly one arrow between any two objects (composition will then be forced to be defined in a unique way). Map each point to a vector space with the same underlying set as the original vector space, but where the zero vector is the selected point. Show that this gives a functor from the given vector space seen as a category, to the category of vector spaces, by describing to which linear maps are the arrows mapped and checking that the functor axioms hold. This exercise is inspired by the discussion from 54:55 to 1:04:40 of the video lecture -- the example of a functor partially described in this discussion actually works, even though we were not quite able to make it work during the discussion. See the video below for a sketch of the solution of this exercise.



Exercise 4. The category of matrices is defined as follows. Objects are natural numbers. Arrows from a natural number "n" to a natural number "m" are m by n matrices. Composition of arrows is given by multiplication of matrices. Verify that this is indeed a category and then construct a functor from this category to the category of vector spaces, by mapping natural number "n" to the n-dimensional vector space
where the blackboard bold R represents the field of real numbers, and by mapping each matrix to a linear map that this matrix describes. Do not forget to verity that all three functor axioms will hold. This exercise is based on the discussion from 1:05:40 to 1:07:45 of the lecture.

Exercise 5. Construct a functor from the category of natural numbers to the category of vector spaces, which acts on objects in a similar way as the functor described in Exercise 4. Generalize this idea to get a functor from the category of sets to the category of vector spaces. This would answer the question asked at 51:14 in the video lecture.

Comments

Popular posts from this blog

Lecture 1: Categories

Lecture 4: Natural Transformations

Lecture 2: Products