mirror of
https://github.com/abuseofnotation/category-theory-illustrated.git
synced 2024-09-11 08:55:55 +03:00
stuff
This commit is contained in:
parent
5e2bbcd12d
commit
cee222b8ac
@ -30,13 +30,13 @@ A few years after that some people found my notes and encouraged me write more.
|
||||
On math
|
||||
===
|
||||
|
||||
Ever since Newton's Principia, the discipline of mathematics is viewed in the somewhat demeaning position of "science and engineering's workhorse" — only "useful" as a means for helping scientists and engineers to make technological and scientific advancements, i.e., it is viewed as just a tool for solving "practical" problems.
|
||||
Ever since Newton's Principia, the discipline of mathematics is viewed in the somewhat demeaning position of "science and engineering's workhorse" --- only "useful" as a means for helping scientists and engineers to make technological and scientific advancements, i.e., it is viewed as just a tool for solving "practical" problems.
|
||||
|
||||
Because of this, mathematicians are in a weird and, I'd say, unique position of always having to defend what they do with respect to its value for *other disciplines*. I again stress that this is something that would be considered absurd when it comes to any other discipline.
|
||||
|
||||
People don't expect any return on investment from *physical theories*, e.g., no one bashes a physical theory for having no utilitarian value.
|
||||
|
||||
And bashing philosophical theories for being impractical would be even more absurd. imagine bashing Wittgenstein:
|
||||
And bashing philosophical theories for being impractical would be even more absurd --- imagine bashing Wittgenstein, for example:
|
||||
|
||||
> "All too well, but what can you do with the picture theory of language?"
|
||||
> "Well, I am told it does have its applications is programming language theory..."
|
||||
@ -45,18 +45,18 @@ Or someone being sceptical to David Hume's scepticism:
|
||||
|
||||
> "That's all fine and dandy, but your theory leaves us at square one in terms of our knowledge. What the hell are we expected to do from there?"
|
||||
|
||||
Although many people don't necessarily subscribe to this view of mathematics as a workhorse, we can see it encoded inside the structure of most mathematics textbooks — each chapter starts with an explanation of a concept, followed by some examples, and then ends with a list of problems that this concept solves.
|
||||
Although many people don't necessarily subscribe to this view of mathematics as a workhorse, we can see it encoded inside the structure of most mathematics textbooks --- each chapter starts with an explanation of a concept, followed by some examples, and then ends with a list of problems that this concept solves.
|
||||
|
||||
There is nothing wrong with this approach, but mathematics is so much more than solving problems. It was the basis of a religious cult in ancient Greece (the Pythagoreans), it was seen by philosophers as means to understanding the laws which govern the universe. It was, and still is, a language which can allow for people with different cultural backgrounds to understand each other. And it is also art and a means of entertainment.
|
||||
|
||||
Category theory embodies all these aspects of mathematics, so I think a very good grounds to writing a book where all of them shine — a book that is based not on solving of problems, but on exploration of concepts and on seeking connections between them. A book that is, overall, pretty.
|
||||
Category theory embodies all these aspects of mathematics, so I think a very good grounds to writing a book where all of them shine --- a book that is based not on solving of problems, but on exploration of concepts and on seeking connections between them. A book that is, overall, pretty.
|
||||
|
||||
Who is this book for
|
||||
====
|
||||
|
||||
So, who is this book for? If we rephrase this question as "Who *should* read this book", then the answer is nobody. Indeed, if you think in terms of "should", mathematics (or at least the type of mathematics that is reviewed here) won't help you much, although it is falsely advertised as a solution to many problems.
|
||||
|
||||
Let's take an example — many people claim that Einstein's theories of relativity are essential for GPS to work properly. Due to relativistic effects the clocks on GPS satellites tick faster than identical clocks on the ground.
|
||||
Let's take an example --- many people claim that Einstein's theories of relativity are essential for GPS to work properly, as, due to relativistic effects, the clocks on GPS satellites tick faster than identical clocks on the ground.
|
||||
|
||||
They seem to think that if the theory didn't exist the engineers that developed the GPS would have faced this phenomenon in the following way:
|
||||
|
||||
@ -91,7 +91,7 @@ The way we think and talk is based on intuition that develops naturally and is a
|
||||
|
||||
It is in these situations that people often resort to *diagrams* to refine their thoughts. Diagrams (even more than formulas) are ubiquitous in science and mathematics.
|
||||
|
||||
Category theory formalizes the concept of diagrams and their components — arrows and objects — and creates a language for presenting all kinds of ideas. In this sense, category theory is a way to unify knowledge, both mathematical and scientific, and to unite various modes of thinking with common terms.
|
||||
Category theory formalizes the concept of diagrams and their components --- arrows and objects --- and creates a language for presenting all kinds of ideas. In this sense, category theory is a way to unify knowledge, both mathematical and scientific, and to unite various modes of thinking with common terms.
|
||||
|
||||
As a consequence of that, category theory and diagrams are also a very understandable way to communicate a formal concept clearly, something I hope to demonstrate in the following pages.
|
||||
|
||||
@ -108,7 +108,7 @@ In the next two chapters, 3 and 4, we jump to two different branches of mathemat
|
||||
|
||||
Chapter 5 also follows the main formula of the previous two chapters, and gets to the heart of the matter of why category theory is a universal language, by showing its connection with the ancient discipline of *logic*. As in chapters 3 and 4 we start with a crash course in logic itself.
|
||||
|
||||
The connection between all these different disciplines is examined in chapter 6, using one of the most interesting category-theoretical concepts — the concept of a functor.
|
||||
The connection between all these different disciplines is examined in chapter 6, using one of the most interesting category-theoretical concepts --- the concept of a functor.
|
||||
|
||||
In chapter 7 we review another more interesting and more advanced categorical concept, the concept of a *natural transformation*.
|
||||
|
||||
@ -123,4 +123,4 @@ Thanks to my high-school arts teacher, Mrs Georgieva who told me that I have som
|
||||
|
||||
Thanks to Prathyush Pramod who encouraged me to finish the book and is also helping me out with it.
|
||||
|
||||
And also to everyone else who submitted feedback and helped me fix some of the numerous errors that I made — knowing myself, I know that there are more.
|
||||
And also to everyone else who submitted feedback and helped me fix some of the numerous errors that I made --- knowing myself, I know that there are more.
|
||||
|
@ -242,7 +242,7 @@ In purely functional programming languages, such operations are outsourced to th
|
||||
|
||||
{% if site.distribution == 'print'%}
|
||||
|
||||
Interlude - type theory
|
||||
Interlude --- type theory
|
||||
===
|
||||
|
||||
Type theory and set theory are related in that type theory can be seen as a more restrictive version of set theory. In set theory you have only one kind of object that is (you guessed it) — set, and a set can contain anything, including other sets. In type theory, you generally have two concepts — types and values.
|
||||
@ -268,7 +268,7 @@ If we look at the definition, we recognize that the set that we just defined doe
|
||||
|
||||
![Russel's paradox - option one](../01_set/russells_paradox_2.svg)
|
||||
|
||||
Hmm, something is not quite right with this diagram as well - because of the new adjustments that we made, our set now *contains itself*. And removing it from the set would just bring us back to the previous situation. So this is Russell's paradox.
|
||||
Hmm, something is not quite right with this diagram as well --- because of the new adjustments that we made, our set now *contains itself*. And removing it from the set would just bring us back to the previous situation. So this is Russell's paradox.
|
||||
|
||||
From set theory to type theory
|
||||
---
|
||||
@ -489,10 +489,10 @@ The practice of using isomorphisms to define an equivalence relation is very pro
|
||||
|
||||
{% if site.distribution == 'print'%}
|
||||
|
||||
Interlude - numbers as isomorphisms
|
||||
Interlude --- numbers as isomorphisms
|
||||
===
|
||||
|
||||
Many people would say that the concept of a number is the most basic concept in mathematics. But actually they are wrong - *sets and isomorphisms are more basic*! Or at least, numbers can be defined using sets and isomorphisms.
|
||||
Many people would say that the concept of a number is the most basic concept in mathematics. But actually they are wrong --- *sets and isomorphisms are more basic*! Or at least, numbers can be defined using sets and isomorphisms.
|
||||
|
||||
To understand how, let's think about how you teach a person what a number is (in particular, here we will concentrate on the *natural*, or counting numbers). You may start your lesson by showing them a bunch of objects that are of a given quantity, like for example if you want to demonstrate the number $2$, you might bring them like two pencils, two apples or two of something else.
|
||||
|
||||
|
@ -27,7 +27,7 @@ It is denoted $B \times Y$ and it comes equipped with two functions for retrievi
|
||||
|
||||
{% if site.distribution == 'print'%}
|
||||
|
||||
Interlude - coordinate systems
|
||||
Interlude --- coordinate systems
|
||||
---
|
||||
|
||||
The concept of the Cartesian product was first defined by the mathematician and philosopher René Descartes as a basis for the *Cartesian coordinate system*. Although it does not look like it, both concepts are named after him (or after the Latinized version of his name).
|
||||
@ -52,7 +52,7 @@ So we can say that the Cartesian coordinate system is some kind of function-like
|
||||
|
||||
What's even more interesting is that this mapping is one-to-one, which makes the two realms *isomorphic* (traditionally we say that the point is *completely* described by the coordinates, which is the same thing).
|
||||
|
||||
Our effort to represent Cartesian coordinates with sets is satisfactory, but incomplete, as we still don't know what these function-like things that connect points to numbers are - they make intuitive sense as functions, and that they exhibit all relevant properties (many-to-one mapping, or one-to-one in this case), however, we have only covered functions as mappings between sets and in this case, even if we can think of the coordinate system as a set (of points and figures), geometrical figures are definitely not a set, as it has a lot of additional things going on (or additional *structure*, as a category theorist would say).
|
||||
Our effort to represent Cartesian coordinates with sets is satisfactory, but incomplete, as we still don't know what these function-like things that connect points to numbers are --- they make intuitive sense as functions, and that they exhibit all relevant properties (many-to-one mapping, or one-to-one in this case), however, we have only covered functions as mappings between sets and in this case, even if we can think of the coordinate system as a set (of points and figures), geometrical figures are definitely not a set, as it has a lot of additional things going on (or additional *structure*, as a category theorist would say).
|
||||
|
||||
So defining this mapping formally, would require us to also formalize both geometry and algebra, and moreover to do so in a way in which they are compatible with one another. This is some of the ambitions of category theory and this is what we will attempt to do later in this book (even if not for this exact example).
|
||||
|
||||
@ -63,7 +63,7 @@ But before we continue with that, let's see some other neat uses of products.
|
||||
Products as Objects
|
||||
---
|
||||
|
||||
In the previous chapter we established the correspondence of various concepts in programming languages and set theory sets resemble types, functions resemble methods/subroutines. This picture is made complete with products, that are like stripped-down *classes* (also called *records* or *structs*) - the sets that form the product correspond to the class's *properties* (also called *members*) and the functions for accessing them are like what programmers call *getter methods*.
|
||||
In the previous chapter we established the correspondence of various concepts in programming languages and set theory sets resemble types, functions resemble methods/subroutines. This picture is made complete with products, that are like stripped-down *classes* (also called *records* or *structs*) --- the sets that form the product correspond to the class's *properties* (also called *members*) and the functions for accessing them are like what programmers call *getter methods*.
|
||||
|
||||
The famous example of object-oriented programming of a `Person` class with `name` and `age` fields is nothing more than a product of the set of strings, and the sets of numbers. Objects with more than two values can be expressed as products the composites of which are themselves products.
|
||||
|
||||
@ -102,9 +102,9 @@ Discovered in 1921 Kazimierz Kuratowski, this one uses just the component of the
|
||||
Defining products in terms of functions
|
||||
---
|
||||
|
||||
In the product definitions presented in the previous section worked by *zooming in* into the individual elements of the product and seeing what they can be made of. I call this the *low-level* approach. This time we will try to do the opposite - be as oblivious to the contents of our sets as possible i.e. instead of zooming in we will *zoom out*, and try to define the product in terms of functions and functional composition. Effectively we will be working at a *higher level* of abstraction.
|
||||
In the product definitions presented in the previous section worked by *zooming in* into the individual elements of the product and seeing what they can be made of. I call this the *low-level* approach. This time we will try to do the opposite --- be as oblivious to the contents of our sets as possible i.e. instead of zooming in we will *zoom out*, and try to define the product in terms of functions and functional composition. Effectively we will be working at a *higher level* of abstraction.
|
||||
|
||||
How can we define products in terms of functions? To do that, we must first think about *what functions* are there for a given product, and we have two of those - the functions for retrieving the two elements of the pair (the "getters", so to say) - formally, if we have a set $G$ which is the product of sets $Y$ and $B$, then we should also have functions which give us back the elements of the product, so $G → Y$ and $G → B$.
|
||||
How can we define products in terms of functions? To do that, we must first think about *what functions* are there for a given product, and we have two of those --- the functions for retrieving the two elements of the pair (the "getters", so to say). Formally, if we have a set $G$ which is the product of sets $Y$ and $B$, then we should also have functions which give us back the elements of the product, so $G → Y$ and $G → B$.
|
||||
|
||||
![Product, external diagram](../02_category/product_external.svg)
|
||||
|
||||
@ -124,12 +124,12 @@ Therefore, we can define the product of $B$ and $Y$ as a set that has functions
|
||||
|
||||
In category theory, this type of property that a given object might possess (participating in a structure such that all similar objects can be converted to/from it) is called a *universal property*. I don't want to go into more detail, as it is a bit early for that now (after all we haven't even defined what category theory is).
|
||||
|
||||
One thing that I like to point out is that this definition (as, by the way, all the previous ones) does not rule out the sets which are isomorphic to the product - when we represents things using universal properties, an isomorphism is the same as equality.
|
||||
One thing that I like to point out is that this definition (as, by the way, all the previous ones) does not rule out the sets which are isomorphic to the product --- when we represents things using universal properties, an isomorphism is the same as equality.
|
||||
|
||||
Sums
|
||||
===
|
||||
|
||||
We will now study a construct that is pretty similar to the product but at the same time is very different. Similar because, like the product, it is a relation between two sets which allows you to unite them into one, without erasing their structure. But different as it encodes a quite different type of relation - a product encodes an *and* relation between two sets, while the sum encodes an *or* relation.
|
||||
We will now study a construct that is pretty similar to the product but at the same time is very different. Similar because, like the product, it is a relation between two sets which allows you to unite them into one, without erasing their structure. But different as it encodes a quite different type of relation --- a product encodes an *and* relation between two sets, while the sum encodes an *or* relation.
|
||||
|
||||
The sum of two sets $B$ and $Y$, denoted $B + Y$ is a set that contains *all elements from the first set combined with all elements from the second one*.
|
||||
|
||||
@ -156,11 +156,11 @@ Defining sums in terms of functions
|
||||
|
||||
As you might already suspect, the interesting part is expressing the sum of two sets using functions. To do that we have to go back to the conceptual part of the definition. We said that sums express an *or* relation between two things.
|
||||
|
||||
A property of every *or* relation is that if something is an $A$ that something is also an $A \vee B$ , and same for $B$ (The $\vee$ symbol means *or* by the way). For example, if my hair is *brown*, then my hair is also *either blond or brown*. This is what *or* means, right? This property can be expressed as a function, two functions actually - one for each set that takes part in the sum relation (for example, if parents are either mothers or fathers, then there surely exist functions $mothers → parents$ and $fathers → parents$).
|
||||
A property of every *or* relation is that if something is an $A$ that something is also an $A \vee B$ , and same for $B$ (The $\vee$ symbol means *or* by the way). For example, if my hair is *brown*, then my hair is also *either blond or brown*. This is what *or* means, right? This property can be expressed as a function, two functions actually --- one for each set that takes part in the sum relation (for example, if parents are either mothers or fathers, then there surely exist functions $mothers → parents$ and $fathers → parents$).
|
||||
|
||||
![Coproduct, external diagram](../02_category/coproduct_external.svg)
|
||||
|
||||
As you might have already noticed, this definition is pretty similar to the definition of the product from the previous section. And the similarities don't end here. As with products, we have sets that can be thought of as *impostor* sums - ones for which these functions exist, but which also contain additional information.
|
||||
As you might have already noticed, this definition is pretty similar to the definition of the product from the previous section. And the similarities don't end here. As with products, we have sets that can be thought of as *impostor* sums --- ones for which these functions exist, but which also contain additional information.
|
||||
|
||||
![Coproduct, external diagram](../02_category/coproduct_candidates.svg)
|
||||
|
||||
@ -174,21 +174,21 @@ Categorical Duality
|
||||
|
||||
The concepts of product and sum might already look similar in a way when we view them through their internal diagrams, but once we zoom out to the external view, and we draw the two concepts external diagrams, this similarity is quickly made precise.
|
||||
|
||||
I use "diagrams" in plural, but actually the two concepts are captured *by one and the same diagram*, the only difference between the two being that their arrows are flipped - many-to-one relationships become one-to-many and the other way around.
|
||||
I use "diagrams" in plural, but actually the two concepts are captured *by one and the same diagram*, the only difference between the two being that their arrows are flipped --- many-to-one relationships become one-to-many and the other way around.
|
||||
|
||||
![Coproduct and product](../02_category/coproduct_product_duality.svg)
|
||||
|
||||
The universal properties that define the two construct are the same as well - if we have a sum $Y + B$, for each impostor sum, such as $Y + B + R$, there exist a trivial function $Y + B \to Y + B + R$.
|
||||
The universal properties that define the two construct are the same as well --- if we have a sum $Y + B$, for each impostor sum, such as $Y + B + R$, there exist a trivial function $Y + B \to Y + B + R$.
|
||||
|
||||
And, if you remember, with product the arrows go the other way around - the equivalent example for product would be the function $Y \times B \times R \to Y \times B $
|
||||
And, if you remember, with product the arrows go the other way around --- the equivalent example for product would be the function $Y \times B \times R \to Y \times B $
|
||||
|
||||
This fact uncovers a deep connection between the concepts of the *product* and *sum*, which is not otherwise apparent - they are each other's opposites - *product* is the opposite of *sum* and *sum* is the opposite of *product*.
|
||||
This fact uncovers a deep connection between the concepts of the *product* and *sum*, which is not otherwise apparent --- they are each other's opposites. *Product* is the opposite of *sum* and *sum* is the opposite of *product*.
|
||||
|
||||
In category theory, concepts that have such a relationship are said to be *dual* to each other. So the the concepts of *product* and *sum* are dual. This is why sum is known in a category-theoretic setting as *converse product*, or *coproduct* for short. This naming convention is used for all dual constructs in category theory.
|
||||
|
||||
{% if site.distribution == 'print'%}
|
||||
|
||||
Interlude - De Morgan duality
|
||||
Interlude --- De Morgan duality
|
||||
===
|
||||
|
||||
Now let's look at how the concepts of product and sum from the viewpoint of *logic*. We mentioned that:
|
||||
@ -200,9 +200,9 @@ When we view those sets as propositions, we discover the concept of the *product
|
||||
|
||||
By the same token, the concept of a *sum* ($+$) corresponds the *or* relation in logic (denoted $\lor$). From this viewpoint, the function $Y \to Y + B$ can be viewed as instance of a logical rule of inference called *disjunction introduction*, stating that, $Y \to Y \lor B$ for example, if your hair is blond, it is either blond or brown.
|
||||
|
||||
This means, among other things, that the concepts of *and* and *or* are also dual - an idea which was put forward in the 19th century by the mathematician Augustus De Morgan and is henceforth known as *De Morgan duality*, and which is a predecessor to the modern idea of duality in category theory, that we examined before.
|
||||
This means, among other things, that the concepts of *and* and *or* are also dual --- an idea which was put forward in the 19th century by the mathematician Augustus De Morgan and is henceforth known as *De Morgan duality*, and which is a predecessor to the modern idea of duality in category theory, that we examined before.
|
||||
|
||||
This duality is subtly encoded in the logical symbols for *and* and *or* ($\land$ and $\lor$) - they are nothing but stylized-versions of the diagrams of products and coproducts.
|
||||
This duality is subtly encoded in the logical symbols for *and* and *or* ($\land$ and $\lor$) --- they are nothing but stylized-versions of the diagrams of products and coproducts.
|
||||
|
||||
![Coproduct and product](../02_category/demorgan_duality.svg)
|
||||
|
||||
@ -226,11 +226,11 @@ $\neg{A} \vee \neg{B}$
|
||||
|
||||
However, this statement is clearly not the opposite of "blond *or* brown"(saying that my hair is not blond *or* not brown does in fact allow it to be blond and also allows for it to be brown, it just doesn't allow it to be both of these things).
|
||||
|
||||
So what have we missed? Simple - although we replaced the propositions that constitute our proposition with their opposites, we didn't replace the operator that connects them - it is still *or* for both propositions. So we must replace it with *or* converse. As we said earlier, and as you can see by analyzing this example, this operator is *and* So the formula becomes "not blond *and* not brown".
|
||||
So what have we missed? Simple: although we replaced the propositions that constitute our proposition with their opposites, we didn't replace the operator that connects them --- it is still *or* for both propositions. So we must replace it with *or* converse. As we said earlier, and as you can see by analyzing this example, this operator is *and* So the formula becomes "not blond *and* not brown".
|
||||
|
||||
$\neg{A} \wedge \neg{B}$
|
||||
|
||||
Saying that this formula is the opposite or "blond and brown" - is the same thing as saying that it is equivalent to its negation, which is precisely what the second De Morgan formula says.
|
||||
Saying that this formula is the opposite or "blond and brown" --- is the same thing as saying that it is equivalent to its negation, which is precisely what the second De Morgan formula says.
|
||||
|
||||
$\neg(A \vee B) = \neg{A} \wedge \neg{B}$
|
||||
|
||||
@ -242,16 +242,16 @@ This probably provokes a lot of questions, but I won't get into more detail here
|
||||
|
||||
{% endif %}
|
||||
|
||||
Category Theory - brief definition
|
||||
Category Theory --- brief definition
|
||||
===
|
||||
|
||||
Maybe it is about time to see what a category is. We will start with a short definition - a category consists of objects (an example of which are sets) and morphisms that go from one object to another (which can be viewed as functions) and that should be composable. We can say a lot more about categories, and even present a formal definition, but for now it is sufficient for you to remember that sets are one example of a category and that categorical objects are like sets, except that we don't *see* their elements. Or to put it another way, category-theoretic notions are captured by the external diagrams, while strictly set-theoretic notions can be captured by internal ones.
|
||||
Maybe it is about time to see what a category is. We will start with a short definition --- a category consists of objects (an example of which are sets) and morphisms that go from one object to another (which can be viewed as functions) and that should be composable. We can say a lot more about categories, and even present a formal definition, but for now it is sufficient for you to remember that sets are one example of a category and that categorical objects are like sets, except that we don't *see* their elements. Or to put it another way, category-theoretic notions are captured by the external diagrams, while strictly set-theoretic notions can be captured by internal ones.
|
||||
|
||||
![Category theory and set theory compared](../02_category/set_category.svg)
|
||||
|
||||
When we are at the realm of sets we can view the set as a collection of individual elements. In category theory we don't have such notion, but we saw how taking this notion away allows us to define concepts such as the sum and product sets in a whole different and more general way.
|
||||
|
||||
Still why would we want to restrict ourselves from looking at the individual elements? It is because, in this way we can relate this viewpoint to objects other than sets. We already discussed one such object - types in programming languages. Remember that we said that programming types (classes) are somewhat similar to sets, and programming methods are somewhat similar to functions between sets, but they are not exactly identical? A formal connection between the two can be made via category theory.
|
||||
Still why would we want to restrict ourselves from looking at the individual elements? It is because, in this way we can relate this viewpoint to objects other than sets. We already discussed one such object --- types in programming languages. Remember that we said that programming types (classes) are somewhat similar to sets, and programming methods are somewhat similar to functions between sets, but they are not exactly identical? A formal connection between the two can be made via category theory.
|
||||
|
||||
| Category Theory | Set theory | Programming Languages |
|
||||
| --- | --- | --- |
|
||||
@ -259,7 +259,7 @@ Still why would we want to restrict ourselves from looking at the individual ele
|
||||
| Objects and Morphisms | Sets and Functions | Classes and methods |
|
||||
| N/A | Element | Object |
|
||||
|
||||
Category theory allows us to see the big picture when it comes to sets and similar structures - looking at the table, we cannot help but notice the somehow weird, (but actually completely logical) symmetry (or perhaps "reverse symmetry") between the world as viewed through the lenses of set theory, and the way it is viewed through the lens of category theory:
|
||||
Category theory allows us to see the big picture when it comes to sets and similar structures --- looking at the table, we cannot help but notice the somehow weird, (but actually completely logical) symmetry (or perhaps "reverse symmetry") between the world as viewed through the lenses of set theory, and the way it is viewed through the lens of category theory:
|
||||
|
||||
| Category Theory | Set theory |
|
||||
| --- | --- |
|
||||
@ -276,16 +276,16 @@ Sets VS Categories
|
||||
|
||||
One remark before we go: in the last paragraphs I sound as if I'm *comparing* categories and sets (and rooting for categories, in order to get more copies of my book sold) and I don't want you to get the wrong impression that the two concepts are somehow competing with one another. Perhaps that notion would be somewhat correct if category and set theory were meant to describe *concrete* phenomena, in the way that the theory of relativity and the theory of quantum mechanics are both supposed to explain the physical world. Concrete theories are conceived mainly as *descriptions* of the world, and as such it makes sense for them to be connected to one another in some sort of hierarchy.
|
||||
|
||||
Abstract theories, like category theory and set theory, on the other hand, are more like *languages* for expressing such descriptions - they still can be connected, and *are* connected in more than one way, but there is no inherent hierarchy between the two and therefore arguing over which of the two is more basic, or more general, is just a chicken-and-egg problem, as you would see in the next chapter.
|
||||
Abstract theories, like category theory and set theory, on the other hand, are more like *languages* for expressing such descriptions --- they still can be connected, and *are* connected in more than one way, but there is no inherent hierarchy between the two and therefore arguing over which of the two is more basic, or more general, is just a chicken-and-egg problem, as you would see in the next chapter.
|
||||
|
||||
Defining Categories (again)
|
||||
===
|
||||
|
||||
> "...deal with all elements of a set by ignoring them and working with the set's definition." - Dijkstra
|
||||
> "...deal with all elements of a set by ignoring them and working with the set's definition." --- Dijkstra
|
||||
|
||||
All category theory books (including this one) starts by talking about set theory. However looking back I really don't know why that is the case - most books that focus around a given subject don't usually start off by introducing an *entirely different subject* before even starting to talk about the main one, even if the two subjects are so related.
|
||||
All category theory books (including this one) starts by talking about set theory. However looking back I really don't know why that is the case --- most books that focus around a given subject don't usually start off by introducing an *entirely different subject* before even starting to talk about the main one, even if the two subjects are so related.
|
||||
|
||||
Perhaps the set-first approach *is* the best way to introduce people to categories. Or perhaps using sets to introduce categories is just one of those things that people do because everyone else does it. But one thing is for certain - we don't need to study sets in order to understand categories. So now I would like to start over and talk about categories as a first concept. So pretend like this is a new book (I wonder if I can dedicate this to a different person).
|
||||
Perhaps the set-first approach *is* the best way to introduce people to categories. Or perhaps using sets to introduce categories is just one of those things that people do because everyone else does it. But one thing is for certain --- we don't *need* to study sets in order to understand categories. So now I would like to start over and talk about categories as a first concept. So pretend like this is a new book (I wonder if I can dedicate this to a different person).
|
||||
|
||||
So. A category is a collection of objects (things) where the "things" can be anything you want. Consider, for example, these ~~colorful~~ gray balls:
|
||||
|
||||
@ -295,7 +295,7 @@ A category consists of a collection of objects as well as some arrows connecting
|
||||
|
||||
![A category](../02_category/category.svg)
|
||||
|
||||
Wait a minute - we said that all sets form a category, but at the same time any one set can be seen as a category on its own right (just one which has no morphisms). This is true and an example of a phenomenon that is very characteristic of category theory - one structure can be examined from many different angles and may play many different roles, often in a recursive fashion.
|
||||
Wait a minute, we said that all sets form a category, but at the same time any one set can be seen as a category on its own right (just one which has no morphisms). This is true and an example of a phenomenon that is very characteristic of category theory --- one structure can be examined from many different angles and may play many different roles, often in a recursive fashion.
|
||||
|
||||
This particular analogy (a set as a category with no morphisms) is, however, not very useful. Not because it's in any way incorrect, but because category theory is *all about the morphisms*. If in set theory arrows are nothing but a connection between a source and a destination, in category theory it's the *objects* that are nothing but a source and destination for the arrows that connect them to other objects. This is why, in the diagram above, the arrows, and not the objects, are colored: if you ask me, the category of sets should really be called *the category of functions*.
|
||||
|
||||
@ -312,7 +312,7 @@ There are some types of categories in which only one morphism between two object
|
||||
Composition
|
||||
---
|
||||
|
||||
One of the few or maybe even the only requirement for a structure to be called a category is that *two morphisms can make a third*, or in other words, that morphisms are *composable* - given two successive arrows with appropriate type signature, we can draw a third one that is equivalent to the consecutive application of the other two.
|
||||
One of the few or maybe even the only requirement for a structure to be called a category is that *two morphisms can make a third*, or in other words, that morphisms are *composable* --- given two successive arrows with appropriate type signature, we can draw a third one that is equivalent to the consecutive application of the other two.
|
||||
|
||||
![Composition of morphisms](../02_category/composition.svg)
|
||||
|
||||
@ -325,7 +325,7 @@ Formally, this requirement says that there should exist an operation (denoted wi
|
||||
The law of identity
|
||||
---
|
||||
|
||||
Before the standard Arabic numerals that we use today, there were Roman numbers. Roman numerals weren't any good, because they lacked the concept of *zero* - a number that indicated the absence of quantity and any number system that lacks this simple concept is bound to remain extremely limited. It is the same in programming, where we have multiple values that indicate the absence of a value.
|
||||
Before the standard Arabic numerals that we use today, there were Roman numbers. Roman numerals weren't any good, because they lacked the concept of *zero* --- a number that indicated the absence of quantity and any number system that lacks this simple concept is bound to remain extremely limited. It is the same in programming, where we have multiple values that indicate the absence of a value.
|
||||
|
||||
The zero of category theory is what we call the "identity morphism" for each object. In short, this is a morphism, that doesn't do anything.
|
||||
|
||||
@ -334,7 +334,7 @@ The zero of category theory is what we call the "identity morphism" for each obj
|
||||
|
||||
It's important to mark this morphism, because there can be (let's add the very important (and also very boring) reminder) many morphisms that go from one object to the same object, many of which actually do stuff. For example, mathematics deals with a multitude of functions that have the set of numbers as source and target, such as $negate$, $square$, $add one$, and are not at all the identity morphism.
|
||||
|
||||
A structure must have an identity morphism for each object in order for it to be called a category - this is known as the law of identity.
|
||||
A structure must have an identity morphism for each object in order for it to be called a category --- this is known as the law of identity.
|
||||
|
||||
**Question:** What is the identity morphism in the category of sets?
|
||||
|
||||
@ -352,7 +352,7 @@ This formula can be expressed using the following diagram, which would only comm
|
||||
|
||||
![Composition of morphisms with many objects](../02_category/composition_associativity.svg)
|
||||
|
||||
This formula (and the diagram) is the definition of a property called $associativity$. Being associative is required for functional composition to really be called functional composition (and for a category to really be called category). It is also required for our diagrams to work, as diagrams can only represent associative structures (imagine if the diagram above does not commute - it would be super weird).
|
||||
This formula (and the diagram) is the definition of a property called $associativity$. Being associative is required for functional composition to really be called functional composition (and for a category to really be called category). It is also required for our diagrams to work, as diagrams can only represent associative structures (imagine if the diagram above does not commute, it would be super weird).
|
||||
|
||||
Associativity is not just about diagrams. For example, when we express relations using formulas, associativity just means that brackets don't matter in our formulas (as evidenced by the definition $(h • g) • f = h • (g • f)$).
|
||||
|
||||
@ -364,7 +364,7 @@ This approach (composing indefinitely many things) for building stuff is often u
|
||||
Commuting diagrams
|
||||
---
|
||||
|
||||
The diagrams above, use colors to illustrate the fact that the green morphism is equivalent to the other two (and not just some unrelated morphism), but in practice this notation is a little redundant - the only reason to draw diagrams in the first place is to represent paths that are equivalent to each other - all other paths just belong in different diagrams.
|
||||
The diagrams above, use colors to illustrate the fact that the green morphism is equivalent to the other two (and not just some unrelated morphism), but in practice this notation is a little redundant --- the only reason to draw diagrams in the first place is to represent paths that are equivalent to each other. All other paths just belong in different diagrams.
|
||||
|
||||
![Composition of morphisms - a commuting diagram](../02_category/composition_commuting_diagram.svg)
|
||||
|
||||
@ -375,7 +375,7 @@ Diagrams that are like that (ones in which any two paths between two objects are
|
||||
A summary
|
||||
---
|
||||
|
||||
For future reference, let's restate what a category is.
|
||||
For future reference, let's restate what a category is:
|
||||
|
||||
A category is a collection of *objects* (we can think of them as *points*) and *morphisms* ( or *arrows*) that go from one object to another, where:
|
||||
1. Each object has to have the identity morphism.
|
||||
@ -388,15 +388,15 @@ This is it.
|
||||
Addendum: Why are categories like that?
|
||||
===
|
||||
|
||||
*Why* are categories defined by those two laws and not some other two (or one, three, four etc.). laws? From one standpoint, the answer to that seems obvious - we study categories because they *work*, I mean, look at how many applications are there.
|
||||
But at the same time category theory is an abstract theory, so everything about it is kinda arbitrary: you can remove a law - and you get another theory that looks similar to category theory (although it might actually turn out to be quite different in practice (due to a phenomenon called "emergence")). Or you add one more law and you get a yet another theory, so if this specific set of laws works better than any other, then this fact demands an explanation. Not a *mathematical* explanation (e.g. we cannot prove that this theory is better than some other one), but an explanation nevertheless. What follows is *my attempt* to provide such an explanation, regarding the laws of *identity* and *associativity*.
|
||||
*Why* are categories defined by those two laws and not some other two (or one, three, four etc.). laws? From one standpoint, the answer to that seems obvious --- we study categories because they *work*, I mean, look at how many applications are there.
|
||||
But at the same time category theory is an abstract theory, so everything about it is kinda arbitrary: you can remove a law --- and you get another theory that looks similar to category theory (although it might actually turn out to be quite different in practice (due to a phenomenon called "emergence")). Or you add one more law and you get a yet another theory, so if this specific set of laws works better than any other, then this fact demands an explanation. Not a *mathematical* explanation (e.g. we cannot prove that this theory is better than some other one), but an explanation nevertheless. What follows is *my attempt* to provide such an explanation, regarding the laws of *identity* and *associativity*.
|
||||
|
||||
Identity and isomorphisms
|
||||
===
|
||||
|
||||
The reason the identity law is required is by far the more obvious one. We need to have a morphism that does nothing? It's because morphisms are the basic building blocks of our language, we need the identity morphism to be able to speak properly. For example, once we have the concept of identity morphism defined, we can have a category-theoretic definition of an *isomorphism* (which is important, because the concept of an isomorphism is very important for category theory):
|
||||
|
||||
Like we said in the previous chapter, an isomorphism between two objects ($A$ and $B$) consists of two morphisms - ($A → B$. and $B → A$) such that their compositions are equivalent to the identity functions of the respective objects. Formally, objects $A$ and $B$ are isomorphic if there exist morphisms $f: A → B$ and $g: B → A$ such that $f \bullet g = id_{B}$ and $g \bullet f = id_{A}$.
|
||||
Like we said in the previous chapter, an isomorphism between two objects ($A$ and $B$) consists of two morphisms --- ($A → B$. and $B → A$) such that their compositions are equivalent to the identity functions of the respective objects. Formally, objects $A$ and $B$ are isomorphic if there exist morphisms $f: A → B$ and $g: B → A$ such that $f \bullet g = id_{B}$ and $g \bullet f = id_{A}$.
|
||||
|
||||
And here is the same thing expressed with a commuting diagram.
|
||||
|
||||
@ -408,9 +408,9 @@ Like the previous one, the diagram expresses the same (simple) fact as the formu
|
||||
Associativity and reductionism
|
||||
===
|
||||
|
||||
Associativity - what it means and why is it there? In order to tackle this question, we must first talk about another concept - the concept of *reductionism*:
|
||||
Associativity --- what does it mean and why is it there? In order to tackle this question, we must first talk about another concept --- the concept of *reductionism*:
|
||||
|
||||
Reductionism is a name for the idea that the behaviour of some more complex phenomenon can be explained in terms of a number of simpler and more fundamental phenomena. Whether the reductionist view is *universally valid*, i.e. whether it is possible to expain everything with a simpler things (and devise a *theory of everything* that reduces the whole universe to a few very simple laws), is a question that we can argue about until the that universe's inevitable collapse. But what is certain is that reductionism underpins all our understanding, especially when it comes to science and mathematics - each scientific discipline has a set of fundaments using which it tries to explain a given set of more complex phenomena, e.g. particle physics tries to explain the behaviour of atoms in terms of a given set of elementary particles, chemistry tries to explain the behaviour of various chemical substances in terms of a the chemical elements that they are composed of etc. A behaviour that cannot be reduced to the fundamentals of a given scientific discipline is simply outside of the scope of this discipline (and so a new discipline has to be created to tackle it).
|
||||
Reductionism is the idea that the behaviour of some more complex phenomenon can be understood in terms of a number of *simpler* and more fundamental phenomena, or in other words, the idea that things keep getting simpler and simpler as they get "smaller" (or when they are viewed at a lower level). Whether the reductionist view is *universally valid*, i.e. whether it is possible to expain everything with a simpler things (and devise a *theory of everything* that reduces the whole universe to a few very simple laws), is a question that we can argue about until the that universe's inevitable collapse. But what is certain is that reductionism underpins all our understanding, especially when it comes to science and mathematics --- each scientific discipline has a set of fundaments using which it tries to explain a given set of more complex phenomena, e.g. particle physics tries to explain the behaviour of atoms in terms of a given set of elementary particles, chemistry tries to explain the behaviour of various chemical substances in terms of a the chemical elements that they are composed of etc. A behaviour that cannot be reduced to the fundamentals of a given scientific discipline is simply outside of the scope of this discipline (and so a new discipline has to be created to tackle it).
|
||||
|
||||
Commutativity
|
||||
---
|
||||
|
@ -6,12 +6,12 @@ title: Monoids
|
||||
Monoids etc
|
||||
===
|
||||
|
||||
Since we are done with categories, let's look at some other structures that are also interesting - monoids. Like categories, monoids/groups are also abstract systems consisting of set of elements and operations for manipulating these elements, however the operations look different than the operations we have for categories. Let's see them.
|
||||
Since we are done with categories, let's look at some other structures that are also interesting --- monoids. Like categories, monoids/groups are also abstract systems consisting of set of elements and operations for manipulating these elements, however the operations look different than the operations we have for categories. Let's see them.
|
||||
|
||||
What are monoids
|
||||
===
|
||||
|
||||
Monoids are simpler than categories. A monoid is defined by a collection/set of elements (called the monoid's *underlying set*, together with an *monoid operation* - a rule for combining two elements that produces a third element one of the same kind.
|
||||
Monoids are simpler than categories. A monoid is defined by a collection/set of elements (called the monoid's *underlying set*, together with an *monoid operation* --- a rule for combining two elements that produces a third element one of the same kind.
|
||||
|
||||
Let's take our familiar colorful balls.
|
||||
|
||||
@ -37,7 +37,7 @@ When an operation is associative, this means we can use all kinds of algebraic o
|
||||
The identity element
|
||||
---
|
||||
|
||||
Actually, not any (associative) operation for combining elements makes the balls form a monoid (it makes them form a *semigroup*, which is also a thing, but that's a separate topic). To be a monoid, a set must feature what is called an *identity element* of a given operation, the concept of which you are already familiar from both sets and categories - it is an element that when combined with any other element gives back that same element (not the identity but the other one). Or simply $x • i = x$ and $i • x = x$ for any $x$.
|
||||
Actually, not any (associative) operation for combining elements makes the balls form a monoid (it makes them form a *semigroup*, which is also a thing, but that's a separate topic). To be a monoid, a set must feature what is called an *identity element* of a given operation, the concept of which you are already familiar from both sets and categories --- it is an element that when combined with any other element gives back that same element (not the identity but the other one). Or simply $x • i = x$ and $i • x = x$ for any $x$.
|
||||
|
||||
In the case of our color-mixing monoid the identity element is the white ball (or perhaps a transparent one, if we have one).
|
||||
|
||||
@ -79,15 +79,15 @@ Thinking about operations that we covered, we may remember the boolean operation
|
||||
Monoid operations in terms of set theory
|
||||
===
|
||||
|
||||
We now know what the monoid operation is, and we even saw some simple examples. However, we never defined the monoid rule/operation formally i.e. using the language of set theory with which we defined everything else. Can we do that? Of course we can - everything can be defined in terms of sets.
|
||||
We now know what the monoid operation is, and we even saw some simple examples. However, we never defined the monoid rule/operation formally i.e. using the language of set theory with which we defined everything else. Can we do that? Of course we can --- everything can be defined in terms of sets.
|
||||
|
||||
We said that a monoid consists of two things a set (let's call it $A$) and a monoid operation that acts on that set. Since $A$ is already defined in set theory (because it is just a set), all we have to do is define the monoid operation.
|
||||
|
||||
Defining the operation is not hard at all. Actually, we have already done it for the operation $+$ - in chapter 2, we said that *addition* can be represented in set theory as a function that accepts a product of two numbers and returns a number (formally $+: \mathbb{Z} \times \mathbb{Z} \to \mathbb{Z}$).
|
||||
Defining the operation is not hard at all. Actually, we have already done it for the operation $+$ --- in chapter 2, we said that *addition* can be represented in set theory as a function that accepts a product of two numbers and returns a number (formally $+: \mathbb{Z} \times \mathbb{Z} \to \mathbb{Z}$).
|
||||
|
||||
![The plus operation as a function](../03_monoid/plus_operation.svg)
|
||||
|
||||
Every other monoid operation can also be represented in the same way - as a function that takes a pair of elements from the monoid's set and returns one other monoid element.
|
||||
Every other monoid operation can also be represented in the same way --- as a function that takes a pair of elements from the monoid's set and returns one other monoid element.
|
||||
|
||||
![The color-mixing operation as a function](../03_monoid/color_mixing_operation.svg)
|
||||
|
||||
@ -96,18 +96,18 @@ Formally, we can define a monoid from any set $A$, by defining an (associative)
|
||||
Other monoid-like objects
|
||||
===
|
||||
|
||||
Monoid operations obey two laws - they are *associative* and there is an *identity element*. In some cases we come across operations that also obey other laws that are also interesting. Imposing more (or less) rules to the way in which (elements) objects are combined results in the definition of other monoid-like structures.
|
||||
Monoid operations obey two laws --- they are *associative* and there is an *identity element*. In some cases we come across operations that also obey other laws that are also interesting. Imposing more (or less) rules to the way in which (elements) objects are combined results in the definition of other monoid-like structures.
|
||||
|
||||
Commutative (abelian) monoids
|
||||
---
|
||||
|
||||
Looking at the monoid laws and the examples we gave so far, we observe that all of them obey one more rule (law) which we didn't specify - the order in which the operations are applied is irrelevant to the end result.
|
||||
Looking at the monoid laws and the examples we gave so far, we observe that all of them obey one more rule (law) which we didn't specify --- the order in which the operations are applied is irrelevant to the end result.
|
||||
|
||||
![Commutative monoid operation](../03_monoid/monoid_commutative.svg)
|
||||
|
||||
Such operations (ones for which combining a given set of elements yields the same result no matter which one is first and which one is second) are called *commutative* operations. Monoids with operations that are commutative are called *commutative monoids*.
|
||||
|
||||
As we said, addition is commutative as well - it does not matter whether if I have given you 1 apple and then 2 more, or if I have given you 2 first and then 1 more.
|
||||
As we said, addition is commutative as well --- it does not matter whether if I have given you 1 apple and then 2 more, or if I have given you 2 first and then 1 more.
|
||||
|
||||
![Commutative monoid operation](../03_monoid/addition_commutative.svg)
|
||||
|
||||
@ -116,7 +116,7 @@ All monoids that we examined so far are also *commutative*. We will see some non
|
||||
Groups
|
||||
---
|
||||
|
||||
A group is a monoid such that for each of its elements, there is another element which is the so called "inverse" of the first one where the element and its inverse cancel each other out when applied one after the other. Plain-English definitions like this make you appreciate mathematical formulas more - formally we say that for all elements $x$, there must exist $x'$ such that $x • x' = i$ ( where $i$ is the identity element).
|
||||
A group is a monoid such that for each of its elements, there is another element which is the so called "inverse" of the first one where the element and its inverse cancel each other out when applied one after the other. Plain-English definitions like this make you appreciate mathematical formulas more --- formally we say that for all elements $x$, there must exist $x'$ such that $x • x' = i$ ( where $i$ is the identity element).
|
||||
|
||||
If we view *monoids* as a means of modeling the effect of applying a set of (associative) actions, we use *groups* to model the effects of actions are also *reversible*.
|
||||
|
||||
@ -127,7 +127,7 @@ The study of groups is a field that is much bigger than the theory of monoids (a
|
||||
Summary
|
||||
---
|
||||
|
||||
But before that, just a quick note - the algebraic structures that we saw can be summarized based on the laws that define them in this table.
|
||||
But before that, just a quick note --- the algebraic structures that we saw can be summarized based on the laws that define them in this table.
|
||||
|
||||
| | Semigroups | Monoids | Groups |
|
||||
|---| --- | --- |
|
||||
@ -142,7 +142,7 @@ Symmetry groups and group classifications
|
||||
|
||||
An interesting kinds of groups/monoids are the groups of *symmetries* of geometric figures. Given some geometric figure, a symmetry is an action after which the figure is not displaced (e.g. it can fit into the same mold that it fit before the action was applied).
|
||||
|
||||
We won't use the balls this time, because in terms of symmetries they have just one position and hence just one action - the identity action (which is its own reverse, by the way). So let's take this triangle, which, for our purposes, is the same as any other triangle (we are not interested in the triangle itself, but in its rotations).
|
||||
We won't use the balls this time, because in terms of symmetries they have just one position and hence just one action --- the identity action (which is its own reverse, by the way). So let's take this triangle, which, for our purposes, is the same as any other triangle (we are not interested in the triangle itself, but in its rotations).
|
||||
|
||||
![A triangle](../03_monoid/symmetry_group.svg)
|
||||
|
||||
@ -153,11 +153,11 @@ Let's first review the group of ways in which we can rotate our triangle i.e. it
|
||||
|
||||
![The group of rotations in a triangle](../03_monoid/symmetry_rotation.svg)
|
||||
|
||||
Connecting the dots (or the triangles in this case) shows us that there are just two possible rotations that get us from any state of the triangle to any other one - a *120-degree rotation* (i.e. flipping the triangle one time) and a *240-degree rotation* (i.e. flipping it two times (or equivalently, flipping it once, but in the opposite direction)). Adding the identity action of 0-degree rotation makes up for 3 rotations (objects) in total.
|
||||
Connecting the dots (or the triangles in this case) shows us that there are just two possible rotations that get us from any state of the triangle to any other one --- a *120-degree rotation* (i.e. flipping the triangle one time) and a *240-degree rotation* (i.e. flipping it two times (or equivalently, flipping it once, but in the opposite direction)). Adding the identity action of 0-degree rotation makes up for 3 rotations (objects) in total.
|
||||
|
||||
![The group of rotations in a triangle](../03_monoid/symmetry_rotation_actions.svg)
|
||||
|
||||
The rotations of a triangle form a monoid - the *rotations are objects* (of which the zero-degree rotation is the identity) and the monoid operation which combines two rotations into one is just the operation of performing the first rotation and then performing the second one.
|
||||
The rotations of a triangle form a monoid --- the *rotations are objects* (of which the zero-degree rotation is the identity) and the monoid operation which combines two rotations into one is just the operation of performing the first rotation and then performing the second one.
|
||||
|
||||
**NB:** Note once again that the elements in the group are the *rotations*, not the triangles themselves, actually the group has nothing to do with triangles, as we shall see later.
|
||||
|
||||
@ -205,7 +205,7 @@ There are abelian groups that are not cyclic, but, as we shall see below, the co
|
||||
Group isomorphisms
|
||||
---
|
||||
|
||||
We already mentioned group isomorphisms, but we didn't define what they are. Let's do that now - an isomorphism between two groups is an isomorphism ($f$) between their respective sets of elements, such that for any $a$ and $b$ we have $f(a \bullet b) = f(a) \bullet f(b)$. Visually, the diagrams of isomorphic groups have the same structure.
|
||||
We already mentioned group isomorphisms, but we didn't define what they are. Let's do that now --- an isomorphism between two groups is an isomorphism ($f$) between their respective sets of elements, such that for any $a$ and $b$ we have $f(a \bullet b) = f(a) \bullet f(b)$. Visually, the diagrams of isomorphic groups have the same structure.
|
||||
|
||||
![Group isomorphism between different representations of S3](../03_monoid/group_isomorphism.svg)
|
||||
|
||||
@ -231,7 +231,7 @@ Like $Z_3$, $Z_1$ and $Z_2$ are cyclic.
|
||||
Group/monoid products
|
||||
===
|
||||
|
||||
We already saw a lot of abelian groups that are also cyclic, but we didn't see any abelian groups that are not cyclic. So let's examine what those look like. This time, instead of looking into individual examples, we will present a general way for producing abelian non-cyclic groups from cyclic ones - it is by uniting them by using *group product*.
|
||||
We already saw a lot of abelian groups that are also cyclic, but we didn't see any abelian groups that are not cyclic. So let's examine what those look like. This time, instead of looking into individual examples, we will present a general way for producing abelian non-cyclic groups from cyclic ones --- it is by uniting them by using *group product*.
|
||||
|
||||
Given any two groups, we can combine them to create a third group, comprised of all possible pairs of elements from the two groups and of the sum of all their actions.
|
||||
|
||||
@ -255,7 +255,7 @@ Another way to present the Klein-four group is the *group of symmetries of a non
|
||||
|
||||
**Task:** Show that the two representations are isomorphic.
|
||||
|
||||
The Klein-four group is *non-cyclic* (because there are not one, but two generators) - vertical and horizontal spin. It is, however, still *abelian*, because the ordering of the actions still does not matter for the end results. Actually, the Klein-four group is the *smallest non-cyclic group*.
|
||||
The Klein-four group is *non-cyclic* (because there are not one, but two generators) --- vertical and horizontal spin. It is, however, still *abelian*, because the ordering of the actions still does not matter for the end results. Actually, the Klein-four group is the *smallest non-cyclic group*.
|
||||
|
||||
Cyclic product groups
|
||||
---
|
||||
@ -278,7 +278,7 @@ Product groups are *abelian*, provided that the *groups that form them* are abel
|
||||
Fundamental theorem of Finite Abelian groups
|
||||
---
|
||||
|
||||
Products provide one way to create non-cyclic abelian groups - by creating a product of two or more cyclic groups. The fundamental theory of finite abelian groups is a result that tells us that *this is the only way* to produce non-cyclic abelian groups i.e.
|
||||
Products provide one way to create non-cyclic abelian groups --- by creating a product of two or more cyclic groups. The fundamental theory of finite abelian groups is a result that tells us that *this is the only way* to produce non-cyclic abelian groups i.e.
|
||||
|
||||
> All abelian groups are either cyclic or products of cyclic groups.
|
||||
|
||||
@ -295,7 +295,7 @@ To see how can we use this theorem, let's revisit our color mixing monoid that w
|
||||
|
||||
As there doesn't exist a color that, when mixed with itself, can produce all other colors, the color-mixing monoid is *not cyclic*. However, the color mixing monoid *is abelian*. So according to the theorem of finite abelian groups (which is valid for monoids as well), the color-mixing monoid must be (isomorphic to) a product.
|
||||
|
||||
And it is not hard to find the monoids that form it - although there isn't one color that can produce all other colors, there are three colors that can do that - the prime colors. This observation leads us to the conclusion that the color-mixing monoid, can be represented as the product of three monoids, corresponding to the three primary colors.
|
||||
And it is not hard to find the monoids that form it --- although there isn't one color that can produce all other colors, there are three colors that can do that --- the prime colors. This observation leads us to the conclusion that the color-mixing monoid, can be represented as the product of three monoids, corresponding to the three primary colors.
|
||||
|
||||
![color-mixing group as a product](../03_monoid/color_mixing_product.svg)
|
||||
|
||||
@ -314,7 +314,7 @@ In both cases the monoid would be cyclic.
|
||||
Dihateral groups
|
||||
===
|
||||
|
||||
Now, let's finally examine a non-commutative group - the group of rotations *and reflections* of a given geometrical figure. It is the same as the last one, but here besides the rotation action that we already saw (and its composite actions), we have the action of flipping the figure vertically, an operation which results in its mirror image:
|
||||
Now, let's finally examine a non-commutative group --- the group of rotations *and reflections* of a given geometrical figure. It is the same as the last one, but here besides the rotation action that we already saw (and its composite actions), we have the action of flipping the figure vertically, an operation which results in its mirror image:
|
||||
|
||||
![Reflection of a triangle](../03_monoid/reflection.svg)
|
||||
|
||||
@ -341,9 +341,9 @@ We began by defining a monoid as a set of composable *elements*. Then we saw tha
|
||||
Currying
|
||||
---
|
||||
|
||||
When we defined monoids, we saw that their operations are two-argument functions. And we introduced a way for representing such functions using set theory - by uniting the two arguments into one using products. i.e. we showed that a function that accepts two arguments (say $A$ and $B$) and maps them into some result ($C$), can be thought as a mapping from the product of the sets of two arguments to the result. So $A\times B\to C$.
|
||||
When we defined monoids, we saw that their operations are two-argument functions. And we introduced a way for representing such functions using set theory --- by uniting the two arguments into one using products. i.e. we showed that a function that accepts two arguments (say $A$ and $B$) and maps them into some result ($C$), can be thought as a mapping from the product of the sets of two arguments to the result. So $A\times B\to C$.
|
||||
|
||||
However, this is not the only way to represent multi-argument function set-theoretically - there is another, equally interesting way, that doesn't rely on any data structures, but only on functions: that way is to have a function that maps the first of the two arguments (i.e. from $A$) to *another function* that maps the second argument to the final result (i.e. $B \to C$). So $A\to B \to C$.
|
||||
However, this is not the only way to represent multi-argument function set-theoretically --- there is another, equally interesting way, that doesn't rely on any data structures, but only on functions: that way is to have a function that maps the first of the two arguments (i.e. from $A$) to *another function* that maps the second argument to the final result (i.e. $B \to C$). So $A\to B \to C$.
|
||||
|
||||
The practice of transforming a function that takes a pair of objects to a function that takes just one object and returns a function that takes another one is called *currying*. It is achieved by a higher-order function. Here is how such a function might be implemented.
|
||||
|
||||
@ -374,11 +374,11 @@ Let's take a step back and examine the groups/monoids that we covered so far in
|
||||
|
||||
![The group of rotations in a triangle - group notation](../03_monoid/symmetry_rotation_actions.svg)
|
||||
|
||||
Using currying, we can represent the elements of a given group/monoid as functions by uniting them to the group operation, and the group operation itself - as functional composition. For example, the 3 elements of $Z_3$ can be seen as 3 bijective (invertable) functions from a set of 3 elements to itself (in group-theoretic context, these kinds of functions are called *permutations*, by the way).
|
||||
Using currying, we can represent the elements of a given group/monoid as functions by uniting them to the group operation, and the group operation itself --- as functional composition. For example, the 3 elements of $Z_3$ can be seen as 3 bijective (invertable) functions from a set of 3 elements to itself (in group-theoretic context, these kinds of functions are called *permutations*, by the way).
|
||||
|
||||
![The group of rotations in a triangle - set notation](../03_monoid/symmetry_rotation_functions.svg)
|
||||
|
||||
We can do the same for the addition monoid - numbers can be seen not as *quantities* (as in two apples, two oranges etc.), but as *operations*, (e.g. as the action of adding two to a given quantity).
|
||||
We can do the same for the addition monoid --- numbers can be seen not as *quantities* (as in two apples, two oranges etc.), but as *operations*, (e.g. as the action of adding two to a given quantity).
|
||||
|
||||
Formally, the operation of the addition monoid, that we saw above has the following type signature.
|
||||
|
||||
@ -405,7 +405,7 @@ The functions that represent the monoid elements have the same set as source and
|
||||
|
||||
![The group of rotations in a triangle - set notation](../03_monoid/symmetry_rotation_cayley.svg)
|
||||
|
||||
And the same is valid for the addition monoid - number functions can be combined using functional composition.
|
||||
And the same is valid for the addition monoid --- number functions can be combined using functional composition.
|
||||
|
||||
$+2 \bullet +3 \cong +5$
|
||||
|
||||
@ -418,13 +418,13 @@ So, basically the functions that represent the elements of a monoid also form a
|
||||
Cayley's theorem
|
||||
---
|
||||
|
||||
Once we learn how to represent the elements of any monoid as permutations that also form a monoid, using currying, it isn't too surprising to learn that this constructed permutation monoid is isomorphic to the original one (the one from which it is constructed - this is a result known as the Cayley's theorem:
|
||||
Once we learn how to represent the elements of any monoid as permutations that also form a monoid, using currying, it isn't too surprising to learn that this constructed permutation monoid is isomorphic to the original one (the one from which it is constructed --- this is a result known as the Cayley's theorem:
|
||||
|
||||
> Any group is isomorphic to a permutation group.
|
||||
|
||||
Formally, if we use $Perm$ to denote the permutation group then $Perm(A) \cong A$ for any $A$.
|
||||
|
||||
![The group of rotations in a triangle - set notation and normal notation](../03_monoid/symmetry_rotation_comparison.svg)
|
||||
![The group of rotations in a triangle --- set notation and normal notation](../03_monoid/symmetry_rotation_comparison.svg)
|
||||
|
||||
Or in other words, representing the elements of a group as permutations actually yields a representation of the monoid itself (sometimes called its *standard representation*).
|
||||
|
||||
@ -445,11 +445,11 @@ The group $\mathrm{S}_2$, has $1 \times 2 = 2$ elements (by the way, the colors
|
||||
|
||||
![The S2 symmetric group](../03_monoid/s2.svg)
|
||||
|
||||
And with $\mathrm{S}_3$ we are already feeling the power of exponential (and even faster than exponential!) growth of the factorial function - it has $1\times 2\times 3=6$ elements.
|
||||
And with $\mathrm{S}_3$ we are already feeling the power of exponential (and even faster than exponential!) growth of the factorial function --- it has $1\times 2\times 3=6$ elements.
|
||||
|
||||
![The S3 symmetric group](../03_monoid/s3.svg)
|
||||
|
||||
Each symmetric group $\mathrm{S}_n$ contains all groups of order $n$ - this is so, because (as we saw in the prev section) every group with $n$ elements is isomorphic to a set of permutations on the set of $n$ elements and the group $\mathrm{S}_n$ contains *all such* permutations that exist.
|
||||
Each symmetric group $\mathrm{S}_n$ contains all groups of order $n$ --- this is so, because (as we saw in the prev section) every group with $n$ elements is isomorphic to a set of permutations on the set of $n$ elements and the group $\mathrm{S}_n$ contains *all such* permutations that exist.
|
||||
|
||||
Here are some examples:
|
||||
- $\mathrm{S}_1$ is isomorphic to $Z_1$, the *trivial group*, and $\mathrm{S}_2$ is isomorphic to $Z_2$ , the *boolean group*, (but no other symmetric grops are isomorphic to cycle groups)
|
||||
@ -465,7 +465,7 @@ Based on this insight, can state Cayley's theorem in terms of symmetric groups i
|
||||
|
||||
**Task:** Show how the two are equivalent.
|
||||
|
||||
Fun fact: the study of group theory actually started by examining symmetric groups, so this theorem was actually a prerequisite for the emergence of the normal definition of groups that we all know and love (OK, at least *I* love it) - it provided a proof that the notion described by this definition is equivalent to the already existing notion of symmetric groups.
|
||||
Fun fact: the study of group theory actually started by examining symmetric groups, so this theorem was actually a prerequisite for the emergence of the normal definition of groups that we all know and love (OK, at least *I* love it) --- it provided a proof that the notion described by this definition is equivalent to the already existing notion of symmetric groups.
|
||||
|
||||
{% endif %}
|
||||
|
||||
@ -476,7 +476,7 @@ We saw that converting the monoid's elements to actions/functions yields an accu
|
||||
|
||||
![The group of rotations in a triangle - set notation and normal notation](../03_monoid/symmetry_rotation_set.svg)
|
||||
|
||||
However, it seems that the set part of the structure in this representation is kinda redundant - you have the same set everywhere - so, it would do it good if we can simplify it. And we can do that by depicting it as an external (categorical) diagram.
|
||||
However, it seems that the set part of the structure in this representation is kinda redundant --- you have the same set everywhere --- so, it would do it good if we can simplify it. And we can do that by depicting it as an external (categorical) diagram.
|
||||
|
||||
![The group of rotations in a triangle - categorical notation](../03_monoid/symmetry_rotation_external.svg)
|
||||
|
||||
@ -487,7 +487,7 @@ But wait, if the monoids' underlying *sets* correspond to *objects* in category
|
||||
|
||||
The only difference between different monoids would be the number of morphisms that they have and the relationship between them.
|
||||
|
||||
The intuition behind this representation from a category-theoretic standpoint is encompassed by the law of $closure$ that monoid and group operations have and that categories lack - it is the law stating that applying the operation (functional composition) on any two objects always yields the same object, e.g. no matter how do you flip a triangle, you'd still get a triangle.
|
||||
The intuition behind this representation from a category-theoretic standpoint is encompassed by the law of $closure$ that monoid and group operations have and that categories lack --- it is the law stating that applying the operation (functional composition) on any two objects always yields the same object, e.g. no matter how do you flip a triangle, you'd still get a triangle.
|
||||
|
||||
| | Categories | Monoids | Groups
|
||||
|---| --- | --- |
|
||||
@ -508,7 +508,7 @@ Aside from the little-confusing fact that *monoid objects are morphisms* when vi
|
||||
|
||||
Categories have an identity morphism for each object, so for categories with just one object, there should also be exactly one identity morphism. And monoids do have an identity object, which when viewed categorically corresponds to that identity morphism.
|
||||
|
||||
Categories provide a way to compose two morphisms with an appropriate type signature, and for categories with one object this means that *all morphisms should be composable* with one another. And the monoid operation does exactly that - given any two objects (or two morphisms, if we use the categorical terminology), it creates a third.
|
||||
Categories provide a way to compose two morphisms with an appropriate type signature, and for categories with one object this means that *all morphisms should be composable* with one another. And the monoid operation does exactly that --- given any two objects (or two morphisms, if we use the categorical terminology), it creates a third.
|
||||
|
||||
Philosophically, defining a monoid as a one-object category means corresponds to the view of monoids as a model of how a set of (associative) actions that are performed on a given object alter its state. Provided that the object's state is determined solely by the actions that are performed on it, we can leave it out of the equation and concentrate on how the actions are combined. And as per usual, the actions (and elements) can be anything, from mixing colors in paint, or adding a quantities to a given set of things etc.
|
||||
|
||||
@ -556,11 +556,11 @@ If you revisit the previous section you will notice that we already saw one such
|
||||
|
||||
![The free monoid with one generator](../03_monoid/infinite_cyclic_presentation_elements.svg)
|
||||
|
||||
We can make a free monoid from the set of colorful balls - the monoid's elements would be sequences of all possible combinations of the balls.
|
||||
We can make a free monoid from the set of colorful balls --- the monoid's elements would be sequences of all possible combinations of the balls.
|
||||
|
||||
![The free monoid with the set of balls as a generators](../03_monoid/balls_free.svg)
|
||||
|
||||
The free monoid is a special one - each element of the free monoid over a given set, can be converted to a corresponding element in any any other monoid that uses the same set of generators by just applying the monoid's laws. For example, here is how the elements above would look like if we apply the laws of the color-mixing monoid.
|
||||
The free monoid is a special one --- each element of the free monoid over a given set, can be converted to a corresponding element in any any other monoid that uses the same set of generators by just applying the monoid's laws. For example, here is how the elements above would look like if we apply the laws of the color-mixing monoid.
|
||||
|
||||
![Converting the elements of the free monoid to the elements of the color-mixing monoid](../03_monoid/balls_free_color_mixing.svg)
|
||||
|
||||
@ -572,7 +572,7 @@ While the intuition behind free monoids seems simple enough, the formal definiti
|
||||
|
||||
We understand that, being the most general of all monoids for a given set of generators, a free monoid can be converted to all of them. i.e. there exist a function from it to all of them. But what kind of function would that be?
|
||||
|
||||
Plus, what about other monoids that also can have this property (that they are connected to any other monoids) Simple - they are the free monoid with some extra structure, so we can filter them out by using an universal property.
|
||||
Plus, what about other monoids that also can have this property (that they are connected to any other monoids) Simple --- they are the free monoid with some extra structure, so we can filter them out by using an universal property.
|
||||
|
||||
But, what would this property be, (and what the hell are universal properties anyways?), tune in after a few chapters to find out.
|
||||
|
||||
|
@ -6,7 +6,7 @@ title: Orders
|
||||
Orders
|
||||
===
|
||||
|
||||
Given a set of objects, there can be numerous criteria, based on which to order them (depending on the objects themselves) - size, weight, age, alphabetical order etc.
|
||||
Given a set of objects, there can be numerous criteria, based on which to order them (depending on the objects themselves) --- size, weight, age, alphabetical order etc.
|
||||
|
||||
However, currently we are not interested in the *criteria* that we can use to order objects, but in the *nature of the relationships* that define order. Of which there can be several types as well.
|
||||
|
||||
@ -20,12 +20,12 @@ And the other is a *binary relation* between these things, which are often repre
|
||||
|
||||
![Binary relation](../04_order/binary_relation.svg)
|
||||
|
||||
Not all binary relationships are orders - only ones that fit certain criteria that we are going to examine as we review the different types of order.
|
||||
Not all binary relationships are orders --- only ones that fit certain criteria that we are going to examine as we review the different types of order.
|
||||
|
||||
Linear order
|
||||
===
|
||||
|
||||
Let's start with an example - the most straightforward type of order that you think og is *linear order* i.e. one in which every object has its place depending on every other object. In this case the ordering criteria is completely deterministic and leaves no room for ambiguity in terms of which element comes before which. For example, order of colors, sorted by the length of their light-waves (or by how they appear in the rainbow).
|
||||
Let's start with an example --- the most straightforward type of order that you think og is *linear order* i.e. one in which every object has its place depending on every other object. In this case the ordering criteria is completely deterministic and leaves no room for ambiguity in terms of which element comes before which. For example, order of colors, sorted by the length of their light-waves (or by how they appear in the rainbow).
|
||||
|
||||
![Linear order](../04_order/linear_order.svg)
|
||||
|
||||
@ -52,7 +52,7 @@ Incidentally, (or rather not incidentally at all), these rules are nearly equiva
|
||||
Reflexivity
|
||||
---
|
||||
|
||||
Let's get the most boring law out of the way - each object has to be bigger or equal to itself, or $a ≤ a$ for all $a$ (the relationship between elements in an order is commonly denoted as $≤$ in formulas, but it can also be represented with an arrow from first object to the second.)
|
||||
Let's get the most boring law out of the way --- each object has to be bigger or equal to itself, or $a ≤ a$ for all $a$ (the relationship between elements in an order is commonly denoted as $≤$ in formulas, but it can also be represented with an arrow from first object to the second.)
|
||||
|
||||
![Reflexivity](../04_order/reflexivity.svg)
|
||||
|
||||
@ -63,7 +63,7 @@ We can formulate it the opposite way too and say that each object should *not* h
|
||||
Transitivity
|
||||
---
|
||||
|
||||
The second law is maybe the least obvious, (but probably the most essential) - it states that if object $a$ is bigger than object $b$, it is automatically bigger than all objects that are smaller than $b$ or $a ≤ b \land b ≤ c \to a ≤ c$.
|
||||
The second law is maybe the least obvious, (but probably the most essential) --- it states that if object $a$ is bigger than object $b$, it is automatically bigger than all objects that are smaller than $b$ or $a ≤ b \land b ≤ c \to a ≤ c$.
|
||||
|
||||
![Transitivity](../04_order/transitivity.svg)
|
||||
|
||||
@ -76,12 +76,12 @@ The third law is called antisymmetry. It states that the function that defines t
|
||||
|
||||
![antisymmetry](../04_order/antisymmetry.svg)
|
||||
|
||||
It also means that no ties are permitted - either I am better than my grandmother at soccer or she is better at it than me.
|
||||
It also means that no ties are permitted --- either I am better than my grandmother at soccer or she is better at it than me.
|
||||
|
||||
Totality
|
||||
---
|
||||
|
||||
The last law is called *totality* (or *connexity*) and it mandates that all elements that belong to the order should be comparable - $a ≤ b \lor b ≤ a$. That is, for any two elements, one would always be "bigger" than the other.
|
||||
The last law is called *totality* (or *connexity*) and it mandates that all elements that belong to the order should be *comparable* ($a ≤ b \lor b ≤ a$). That is, for any two elements, one would always be "bigger" than the other.
|
||||
|
||||
By the way, this law makes the reflexivity law redundant, as reflexivity is just a special case of totality when $a$ and $b$ are one and the same object, but I still want to present it for reasons that will become apparent soon.
|
||||
|
||||
@ -104,15 +104,15 @@ Natural numbers form a linear order under the operation *bigger or equal to* (th
|
||||
|
||||
![numbers](../04_order/numbers.svg)
|
||||
|
||||
In many ways, numbers are the quintessential order - every finite order of objects is isomorphic to a subset of the order of numbers, as we can map the first element of any order to the number $1$, the second one to the number $2$ etc (and we can do the opposite operation as well).
|
||||
In many ways, numbers are the quintessential order --- every finite order of objects is isomorphic to a subset of the order of numbers, as we can map the first element of any order to the number $1$, the second one to the number $2$ etc (and we can do the opposite operation as well).
|
||||
|
||||
If we think about it, this isomorphism is actually closer to the everyday notion of a linear order, than the one defined by the laws - when most people think of order, they aren't thinking of a *transitive, antisymmetric* and *total* relation, but are rather thinking about criteria based on which they can decide which object comes first, which comes second etc. So it's important to notice that the two are equivalent.
|
||||
If we think about it, this isomorphism is actually closer to the everyday notion of a linear order, than the one defined by the laws --- when most people think of order, they aren't thinking of a *transitive, antisymmetric* and *total* relation, but are rather thinking about criteria based on which they can decide which object comes first, which comes second etc. So it's important to notice that the two are equivalent.
|
||||
|
||||
![Linear order isomorphisms](../04_order/linear_order_isomorphism.svg)
|
||||
|
||||
From the fact that any finite order of objects is isomorphic to the natural numbers, it also follows that all linear orders of the same magnitude are isomorphic to one another.
|
||||
|
||||
So, the linear order is simple, but it is also (and I think that this isomorphism proves it) the most *boring* order ever, especially when looked from a category-theoretic viewpoint - all finite linear orders (and most infinite ones) are just isomorphic to the natural numbers and so all of their diagrams look the same way.
|
||||
So, the linear order is simple, but it is also (and I think that this isomorphism proves it) the most *boring* order ever, especially when looked from a category-theoretic viewpoint --- all finite linear orders (and most infinite ones) are just isomorphic to the natural numbers and so all of their diagrams look the same way.
|
||||
|
||||
![Linear order (general)](../04_order/general_linear_order.svg)
|
||||
|
||||
@ -123,7 +123,7 @@ However, this is not the case with partial orders that we will look into next.
|
||||
Partial order
|
||||
===
|
||||
|
||||
Like a linear order, a partial order consists of a set plus a relation, with the only difference that, although it still obeys the *reflexive, transitive* and the *antisymmetric* laws, the relation does not obey the law of *totality*, that is, not all of the sets elements are necessarily ordered. I say "necessarily" because even if all elements are ordered, it is still a partial order (just as a group is still a monoid) - all linear orders are also partial orders, but not the other way around. We can even create an *order of orders*, based on which is more general.
|
||||
Like a linear order, a partial order consists of a set plus a relation, with the only difference that, although it still obeys the *reflexive, transitive* and the *antisymmetric* laws, the relation does not obey the law of *totality*, that is, not all of the sets elements are necessarily ordered. I say "necessarily" because even if all elements are ordered, it is still a partial order (just as a group is still a monoid) --- all linear orders are also partial orders, but not the other way around. We can even create an *order of orders*, based on which is more general.
|
||||
|
||||
Partial orders are also related to the concept of an *equivalence relations* that we covered in chapter 1, except that *symmetry* law is replaced with *antisymmetry*.
|
||||
|
||||
@ -135,7 +135,7 @@ However, including this **o**ther person whom none of us played yet, makes the h
|
||||
|
||||
![Soccer player order - leftover element](../04_order/player_order_leftover.svg)
|
||||
|
||||
This is the main difference between partial and total orders - partial orders cannot provide us with a definite answer of the question who is better than who. But sometimes this is what we need - in sports, as well as in other domains, there isn't always an appropriate way to rate people linearly.
|
||||
This is the main difference between partial and total orders --- partial orders cannot provide us with a definite answer of the question who is better than who. But sometimes this is what we need --- in sports, as well as in other domains, there isn't always an appropriate way to rate people linearly.
|
||||
|
||||
Chains
|
||||
---
|
||||
@ -150,14 +150,14 @@ The chains in an order don't have to be completely disconnected from each other
|
||||
|
||||
![Soccer order - two hierarchies and a join](../04_order/player_order_two_join.svg)
|
||||
|
||||
The above set is not linearly-ordered. This is because, although we know that $d ≤ g$ and that $f ≤ g$, the relationship between $d$ and $f$ is *not* known - any element can be bigger than the other one.
|
||||
The above set is not linearly-ordered. This is because, although we know that $d ≤ g$ and that $f ≤ g$, the relationship between $d$ and $f$ is *not* known --- any element can be bigger than the other one.
|
||||
|
||||
Greatest and least objects
|
||||
---
|
||||
|
||||
Although partial orders don't give us a definitive answer to "Who is better than who?", some of them still can give us an answer to the more important question (in sports, as well as in other domains), namely "Who is number one?" i.e. who is the champion, the player who is better than anyone else. Or, more generally, the element that is bigger than all other elements.
|
||||
|
||||
We call such element the *greatest element*. Some (not all) partial orders do have such element - in our last diagram $m$ is the greatest element, in this diagram, the green element is the biggest one.
|
||||
We call such element the *greatest element*. Some (not all) partial orders do have such element --- in our last diagram $m$ is the greatest element, in this diagram, the green element is the biggest one.
|
||||
|
||||
![Join diagram with one more element](../04_order/join_additional_element.svg)
|
||||
|
||||
@ -204,7 +204,7 @@ The same rules as for the joins apply.
|
||||
Hasse diagrams
|
||||
---
|
||||
|
||||
The diagrams that we use in this section are called "Hasse diagrams" and they work much like our usual diagrams, however they have an additional rule that is followed - "bigger" elements are always positioned above smaller ones.
|
||||
The diagrams that we use in this section are called "Hasse diagrams" and they work much like our usual diagrams, however they have an additional rule that is followed --- "bigger" elements are always positioned above smaller ones.
|
||||
|
||||
In terms of arrows, the rule means that if you add an arrow to a point, the point *to* which the arrow points must always be above the one *from* which it points.
|
||||
|
||||
@ -233,7 +233,7 @@ We saw that when we order numbers by "bigger or equal to", they form a linear or
|
||||
|
||||
![Divides poset](../04_order/divides_poset.svg)
|
||||
|
||||
And it so happens (actually for very good reason) that the join operation again corresponds to an operation that is relevant in the context of the objects - the join of two numbers in this partial order is their *least common multiple*.
|
||||
And it so happens (actually for very good reason) that the join operation again corresponds to an operation that is relevant in the context of the objects --- the join of two numbers in this partial order is their *least common multiple*.
|
||||
|
||||
And the *meet* (the opposite of join) of two numbers is their *greatest common divisor*.
|
||||
|
||||
@ -252,7 +252,7 @@ Given a collection of all possible sets containing a combination of a given set
|
||||
|
||||
In this case the *join* operation of two sets is their *union*, and the *meet* operation is their set *intersection*.
|
||||
|
||||
This diagram might remind you of something - if we take the colors that are contained in each set and mix them into one color, we get the color-blending partial order that we saw earlier.
|
||||
This diagram might remind you of something --- if we take the colors that are contained in each set and mix them into one color, we get the color-blending partial order that we saw earlier.
|
||||
|
||||
![A color mixing poset, ordered by inclusion](../04_order/color_mixing_poset_blend.svg)
|
||||
|
||||
@ -270,7 +270,7 @@ We mentioned order isomorphisms several times already so this is about time to e
|
||||
|
||||
![Divides poset](../04_order/divides_poset_isomorphism.svg)
|
||||
|
||||
When we talk about sets, an isomorphism means just a reversible function. But as orders, besides having their underlying sets, have the arrows that connect them, there is an additional requirement for a pair of functions to form an isomorphism - to be an isomorphism, a function has to *respect those arrows*, in other words it should be *order preserving*. More specifically, applying the function (let's call it F) to any two elements in one set ($a$ and $b$) should result in two elements that have the same corresponding order in the other set (so $a ≤ b$ if $F(a) ≤ F(b)$.
|
||||
When we talk about sets, an isomorphism means just a reversible function. But as orders, besides having their underlying sets, have the arrows that connect them, there is an additional requirement for a pair of functions to form an isomorphism --- to be an isomorphism, a function has to *respect those arrows*, in other words it should be *order preserving*. More specifically, applying the function (let's call it F) to any two elements in one set ($a$ and $b$) should result in two elements that have the same corresponding order in the other set (so $a ≤ b$ if $F(a) ≤ F(b)$.
|
||||
|
||||
Birkhoff's representation theorem
|
||||
---
|
||||
@ -307,7 +307,7 @@ Our color-mixing lattice, has a *greatest element* (the black ball) and a *least
|
||||
|
||||
{% if site.distribution == 'print' %}
|
||||
|
||||
Interlude - semilattices and trees
|
||||
Interlude --- semilattices and trees
|
||||
---
|
||||
|
||||
Lattices are partial orders that have both *join* *and* *meet* for each pair of elements. Partial orders that just have *join* (and no *meet*), or just have *meet* and no *join* are called *semilattices*. More specifically, partial orders that have *meet* for every pair of elements are called *meet-semilattices*.
|
||||
@ -351,11 +351,11 @@ In the previous section, we saw how removing the law of *totality* from the laws
|
||||
|Antisymmetry | X | X | |
|
||||
|Totality | X | | |
|
||||
|
||||
The result is a structure called a *preorder* which is not exactly an order - it can have arrows coming from any point to any other: if a partial order can be used to model who is better than who at soccer, then a preorder can be used to model who has beaten who, either directly (by playing him) or indirectly.
|
||||
The result is a structure called a *preorder* which is not exactly an order --- it can have arrows coming from any point to any other: if a partial order can be used to model who is better than who at soccer, then a preorder can be used to model who has beaten who, either directly (by playing him) or indirectly.
|
||||
|
||||
![preorder](../04_order/preorder.svg)
|
||||
|
||||
Preorders have just one law - *transitivity* $a ≤ b \land b ≤ c \to a ≤ c$ (two, if we count *reflexivity*). The part about the indirect wins is a result of this law. Due to it, all indirect wins (ones that are wins not against the player directly, but against someone who had beat them) are added as a direct result of its application, as seen here (we show indirect wins in lighter tone).
|
||||
Preorders have just one law --- *transitivity* $a ≤ b \land b ≤ c \to a ≤ c$ (two, if we count *reflexivity*). The part about the indirect wins is a result of this law. Due to it, all indirect wins (ones that are wins not against the player directly, but against someone who had beat them) are added as a direct result of its application, as seen here (we show indirect wins in lighter tone).
|
||||
|
||||
![preorder in sport](../04_order/preorder_sports.svg)
|
||||
|
||||
@ -366,7 +366,7 @@ All of that structure arises naturally from the simple law of transitivity.
|
||||
Preorders and equivalence relations
|
||||
---
|
||||
|
||||
Preorders may be viewed as a middle-ground between *partial orders* and *equivalence relations*. As the missing exactly the property on which those two structures differ - (anti)symmetry. Because of that, if we have a bunch of objects in a preorder that follow the law of *symmetry*, those objects form an equivalence relation. And if they follow the reverse law of *antisymmetry*, they form an partial order.
|
||||
Preorders may be viewed as a middle-ground between *partial orders* and *equivalence relations*. As the missing exactly the property on which those two structures differ --- (anti)symmetry. Because of that, if we have a bunch of objects in a preorder that follow the law of *symmetry*, those objects form an equivalence relation. And if they follow the reverse law of *antisymmetry*, they form an partial order.
|
||||
|
||||
| Equivalence relation | Preorder | Partial order |
|
||||
| --- | --- | --- |
|
||||
@ -389,7 +389,7 @@ In short, for every preorder, we can define the *partial order of the equivalenc
|
||||
Maps as preorders
|
||||
---
|
||||
|
||||
We use maps to get around all the time, often without thinking about the fact that that they are actually diagrams. More specifically, some of them are preorders - the objects represent cities or intercections, and the relations represent the roads.
|
||||
We use maps to get around all the time, often without thinking about the fact that that they are actually diagrams. More specifically, some of them are preorders --- the objects represent cities or intercections, and the relations represent the roads.
|
||||
|
||||
![A map as a preorder](../04_order/preorder_map.svg)
|
||||
|
||||
@ -406,21 +406,19 @@ Let's now reformat the preorder that we used in the previous two examples, as Ha
|
||||
|
||||
![A state machine as a preorder](../04_order/preorder_state_machine.svg)
|
||||
|
||||
A specification of a finite state machine consists of a set of states that the machine can have, which, as the name suggest, must be finite and a bunch of transition functions that specify which state do we transition to (often expressed as tables.)
|
||||
A specification of a finite state machine consists of a set of states that the machine can have, which, as the name suggest, must be finite, and a bunch of transition functions that specify which state do we transition to (often expressed as tables.)
|
||||
|
||||
But as we saw, a finite state machine is similar to a preorder with a greatest and least object, in which the relations between the objects are represented by functions.
|
||||
|
||||
Finite state machines are used in organization planning e.g. imagine a process where a given item gets manifactured, gets checked by a quality control person, who, if they find some defficiencies, pass it to the necessary repairing departments and then they check it again and send it for shipping - this process can be modelled by the above diagram.
|
||||
Finite state machines are used in organization planning e.g. imagine a process where a given item gets manifactured, gets checked by a quality control person, who, if they find some defficiencies, pass it to the necessary repairing departments and then they check it again and send it for shipping. This process can be modelled by the above diagram.
|
||||
|
||||
{%endif%}
|
||||
|
||||
<!--
|
||||
|
||||
Or alternatively, a finite state machine is just a preorder with a greatest and least object, in which the relations between the objects are represented by functions.
|
||||
|
||||
https://www.cs.rochester.edu/u/nelson/courses/csc_173/fa/fa.html
|
||||
|
||||
Finite state machines are used in organization planning e.g. imagine a process where an item gets manifactured, gets checked by a quality control person, who, if they find some defficiencies, pass it to the necessary repairing departments and then they check it again and send it for shipping - this process can be modelled by the above diagram.
|
||||
|
||||
|Current State | Input | Next State |
|
||||
|--- | --- | --- |
|
||||
@ -444,7 +442,7 @@ State machines are, however not Turing-complete, that is, they cannot encode any
|
||||
Orders as categories
|
||||
===
|
||||
|
||||
We saw that preorders are a powerful concept, so let's take a deeper look at the law that governs them - the transitivity law. What this law tells us that if we have two pairs of relationship $a ≤ b$ and $b ≤ c$, then we automatically have a third one $a ≤ c$.
|
||||
We saw that preorders are a powerful concept, so let's take a deeper look at the law that governs them --- the transitivity law. What this law tells us that if we have two pairs of relationship $a ≤ b$ and $b ≤ c$, then we automatically have a third one $a ≤ c$.
|
||||
|
||||
![Transitivity](../04_order/transitivity.svg)
|
||||
|
||||
@ -460,11 +458,11 @@ So let's review the definition of a category again.
|
||||
> 1. Each object has to have the identity morphism.
|
||||
> 2. There should be a way to compose two morphisms with an appropriate type signature into a third one in a way that is associative.
|
||||
|
||||
Looks like we have law number 2 covered. What about that other one - the identity law? We have it too, under the name *reflexivity*.
|
||||
Looks like we have law number 2 covered. What about that other one --- the identity law? We have it too, under the name *reflexivity*.
|
||||
|
||||
![Reflexivity](../04_order/reflexivity.svg)
|
||||
|
||||
So it's official - preorders are categories (sounds kinda obvious, especially after we also saw that orders can be reduced to sets and functions using the inclusion order, and sets and functions form a category in their own right.)
|
||||
So it's official --- preorders are categories (sounds kinda obvious, especially after we also saw that orders can be reduced to sets and functions using the inclusion order, and sets and functions form a category in their own right.)
|
||||
|
||||
And since partial orders and total orders are preorders too, they are categories as well.
|
||||
|
||||
@ -489,7 +487,7 @@ If you recall, this is an operation that corresponds to *set inclusion* in the c
|
||||
|
||||
![Joins as coproduct](../04_order/coproduct_inclusion.svg)
|
||||
|
||||
But wait, wasn't there something else that corresponded to set inclusion - oh yes, the *join* operation in orders. And not merely that, but orders are defined in the exact same way as the categorical coproducts.
|
||||
But wait, wasn't there something else that corresponded to set inclusion --- oh yes, the *join* operation in orders. And not merely that, but orders are defined in the exact same way as the categorical coproducts.
|
||||
|
||||
In category theory, an object $G$ is the coproduct of objects $Y$ and $B$ if the following two conditions are met:
|
||||
|
||||
|
@ -18,7 +18,7 @@ So far, we saw many different categories and category types. Let's review them o
|
||||
The category of sets
|
||||
---
|
||||
|
||||
We began by reviewing the mother of all categories - *the category of sets*.
|
||||
We began by reviewing the mother of all categories --- *the category of sets*.
|
||||
|
||||
![The category of sets](../06_functors/category_sets.svg)
|
||||
|
||||
@ -45,7 +45,7 @@ And most importantly, we saw some categories that are *completely made up*, such
|
||||
|
||||
![Finite categories](../06_functors/finite_categories.svg)
|
||||
|
||||
Although they are not useful by themselves, the idea behind them is important - we can draw any combination of points and arrows and call it a category, in the same way that we can construct a set out of every combination of objects.
|
||||
Although they are not useful by themselves, the idea behind them is important --- we can draw any combination of points and arrows and call it a category, in the same way that we can construct a set out of every combination of objects.
|
||||
|
||||
Examining some finite categories
|
||||
---
|
||||
@ -56,7 +56,7 @@ The simplest category is $0$ (enjoy the minimalism of this diagram).
|
||||
|
||||
![The finite category 0](../06_functors/finite_zero.svg)
|
||||
|
||||
The next simplest category is $1$ - it is comprised of one object no morphism besides its identity morphism (which we don't draw, as usual)
|
||||
The next simplest category is $1$ --- it is comprised of one object no morphism besides its identity morphism (which we don't draw, as usual)
|
||||
|
||||
![the finite category 1](../06_functors/finite_one.svg)
|
||||
|
||||
@ -88,7 +88,7 @@ It can alternatively be viewed as two "twin" functions such that each of which e
|
||||
Order isomorphisms
|
||||
---
|
||||
|
||||
Then, in chapter 4, we encountered *order isomorphisms* and we saw that they are like set isomorphisms, but with one extra condition - aside from just being there, the functions that define the isomorphism have to preserve the order of the object e.g. the greatest object of one order should be connected to the greatest object of the other one, the least object of one order should be connected to the least object of the other one, and same for all objects that are in between.
|
||||
Then, in chapter 4, we encountered *order isomorphisms* and we saw that they are like set isomorphisms, but with one extra condition --- aside from just being there, the functions that define the isomorphism have to preserve the order of the object e.g. the greatest object of one order should be connected to the greatest object of the other one, the least object of one order should be connected to the least object of the other one, and same for all objects that are in between.
|
||||
|
||||
![Order isomorphism](../06_functors/order_isomorphism.svg)
|
||||
|
||||
@ -126,11 +126,11 @@ By examining them more closely, we realize that categorical isomorphisms are not
|
||||
|
||||
In the next chapter we will devise a more apt way to define a *two-way connection* between categories. But for this, we need to first examine *one-way connections* between them, i.e. *functors*.
|
||||
|
||||
PS: Categorical isomorphisms are also *very rare in practice* - the only one that comes to mind me is the Curry-Howard-Lambek isomorphism from the previous chapter. That's because if two categories are isomorphic then there is no reason at all to treat them as different categories - they are one and the same.
|
||||
PS: Categorical isomorphisms are also *very rare in practice* --- the only one that comes to mind me is the Curry-Howard-Lambek isomorphism from the previous chapter. That's because if two categories are isomorphic then there is no reason at all to treat them as different categories --- they are one and the same.
|
||||
|
||||
<!--
|
||||
comics:
|
||||
OK, I think I got it - isomorphisms are when you have two similar pictures and you connect the dots.
|
||||
OK, I think I got it --- isomorphisms are when you have two similar pictures and you connect the dots.
|
||||
|
||||
Pretty much.
|
||||
-->
|
||||
@ -146,7 +146,7 @@ In other words, a functor is a phrase that *acts as a function*, only not a func
|
||||
|
||||
Later, one of the inventors of category theory Sanders Mac Lane borrowed the word, to describe a something that *acts as function between categories*, which he defined in the following way:
|
||||
|
||||
> A functor between two categories (let's call them $A$ and $B$) consists of two mappings - a mapping that maps each *object* in $A$ to an object in $B$ and a mapping that maps each *morphism* between any objects in $A$ to a morphism between objects in $B$, in a way that *preserves the structure* of the category.
|
||||
> A functor between two categories (let's call them $A$ and $B$) consists of two mappings --- a mapping that maps each *object* in $A$ to an object in $B$ and a mapping that maps each *morphism* between any objects in $A$ to a morphism between objects in $B$, in a way that *preserves the structure* of the category.
|
||||
|
||||
![Functor](../06_functors/functor.svg)
|
||||
|
||||
@ -155,7 +155,7 @@ Now let's unpack this definition by going through each of its components.
|
||||
Object mapping
|
||||
---
|
||||
|
||||
In the definition above we use the word "mapping" to avoid misusing the word "function" for something that isn't exactly a function. But in this particular case, calling the mapping a function would barely be a misuse - if we forget about morphisms and treat the source and target categories as sets, the object mapping is nothing but a regular old function.
|
||||
In the definition above we use the word "mapping" to avoid misusing the word "function" for something that isn't exactly a function. But in this particular case, calling the mapping a function would barely be a misuse --- if we forget about morphisms and treat the source and target categories as sets, the object mapping is nothing but a regular old function.
|
||||
|
||||
![Functor for objects](../06_functors/functor_objects.svg)
|
||||
|
||||
@ -194,7 +194,7 @@ So this definition translates to the following two *functor laws*
|
||||
|
||||
![Functor](../06_functors/functor_laws_composition.svg)
|
||||
|
||||
And these laws conclude the definition of functors - a simple but, as we will see shortly, very powerful concept.
|
||||
And these laws conclude the definition of functors --- a simple but, as we will see shortly, very powerful concept.
|
||||
|
||||
To see *why* is it so powerful, let's check some examples.
|
||||
|
||||
@ -203,9 +203,9 @@ Diagrams are functors
|
||||
|
||||
> “A sign is something by knowing which we know something more.” — Charles Sanders Peirce
|
||||
|
||||
We will start with an example of a functor that is very *meta* - the diagrams/illustrations in this book.
|
||||
We will start with an example of a functor that is very *meta* --- the diagrams/illustrations in this book.
|
||||
|
||||
You might have noticed that diagrams play a special role in category theory - while in other disciplines their function is merely complementary i.e. they only show what is already defined in another way, here *the diagrams themselves serve as definitions*.
|
||||
You might have noticed that diagrams play a special role in category theory --- while in other disciplines their function is merely complementary i.e. they only show what is already defined in another way, here *the diagrams themselves serve as definitions*.
|
||||
|
||||
For example, in chapter 1 we presented the following definition of functional composition.
|
||||
|
||||
@ -217,7 +217,7 @@ We all see the benefit of defining stuff by means of diagrams as opposed to writ
|
||||
|
||||
> "Suppose you have three objects $a$, $b$ and $c$ and two morphisms $f: b \to c$ and $g: a \to b$..."
|
||||
|
||||
However, it (defining stuff by means of diagrams) presents a problem - definitions in mathematics are supposed to be formal, so if we want to use diagrams as definitions we must first *formalize the definition of a diagram itself*.
|
||||
However, it (defining stuff by means of diagrams) presents a problem --- definitions in mathematics are supposed to be formal, so if we want to use diagrams as definitions we must first *formalize the definition of a diagram itself*.
|
||||
|
||||
So how can we do that? One key observation is that diagrams look as finite categories, as, for example, the above definition looks in the same way as the category $3$.
|
||||
|
||||
@ -248,15 +248,15 @@ Maps are functors
|
||||
|
||||
> A map is not the territory it represents, but, if correct, it has a similar structure to the territory, which accounts for its usefulness. Alfred Korzybski
|
||||
|
||||
Functors are sometimes called "maps" for a good reason - maps, like all other diagrams, are functors. If we consider some space, containing cities and roads that we travel by, as a category, in which the cities are objects and roads between them are morphisms, then a road map can be viewed as category that represent some region of that space, together with a functor that maps the objects in the map to real-world objects.
|
||||
Functors are sometimes called "maps" for a good reason --- maps, like all other diagrams, are functors. If we consider some space, containing cities and roads that we travel by, as a category, in which the cities are objects and roads between them are morphisms, then a road map can be viewed as category that represent some region of that space, together with a functor that maps the objects in the map to real-world objects.
|
||||
|
||||
![A map and a preorder of city pathways](../06_functors/preorder_map_functor.svg)
|
||||
|
||||
In maps, morphisms that are a result of composition are often not displayed, but we use them all the time - they are called *routes*. And the law of preserving composition tells us that every route that we create on a map corresponds to a real-world route.
|
||||
In maps, morphisms that are a result of composition are often not displayed, but we use them all the time --- they are called *routes*. And the law of preserving composition tells us that every route that we create on a map corresponds to a real-world route.
|
||||
|
||||
![A map and a preorder of city pathways](../06_functors/preorder_map_functor_route.svg)
|
||||
|
||||
Notice that in order to be a functor, a map does not have to list *all* roads that exist in real life, and *all* traveling options ("the map is not the territory"), the only requirement is that *the roads that it lists should be actual* - this is a characteristic shared by all many-to-one relationships (i.e. functions).
|
||||
Notice that in order to be a functor, a map does not have to list *all* roads that exist in real life, and *all* traveling options ("the map is not the territory"), the only requirement is that *the roads that it lists should be actual* --- this is a characteristic shared by all many-to-one relationships (i.e. functions).
|
||||
|
||||
Human perception is functorial
|
||||
---
|
||||
@ -267,7 +267,7 @@ My thesis is that to perceive the world around us, we are going through a bunch
|
||||
|
||||
![Perception is functorial](../06_functors/chain.svg)
|
||||
|
||||
You can view this as a progression from simpler to more abstract from categories with less morphisms to categories with more morphisms - we start with the category of pieces of sensory data that have no connections between one another, and proceed to another category where some of these pieces of data are connected. Then, we transfer this structure in another category with even more connections.
|
||||
You can view this as a progression from simpler to more abstract from categories with less morphisms to categories with more morphisms --- we start with the category of pieces of sensory data that have no connections between one another, and proceed to another category where some of these pieces of data are connected. Then, we transfer this structure in another category with even more connections.
|
||||
|
||||
![Perception is functorial](../06_functors/logic_thought.svg)
|
||||
|
||||
@ -278,24 +278,24 @@ Functors in monoids
|
||||
|
||||
So, after this slight detour, we will return to our usual modus operandi:
|
||||
|
||||
Hey, do you know that in group theory, there is this cool thing called *group homomorphism* (or *monoid homomorphism* when we are talking about monoids) - it is a function between the groups' underlying sets which preserves the group operation.
|
||||
Hey, do you know that in group theory, there is this cool thing called *group homomorphism* (or *monoid homomorphism* when we are talking about monoids) --- it is a function between the groups' underlying sets which preserves the group operation.
|
||||
|
||||
So, for example, If the time of the day right now is 00:00 o'clock (or 12 PM) then what would the time be after $n$ hours? The answer to this question can be expressed as a function with the set of integers as source and target.
|
||||
|
||||
![Group homomorphism as a function](../06_functors/group_homomorphism_function.svg)
|
||||
|
||||
This function is interesting - it preserves the operation of (modular) addition: if, 13 hours from now the time will be 1 o'clock and if 14 hours from now it will be 2 o'clock, then the time after (13 + 14) hours will be (1 + 2) o'clock.
|
||||
This function is interesting --- it preserves the operation of (modular) addition: if, 13 hours from now the time will be 1 o'clock and if 14 hours from now it will be 2 o'clock, then the time after (13 + 14) hours will be (1 + 2) o'clock.
|
||||
|
||||
![Group homomorphism](../06_functors/group_homomorphism.svg)
|
||||
|
||||
Or to put it formally, if we call it (the function) $F$, then we have the following equation - $F(a + b) = F(a) + F(b)$ (where $+$ in the right-hand side of the equation means modular addition). Because this equation holds, the $F$ function is a *group homomorphism* between the group of integers under addition and the group of modulo arithmetic with base 11 under modular addition (where you can replace 11 with any other number).
|
||||
Or to put it formally, if we call it (the function) $F$, then we have the following equation: $F(a + b) = F(a) + F(b)$ (where $+$ in the right-hand side of the equation means modular addition). Because this equation holds, the $F$ function is a *group homomorphism* between the group of integers under addition and the group of modulo arithmetic with base 11 under modular addition (where you can replace 11 with any other number).
|
||||
|
||||
|
||||
The groups don't have to be so similar for there to be a homomorphism between them. Take, for example, the function that maps any number $n$ to 2 to the *power of $n$,* so $n \to 2ⁿ$ (here, again, you can replace 2 with any other number). This function gives a rise to a group homomorphism between the group of integers under addition and the integers under multiplication, or $F(a + b) = F(a) \times F(b)$.
|
||||
|
||||
![Group homomorphism between different groups](../06_functors/group_homomorphism_addition_multiplication.svg)
|
||||
|
||||
Wait, what were we talking about, again? Oh yeah - group homomorphisms are functors. To see why, we switch to the category-theoretic representation of groups and revisit our first example and (to make the diagram simpler, we use $mod2$ instead of $mod11$).
|
||||
Wait, what were we talking about, again? Oh yeah --- group homomorphisms are functors. To see why, we switch to the category-theoretic representation of groups and revisit our first example and (to make the diagram simpler, we use $mod2$ instead of $mod11$).
|
||||
|
||||
![Group homomorphism as a functor](../06_functors/group_homomorphism_functor.svg)
|
||||
|
||||
@ -304,7 +304,7 @@ It seems that when we view groups/monoid as one-object categories, a group/monoi
|
||||
Object mapping
|
||||
---
|
||||
|
||||
Groups/monoids have just one object when viewed as categories, so there is also only one possible object mapping between any couple of groups/monoids - one that maps the (one and only) object of the source group to the object of the target group (not depicted in the diagram).
|
||||
Groups/monoids have just one object when viewed as categories, so there is also only one possible object mapping between any couple of groups/monoids --- one that maps the (one and only) object of the source group to the object of the target group (not depicted in the diagram).
|
||||
|
||||
Morphism mapping
|
||||
---
|
||||
@ -326,7 +326,7 @@ And many algebraic operations satisfy this equation, for example the functor law
|
||||
Functors in orders
|
||||
===
|
||||
|
||||
And now let's talk about a concept that is completely unrelated to functors, nudge-nudge (hey, bad jokes are better than no jokes at all, right?) In the theory of orders, we have the concept of functions between orders (which is unsurprising, given that orders, like monoids/groups, are based on sets) and one very interesting type of such function, which has applications in calculus and analysis, is a *monotonic function* (also called *monotone map*) - this is a function between two orders that *preserves the order of the objects in the source order, in the target order. So a function $F$ is monotonic when for every $a$ and $b$ in the source order, if $a ≤ b$ then $F(a) ≤ F(b)$.
|
||||
And now let's talk about a concept that is completely unrelated to functors, nudge-nudge (hey, bad jokes are better than no jokes at all, right?) In the theory of orders, we have the concept of functions between orders (which is unsurprising, given that orders, like monoids/groups, are based on sets) and one very interesting type of such function, which has applications in calculus and analysis, is a *monotonic function* (also called *monotone map*). This is a function between two orders that *preserves the order of the objects in the source order, in the target order. So a function $F$ is monotonic when for every $a$ and $b$ in the source order, if $a ≤ b$ then $F(a) ≤ F(b)$.
|
||||
|
||||
For example, the function that maps the current time to the distance traveled by some object is monotonic because the distance traveled increases (or stays the same) as time increases.
|
||||
|
||||
@ -346,7 +346,7 @@ Like with categories, the object mapping of an order is represented by a functio
|
||||
Morphism mapping
|
||||
---
|
||||
|
||||
With monoids, the object mapping component of functors was trivial. Here is the reverse - the morphism mapping is trivial - given a morphism between two objects from the source order, we map that morphism to the morphism between their corresponding objects in the target order. The fact that the monotonic function respects the order of the elements, ensures that the latter morphism exists.
|
||||
With monoids, the object mapping component of functors was trivial. Here is the reverse: the morphism mapping is trivial - given a morphism between two objects from the source order, we map that morphism to the morphism between their corresponding objects in the target order. The fact that the monotonic function respects the order of the elements, ensures that the latter morphism exists.
|
||||
|
||||
Functor laws
|
||||
---
|
||||
@ -375,11 +375,11 @@ But because in orders there can be just one morphism between $F(a)$ and $F(c)$ s
|
||||
Linear functions
|
||||
===
|
||||
|
||||
OK, enough with this abstract nonsense, let's talk about "normal" functions - ones between numbers.
|
||||
OK, enough with this abstract nonsense, let's talk about "normal" functions --- ones between numbers.
|
||||
|
||||
In calculus, there is this concept of *linear functions* (also called "degree one polynomials") that are sometimes defined as functions of the form $f(x) = xa$ i.e. ones that contain no operations other than multiplying the argument by some constant (designated as $a$ in the example).
|
||||
|
||||
But if we start plotting some such functions we will realize that there is another way to describe them - their graphs are always comprised of straight lines.
|
||||
But if we start plotting some such functions we will realize that there is another way to describe them --- their graphs are always comprised of straight lines.
|
||||
|
||||
![Linear functions](../06_functors/linear_functions.svg)
|
||||
|
||||
@ -414,7 +414,7 @@ $f(x) + f(y) = f(x + y)$
|
||||
|
||||
And if we view that natural numbers as an order, linear functions are also functors as well, as all functions that are plotted with straight lines are obviously monotonic.
|
||||
|
||||
Note, however, that not all functions that are plotted straight lines preserve addition - functions of the form $f(x) = x * a + b$ in which $b$ is non-zero, are also straight lines (and are also called linear) but they don't preserve addition.
|
||||
Note, however, that not all functions that are plotted straight lines preserve addition --- functions of the form $f(x) = x * a + b$ in which $b$ is non-zero, are also straight lines (and are also called linear) but they don't preserve addition.
|
||||
|
||||
![Linear functions](../06_functors/linear_function_non_functor.svg)
|
||||
|
||||
@ -435,7 +435,7 @@ Types in programming language form a category, associated to that category are s
|
||||
|
||||
![A functor in programming](../06_functors/functor_programming.svg)
|
||||
|
||||
But let's start with the basics - defining the concept of a functor in programming context is as simple as changing the terms we use, according to the table in chapter 2 (the one that compares category theory with programming languages), and (perhaps more importantly) changing the font we use in our formulas from "modern" to "monospaced".
|
||||
But let's start with the basics: defining the concept of a functor in programming context is as simple as changing the terms we use, according to the table in chapter 2 (the one that compares category theory with programming languages), and (perhaps more importantly) changing the font we use in our formulas from "modern" to "monospaced".
|
||||
|
||||
> A functor between two categories (let's call them `A` and `B`) consists of a mapping that maps each ~~object~~ *type* in `A` to a type in `B` and a mapping that maps each ~~morphism~~ *function* between types in `A` to a function between types in `B`, in a way that preserves the structure of the category.
|
||||
|
||||
@ -444,7 +444,7 @@ Comparing these definitions makes us realize that mathematicians and programmers
|
||||
Type mapping
|
||||
---
|
||||
|
||||
The first component of a functor is a mapping that converts one type (let's call it `A`) to another type (`B`). So it is *like a function, but between types*. Such constructions are supported by almost all programming languages that have static type checking in the first place - they go by the name of *generic types*. A generic type is nothing but a function that maps one (concrete) type to another (this is why generic types are sometimes called *type-level functions*).
|
||||
The first component of a functor is a mapping that converts one type (let's call it `A`) to another type (`B`). So it is *like a function, but between types*. Such constructions are supported by almost all programming languages that have static type checking in the first place --- they go by the name of *generic types*. A generic type is nothing but a function that maps one (concrete) type to another (this is why generic types are sometimes called *type-level functions*).
|
||||
|
||||
![A functor in programming - type mapping](../06_functors/functor_programming_objects.svg)
|
||||
|
||||
@ -453,7 +453,7 @@ Note that although the diagrams they look similar, a *type-level* function is co
|
||||
Function mapping
|
||||
---
|
||||
|
||||
So the type mapping of a functor is simply a generic type in a programming language (we can also have functors between two generic types, but we will review those later). So what is the *function mapping* - that is a mapping that convert any function operating on simple types, like $string \to number$ to a function between their more complex counterparts e.g. $List\ string \to List\ number$.
|
||||
So the type mapping of a functor is simply a generic type in a programming language (we can also have functors between two generic types, but we will review those later). So what is the *function mapping* --- this is a mapping that convert any function operating on simple types, like $string \to number$ to a function between their more complex counterparts e.g. $List\ string \to List\ number$.
|
||||
|
||||
![A functor in programming - function mapping](../06_functors/functor_programming_morphisms.svg)
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
---
|
||||
layout: default
|
||||
title: Natural transformations
|
||||
---
|
||||
@ -6,31 +7,31 @@ title: Natural transformations
|
||||
Natural transformations
|
||||
===
|
||||
|
||||
> I didn’t invent categories to study functors; I invented them to study natural transformations. - Saunders Mac Lane
|
||||
> I didn’t invent categories to study functors; I invented them to study natural transformations. --- Saunders Mac Lane
|
||||
|
||||
In this chapter, we will introduce the concept of a morphism between functors or *natural transformation*. Understanding natural transformations will enable us to define category equality and some other advanced concepts.
|
||||
|
||||
Natural transformations really are at the heart of category theory - As a matter of fact, category theory was invented with the purpose of studying natural transformations. However, the importance of natural transformations is not obvious at first, and so, before introducing them, I like to talk about the body of knowledge that this heart maintains (I am good with methaphors... in principle).
|
||||
Natural transformations really are at the heart of category theory --- As a matter of fact, category theory was invented with the purpose of studying natural transformations. However, the importance of natural transformations is not obvious at first, and so, before introducing them, I like to talk about the body of knowledge that this heart maintains (I am good with methaphors... in principle).
|
||||
|
||||
Objects are overrated
|
||||
===
|
||||
|
||||
> The world is the collection of facts, not of things. - Ludwig Wittgenstein
|
||||
> The world is the collection of facts, not of things. --- Ludwig Wittgenstein
|
||||
|
||||
Objects are all around us, everything we "see", both literary (in real life), or metaphorically (in mathematics), can be viewed as an object. Because of this, we might be inclined to think, as many other people do, that the key to understanding the world is understanding *what objects are*. This is what set theory does, from one standpoint - the main (we may say the only) atomic concept in set theory is a concept of a set. When mathematicians say that "everything is a set", they are saying that *all objects can be represented by sets* (and morphisms can be represented by sets as well).
|
||||
Objects are all around us, everything we "see", both literary (in real life), or metaphorically (in mathematics), can be viewed as an object. Because of this, we might be inclined to think, as many other people do, that the key to understanding the world is understanding *what objects are*. This is what set theory does, from one standpoint --- the main (we may say the only) atomic concept in set theory is a concept of a set. When mathematicians say that "everything is a set", they are saying that *all objects can be represented by sets* (and morphisms can be represented by sets as well).
|
||||
|
||||
However, there is another way to look at things. What is an object, when viewed by itself? Can we study an object in isolation and will there anything left to study about it, once it is detached from its environment? Asking such questions might lead us to suspect that, although what we *see* when we look at the world are the objects, it's *functions* that are the real key to understanding it.
|
||||
|
||||
When we think hard about everyday objects we realize that each of them has a specific *function* or functions without which, it would not be itself. Is a lamp that doesn't glow still a lamp? Is there food that is non-edible (or an edible item that isn't food)? And this is even more valid for mathematical objects, which , Without the functions that go between them, are not objects at all.
|
||||
When we think hard about everyday objects we realize that each of them has a specific *function* or functions without which, it would not be itself. Is a lamp that doesn't glow still a lamp? Is there food that is non-edible (or an edible item that isn't food)? And this is even more valid for mathematical objects, which, without the functions that go between them, are not objects at all, for example, in logic, we say there exist an object such that so and so (existential qualifiers).
|
||||
|
||||
So instead of thinking about objects that just happen to have some morphisms between them, we might take the opposite view and say *that objects are only interesting as sources and targets of morphisms.*
|
||||
|
||||
This view is deeply engrained in category theory. For example, when we say that a given property defines an object *up to a unique isomorphism* what we mean is exactly this - that if there are two or more objects that are isomorphic to one another and have exactly the same morphisms from/to all other objects in the category, then these objects are, for all intends and purposes, equivalent. And the key to understanding how this works are natural transformations.
|
||||
This view is deeply engrained in category theory. For example, when we say that a given property defines an object *up to a unique isomorphism* what we mean is exactly this --- that if there are two or more objects that are isomorphic to one another and have exactly the same morphisms from/to all other objects in the category, then these objects are, for all intends and purposes, equivalent. And the key to understanding how this works are natural transformations.
|
||||
|
||||
Equivalence of categories
|
||||
===
|
||||
|
||||
So, are you ready to hear about natural transformations? Actually it is my opinion that you are not, so I would like to continue with something else. Let's ask ourselves the same question that we were poundering at the beginning of the previous chapter - what does it mean for two categories to be equal.
|
||||
So, are you ready to hear about natural transformations? Actually it is my opinion that you are not, so I would like to continue with something else. Let's ask ourselves the same question that we were poundering at the beginning of the previous chapter --- what does it mean for two categories to be equal.
|
||||
|
||||
We said that categorical isomorphism is somewhat too rigid to accurately capture the concept of equality. This is because (though it may seem contradictory) in isomorphic categories, *isomorphic objects aren't considered equal*, and so this concept goes against the idea that functions (and not objects) are the primary concept. For example the following two categories are *not* isomorphic.
|
||||
|
||||
@ -40,7 +41,7 @@ So, being isomorphic means that two structures are completely the same. A map is
|
||||
|
||||
![Isomorphic categories](isomorphic_categories.svg)
|
||||
|
||||
But, like we said, in category theory, we specify most concepts by treating isomorphis objects as equal - this is valid for all definitions that are based on universal properties. Or to extend the map example, suppose, that there are two intersections that are positioned in such a way that for every road that goes to and from one of them, there is an identical road to the other one (maybe the one of these intercection was meant to replace the other one but it wasn't closed). Then suppose that you have a map which displays these two intercections as one and the same intercection.
|
||||
But, like we said, in category theory, we specify most concepts by treating isomorphis objects as equal --- this is valid for all definitions that are based on universal properties. Or to extend the map example, suppose, that there are two intersections that are positioned in such a way that for every road that goes to and from one of them, there is an identical road to the other one (maybe the one of these intercection was meant to replace the other one but it wasn't closed). Then suppose that you have a map which displays these two intercections as one and the same intercection.
|
||||
|
||||
![Non-isomorphic categories](non_isomorphic_categories.svg)
|
||||
|
||||
@ -83,12 +84,12 @@ We know that natural transformations are morphisms between functors, so let's dr
|
||||
|
||||
![Two functors](natural_functors_objects.svg)
|
||||
|
||||
Note that the functors are similar have the same signature - both their input and output categories are the same - this is a necessary (but not sufficient) condition for them to be connected by a natural transformation.
|
||||
Note that the functors are similar have the same signature --- both their input and output categories are the same --- this is a necessary (but not sufficient) condition for them to be connected by a natural transformation.
|
||||
|
||||
Building the object mapping mapping
|
||||
---
|
||||
|
||||
A functor is comprised of two components - object mapping and morphism mapping, so a natural transformatiom, being a morphism between functors, should take those two mappings into account.
|
||||
A functor is comprised of two components --- object mapping and morphism mapping, so a natural transformatiom, being a morphism between functors, should take those two mappings into account.
|
||||
|
||||
Let's first connect the object mappings of the two functors, creating what we called "object mapping mapping". It is simpler than it sounds when we realize that we only need to connect the object in functors' *target category*. The objects in the source category would just always be the same as both functors would include *all* object from the source category, (because that is what functions do, right?)
|
||||
|
||||
@ -100,7 +101,7 @@ Note that the mappings between these objects do not (always) have the character
|
||||
|
||||
Building the morphism mapping mapping
|
||||
---
|
||||
Once the connections between the object mappings are already established, there is only one way to do the morphism mapping - take each morphism in the source category and connect the two images that this morphism has (generated by the two functors), in the target category.
|
||||
Once the connections between the object mappings are already established, there is only one way to do the morphism mapping --- take each morphism in the source category and connect the two images that this morphism has (generated by the two functors), in the target category.
|
||||
|
||||
![Two functors](natural_functors.svg)
|
||||
|
||||
@ -111,7 +112,7 @@ Before we finish up this chapter, let's distill a rigorous definition of natural
|
||||
|
||||
Furthermore, the mapping must be such that any morphism in $C$ with a signature $X \to Y$, the object $F(X)$ in $D$ should always be mapped to $G(X)$ and object $F(Y)$ should be mapped to $G(Y)$.
|
||||
|
||||
Note that if the condition above (sometimes called the "naturality condition") is met, the below diagram would commute. This works the other way too - if the diagram commutes, the condition is met, so we can say that *the diagram and the definition are isomorphic*. And because the diagram is much simpler we may think of it as the real definition.
|
||||
Note that if the condition above (sometimes called the "naturality condition") is met, the below diagram would commute. This works the other way too --- if the diagram commutes, the condition is met, so we can say that *the diagram and the definition are isomorphic*. And because the diagram is much simpler we may think of it as the real definition.
|
||||
|
||||
![Two functors](natural_transformation_formula.svg)
|
||||
|
||||
@ -120,6 +121,8 @@ If you look just a little bit closely, you will see that the only difference bet
|
||||
Natural transformations again
|
||||
===
|
||||
|
||||
Now that we saw the definition of natural transformations, it is time to see the definition of natural transformations (and if you feel that the quality of the humour in this book is deteoriating, that's only because *things are getting serious*).
|
||||
|
||||
I am sure that once you saw one definition of a natural transformation, you just cannot get enough of them. So let's work out one more. Let's start with our two functors.
|
||||
|
||||
![Two functors](natural_functors.svg)
|
||||
@ -137,7 +140,7 @@ And then take the set of all possible pairs of the objects of these categories.
|
||||
|
||||
![Product category - objects](product_set.svg)
|
||||
|
||||
Is there a way to make a category from that set? Sure, we saw something similar in the chapter about group/monoid products - we just take all morphisms coming from any of the two categories and replicate them to all pairs that feature some objects from their type signature.
|
||||
Is there a way to make a category from that set? Sure, we saw something similar in the chapter about group/monoid products --- we just take all morphisms coming from any of the two categories and replicate them to all pairs that feature some objects from their type signature.
|
||||
|
||||
![Product category](product_category.svg)
|
||||
|
||||
@ -146,11 +149,11 @@ This is the *product category* of the two categories.
|
||||
Natural transformations as functors of product categories
|
||||
---
|
||||
|
||||
When looking into the last diagram, you might suspect that the categories we chose to demonstrate the notion of the product category is not arbitrary. And you would be right - we can already see the naturality square in it.
|
||||
When looking into the last diagram, you might suspect that the categories we chose to demonstrate the notion of the product category is not arbitrary. And you would be right --- we can already see the naturality square in it.
|
||||
|
||||
![Product category](product_category_target_category.svg)
|
||||
|
||||
That is because the category with two objects and one morphism (which, if you remember is called $2$) is the key to constructing a functor that is equivalent to a natural transformation - because it has two objects, it produces two copies of the source category and because the two objects are connected, the two copies are connected in the same way as the two "images" in the target category are connected. And so all that is left is to draw the two functors.
|
||||
That is because the category with two objects and one morphism (which, if you remember is called $2$) is the key to constructing a functor that is equivalent to a natural transformation --- because it has two objects, it produces two copies of the source category and because the two objects are connected, the two copies are connected in the same way as the two "images" in the target category are connected. And so all that is left is to draw the two functors.
|
||||
|
||||
![Product category](product_category_natural_transformation.svg)
|
||||
|
||||
@ -175,7 +178,7 @@ Limits and colimits
|
||||
Interlude: Naturality explained
|
||||
---
|
||||
|
||||
Isomorphism is not hard to construct - given two sets, containing three objects each, there are three isomorphisms that connect them, and that number grows exponentially.
|
||||
Isomorphism is not hard to construct --- given two sets, containing three objects each, there are three isomorphisms that connect them, and that number grows exponentially.
|
||||
|
||||
But most of these isomorphisms, are just random. In our studies we are only interested in structures that *make sense*. In category theory the abstract notion of making sense is captured by the naturality condition.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user