mirror of
https://github.com/boris-marinov/category-theory-illustrated.git
synced 2024-09-11 18:47:37 +03:00
02
This commit is contained in:
parent
456b3970c7
commit
4a81c061df
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
*.swp
|
||||
*.un~
|
@ -14,8 +14,6 @@ Set theory and category theory are different. They are not created for to provid
|
||||
|
||||
People have tried to be precise and at the same time down to Earth for centuries, and only recently discovered that "precise and down to Earth" is an oxymoron. Let's take Euclidian geometry as an example. Yes, Euclidian geometry is precise, because it is valid for all sets of objects, called ("point" "line" "angle" and "circle" etc.), which have relationships, as defined by the five famous axioms. Yes, geometry does, in many instances, describe the natural world, because there are many sets of objects which have these relations. However, its "precise" part and it's "down to Earth" part have nothing to do with each other. We can, for example, define a point as any stain on the floor of your room and that a line as a piece of duct tape, put on the same floor - that will be a completely valid application of the Euclidian laws, albeit not very useful one. Or we can try to use geometry to reason about points on the surface of the Earth, which is a very useful application, of geometry, however not of Euclidian geometry, because Euclidian geometry only describes points on a flat plane, and the Earth is not flat. You can argue that these are actually two separate theories there, which just happen to be perceived as one. You have the axioms, or the postulates on one hand, which are not useful for anything on their own, and you have applications in science and engineering which are somewhat based on them, but not quite.
|
||||
|
||||
What Category Theory aims, is to formalise some common concepts that we use in our daily (intellectual) lives in the same way that grammar textbooks formalise the language that we use in our daily lives - a language that does not follow any rules on its own.
|
||||
|
||||
Sets
|
||||
===
|
||||
|
||||
@ -52,7 +50,7 @@ The set of all *red balls* contains just one ball.
|
||||
|
||||
![The singleton set of red balls](singleton.svg)
|
||||
|
||||
Like we said above, sets are all about for summarising *several* elements into one. Still, sets that contain just one element are perfectly valid. Simply, there are things which are one of a kind. Furthermore, if I have a function which expects a set of given items, here shouldn't be any issue if the "items" are just one item. Or to take a real-life example, the set of queens of England is a singleton set. The set of books written by the American writer Harper Lee were a singleton - she has written just one novel, until 2015.
|
||||
Like we said above, sets are all about for summarising *several* elements into one. Still, sets that contain just one element are perfectly valid. Simply, there are things which are one of a kind. Furthermore, if I have a function which expects a set of given items, here shouldn't be any issue if the "items" are just one item. Or to take a real-life example, the set of queens of England is a singleton set. The set of books written by the American writer Harper Lee and published during her lifetime is a singleton set - she has published just one novel.
|
||||
|
||||
The Empty set
|
||||
---
|
||||
@ -265,7 +263,7 @@ More formally, two sets **R** and **G** are isomorphic, or **R ≅ G** if there
|
||||
Isomorphism and equality
|
||||
---
|
||||
|
||||
The concept of an isomorphism is strongly related to the concept of equality (that is why it is denoted with **≅**, which is almost the same as **=**).
|
||||
In category theory, the concept of an isomorphism is strongly related to the concept of equality (that is why it is denoted with **≅**, which is almost the same as **=**). This is also related to programming, where if we have a function that convert our object of type A to an object of type B and the other way around we pretty much regard A and B as two formats of the same object.
|
||||
|
||||
For example, we all know that everything is equal to itself. Well, if you look closely you would see that the identity function is reversible (its reverse is itself), so each set is also isomorphic to itself.
|
||||
|
||||
|
Binary file not shown.
@ -168,67 +168,69 @@ Do note how the world "Object" is used in both programming languages and in cate
|
||||
Limits
|
||||
===
|
||||
|
||||
Products are one example of what is known in category theory as *limits*. A limit is an object that summarizes a structure (also called a diagram) consisting of other objects and morphisms in a way that allows us to later retrieve some of it.
|
||||
|
||||
A limit also has to be unique in the sense that you cannot have two limit objects for the same structure.
|
||||
|
||||
Limits also are defined so that the diagram commutes.
|
||||
|
||||
Limits can be defined formally, just like everything else that we examine, but we won't bother to do that.
|
||||
|
||||
Products are Limits
|
||||
---
|
||||
Products are one example of limits.
|
||||
|
||||
A limit is an object that encodes a structure (also called a diagram) of other objects and morphisms in a way that allows us to later retrieve the structure. A limit also has to be unique in the sense that you cannot have two limit objects for the same structure.
|
||||
|
||||
What is the "structure" that a product is encoding? It is a structure that consists of two objects (sets) that are have no connections between them.
|
||||
OK, we said that limits summarize a structure. What is the structure that a product is summarizing? It is a structure that consists of two objects (sets) that are have no connections between them.
|
||||
|
||||
![External diagram](product_part_external.svg)
|
||||
|
||||
How do we retrieve the original objects given their product? By following the morphisms (functions) from it to any of them. Why is the product unique when it comes to representing the two objects? Because any other object that represents them is connected to the product.
|
||||
By following the morphisms (functions) from the limit object, we can retrieve its components.
|
||||
|
||||
We will see that all other limits are defined in roughly the same way.
|
||||
Why is the product unique when it comes to representing the two objects? Because any other object that also represents them is connected to the product through a morphism (this is known as the *universal property* of limits).
|
||||
|
||||
Pullbacks
|
||||
---
|
||||
Imagine a diagram consisting of two objects that are both connected to a third one:
|
||||
|
||||
![External diagram](pullback_part_external.svg)
|
||||
Imagine a diagram consisting of two objects that are both connected to a third one or of two sets that both have functions to a third one.
|
||||
|
||||
Or two sets that both have functions to a third one.
|
||||
|
||||
![Internal diagram](pullback_part_internal.svg)
|
||||
![External diagram](pullback_part_external_internal.svg)
|
||||
|
||||
This diagram can expresses two unrelated facts, for example let's take a function from men to people and from parents are people, connecting each person from the set of parents to the same person from the set of all people.
|
||||
|
||||
![Internal diagram](pullback_part_internal_father.svg)
|
||||
|
||||
Because there are so many types of functions, I feel that I have to offer another example. Think of how recruiting (or "tallent aquisition" as they call it) works. There are companies that post job descriptions of the market and people who fit one or several of the job descriptions posted. This process can be summarised in the same type of diagram:
|
||||
Because there are so many types of functions, I feel that I have to offer another example: Think of how recruiting (or "talent aquisition" as it is also called) works. There are companies that post job descriptions of the market and people who fit one or several of the job descriptions posted. This process can be summarised in the same type of diagram:
|
||||
|
||||
![Internal diagram](pullback_part_internal_recruit.svg)
|
||||
|
||||
The limit to this diagram, as we said is an object for which is connected to the three objects in it.
|
||||
The limit to a diagram, as we said, is an object for which is connected to the three objects in it.
|
||||
|
||||
![External diagram of a pullback](pullback_external_extra_morphism.svg)
|
||||
|
||||
The connection to the third object is just the composition of the other two so it will always exist as long as they exist - we might as well remove it.
|
||||
In this case the connection to the third object is just the composition of the other two so it exists by definition (as long as they exist).
|
||||
|
||||
![External diagram of a pullback](pullback_external.svg)
|
||||
|
||||
Like with the product, we define the limit to be such, that any object that is connected to the tree objects in the diagram - is also connected to the limit.
|
||||
Like with the product, we define the limit to be such, that any object that is connected to the three objects in the diagram is also connected to the limit object.
|
||||
|
||||
![External diagram of a pullback](pullback_candidates.svg)
|
||||
|
||||
In the category of sets, a pullback is called a *fiber product*.
|
||||
In the category of sets, a the object (set) that fits this description for any objects A and B is called their *fiber product*.
|
||||
|
||||
![Internal diagram of the pullback](pullback_internal.svg)
|
||||
|
||||
It is like the ordinary product, except that it contains just the pairs which satisfy the condition given by the two functions.
|
||||
It is like the ordinary product of A and B, except that it does not contain all pairs but just the ones which satisfy the condition given by the two functions.
|
||||
|
||||
![Internal diagram of the pullback](pullback_product_internal.svg)
|
||||
|
||||
The concept might look abstract and detached from reality, but it is exactly the opposite. The pullback summarizes the two ideas into one in a way that is very intuitive. For example the pullback of the sets of men to people and the sets of parents to people, is the set of all fathers.
|
||||
The concept might look abstract and detached from reality, but it is actually exactly the opposite. The pullbacks summarize two ideas into one in a way that is very intuitive. For example the pullback of the sets of men to people and the sets of parents to people, is the set of all fathers.
|
||||
|
||||
![Internal diagram of the pullback](pullback_internal_father.svg)
|
||||
|
||||
Well, technically it is the set of pairs of objects where both objects are the same object, but let's concentrate on the big picture.
|
||||
Well, technically it is the set of *pairs* of objects where both objects in the set are actually the same object, but let's concentrate on the big picture for now. And with category theory we can do so without being technically incorrect - a set of pairs where both objects are actually the same object is isomorphic to the set containing just the objects. So we can use the simpler label in our external diagram.
|
||||
|
||||
![Internal diagram of the pullback](pullback_external_father.svg)
|
||||
|
||||
(Note that we can simplify the label as the two sets are isomorphic).
|
||||
|
||||
Task: Definine the two functions that constitute the isomorphism between those two sets.
|
||||
|
||||
The pullback of the diagram with the job descriptions is the sets of all matches - pairs that contain one person and one description where the person fits the descripton.
|
||||
|
||||
@ -236,10 +238,18 @@ The pullback of the diagram with the job descriptions is the sets of all matches
|
||||
|
||||
Task: Draw an internal diagram for the second example.
|
||||
|
||||
Task: A pullback is like a product. In fact if a certain sets from the diagram which a pullback summarizes is isomorphic to a certain set which we covered in the first chapter, the pullback becomes equivalent to a product. Find that set.
|
||||
|
||||
Pullback with the Singleton set.
|
||||
Equalizers
|
||||
---
|
||||
|
||||
When working with external diagrams, we should not forget that just because two functions come and go from the same sets, that does not mean that they are the same. To remind us that, let's examine the diagram consisting of two objects that are connected with each other in two ways.
|
||||
|
||||
![External diagram of a equalizer](equalizer_external.svg)
|
||||
|
||||
You can view the diagram as just two functions with the same type signature.
|
||||
|
||||
Like with
|
||||
|
||||
|
||||
|
||||
@ -250,8 +260,12 @@ Pullback with the Singleton set.
|
||||
|
||||
|
||||
|
||||
Equivalence relations
|
||||
---
|
||||
|
||||
What is equality? We might have a long theoretical discussion about this question. Or we can define it rigorously using category theory (I hope you prefer the latter).
|
||||
|
||||
Some other categories
|
||||
===
|
||||
|
||||
A: Every theory in formal logic, as well as of mathematics can be represented as a directed graph, with `True` and `False` at its center. and `True` follows *from* everything and everything follows from `False`.
|
||||
|
@ -2,3 +2,5 @@ This book is a product of my own endeavour of understanding category theory from
|
||||
|
||||
It is aimed at programmers, as well as anyone else who is interested in this stuff. I am writing it as I learn.
|
||||
|
||||
The main reason I am interested in Category Theory is that it allows us to formalise some common concepts that we use in our daily (intellectual) lives. Much of our language is based on intuition and rightfully so: relying on intuition is a very easy way to get your point across so it is understood by other human beings. However, that is part of the problem: sometimes intuition makes it too easy to communicate with someone. So easy that he might, in fact, understand things that you haven't actually said. For example, when I say that two things are equal, it would seem obvious to you what I mean, although it isn't obvious at all (how are they equal, at what context etc). That is the place when we might want to provide a more rigorous definition of what am I saying (even if I did not have one, to begin with). But providing such definition in natural language, which is designed to use intuition as a means of communication, is no easy task. It is in these situations that people often resort to *diagrams* to explain their thoughts. Diagrams are ubiquitous in science and mathematics because they are an understandable way to communicate a formal concept clearly. Category theory formalises the concept of a diagram and their components - arrows and objects and creates *a* language for presenting all kinds of ideas.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user