diff --git a/03_categories/arrows.svg b/03_categories/arrows.svg
index 85646cf..2f3f667 100644
--- a/03_categories/arrows.svg
+++ b/03_categories/arrows.svg
@@ -1 +1,120 @@
-
\ No newline at end of file
+
+
diff --git a/03_categories/set_arrows.svg b/03_categories/set_arrows.svg
index 90d8753..ea530b1 100644
--- a/03_categories/set_arrows.svg
+++ b/03_categories/set_arrows.svg
@@ -1 +1,205 @@
-
+
+
diff --git a/04_monoids/addition_commutative.svg b/04_monoids/addition_commutative.svg
new file mode 100644
index 0000000..5ba418d
--- /dev/null
+++ b/04_monoids/addition_commutative.svg
@@ -0,0 +1,201 @@
+
+
diff --git a/04_monoids/balls.svg b/04_monoids/balls.svg
new file mode 100644
index 0000000..cf2e738
--- /dev/null
+++ b/04_monoids/balls.svg
@@ -0,0 +1,132 @@
+
+
diff --git a/04_monoids/balls_arithmetic.svg b/04_monoids/balls_arithmetic.svg
new file mode 100644
index 0000000..512d28b
--- /dev/null
+++ b/04_monoids/balls_arithmetic.svg
@@ -0,0 +1,238 @@
+
+
diff --git a/04_monoids/balls_associativity.svg b/04_monoids/balls_associativity.svg
new file mode 100644
index 0000000..3c7b76b
--- /dev/null
+++ b/04_monoids/balls_associativity.svg
@@ -0,0 +1,251 @@
+
+
diff --git a/04_monoids/balls_identity.svg b/04_monoids/balls_identity.svg
new file mode 100644
index 0000000..5c59d8a
--- /dev/null
+++ b/04_monoids/balls_identity.svg
@@ -0,0 +1,115 @@
+
+
diff --git a/04_monoids/balls_rule.svg b/04_monoids/balls_rule.svg
new file mode 100644
index 0000000..f854dcb
--- /dev/null
+++ b/04_monoids/balls_rule.svg
@@ -0,0 +1,115 @@
+
+
diff --git a/04_monoids/monoid_commutative.svg b/04_monoids/monoid_commutative.svg
new file mode 100644
index 0000000..e7e6933
--- /dev/null
+++ b/04_monoids/monoid_commutative.svg
@@ -0,0 +1,172 @@
+
+
diff --git a/04_monoids/numbers_addition.svg b/04_monoids/numbers_addition.svg
new file mode 100644
index 0000000..e75d1b3
--- /dev/null
+++ b/04_monoids/numbers_addition.svg
@@ -0,0 +1,152 @@
+
+
diff --git a/04_monoids/numbers_multiplication.svg b/04_monoids/numbers_multiplication.svg
new file mode 100644
index 0000000..2d878b2
--- /dev/null
+++ b/04_monoids/numbers_multiplication.svg
@@ -0,0 +1,152 @@
+
+
diff --git a/04_monoids/text.md b/04_monoids/text.md
index 888c575..86d57e9 100644
--- a/04_monoids/text.md
+++ b/04_monoids/text.md
@@ -7,48 +7,59 @@ Since we are done with categories, let's look at some other structures that are
What are monoids
===
-Monoids are simpler than categories. A monoid is defined by a collection (set) of objects and an operation that allows us to combine two objects and produce a third one of the same kind.
-
-The monoid operation
----
+Monoids are simpler than categories. A monoid is defined by a collection (set) of elements and an operation that allows us to combine two element and produce a third one of the same kind.
Let's take our familiar colourful balls.
[Balls](balls.svg)
-In this case a monoid would be a rule (operation) for "combining" two balls into one where the rule should (like functional composition) be "associative" i.e. applying it on the same number of elements in a different order should make no difference.
+In this case a monoid would be a rule (operation) for "combining" two balls into one.
An example of such rule would be blending the colors of the balls, as if we are mixing paint.
[A rule for combining balls](balls_rule.svg)
-You can probably think of other ways to define such a rule. This will help you realize that there can be many ways to create a monoid from the same set of items. The monoid is not the set itself, it is the set *together with the rule*.
+You can probably think of other ways to define such a rule. This will help you realize that there can be many ways to create a monoid from a given set of items. The monoid is not the set itself, it is the set *together with the rule*.
+
+Associativity
+---
+
+The monoid rule should, like functional composition, be "associative" i.e. applying it on the same number of elements in a different order should make no difference.
+
+[Associativity in the color mixing operation](balls_associativity.svg)
+
+When a rule is associative, this means we can use all kinds of algebraic operations to any sequence of terms (or in other words to apply equation reasoning), like for example we can add or remove a term that is present at both sides of an equation and retaining the equality of the existing terms:
+
+[Associativity in the color mixing operation](balls_arithmetic.svg)
The identity element
---
-Actually, not any (associative) rule for combining elements makes them form a monoid (it makes them form a "semigroup", which is also a thing, but I won't go into that). In order to be a monoid, a collection must feature what is called an "identity element" of a given rule (or a zero element, if you prefer) - one that dissapears when combined with other element. So the identity element **i** is such that when you combine any element with the identity element, the result would be that 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.
+Actually, not any (associative) rule 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). In order to be a monoid, a set must feature what is called an "identity element" of a given rule (or a *zero* element, if you prefer) - one 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 color white, represented by the white ball:
[The identity element of the color-mixing monoid](balls_identity.svg)
-If you remember from the last chapter that functional composition is also associative and that it also contains an identity element, you might start suspecting that it forms a monoid in some way, and that is really the case (if this book were a whodunit pulp fiction, it would be a really bad one) We will go into more details later.
+As you probably remember from the last chapter, functional composition is also associative and it also contains an identity element, so you might start suspecting that it forms a monoid in some way. And it is really the case with one little caveat.
-Some basic examples
+To keep the suspense alive, let's see some simpler monoids before we dwelve into that:
+
+Basic monoids
===
+
Monoids from numbers
---
-Mathematics is not all about numbers, but you can numbers do pop in in most areas of mathematics and monoids are no exception. The set of natural numbers *N* form a monoid, when combined with the all to familiar operation of addition.
+Mathematics is not all about numbers, however numbers do tend to pop up in most of its areas and monoids are no exception. The set of natural numbers *N* form a monoid when combined with the all too familiar operation of addition (or to use the official terminology *N* *form* a monoid *under* addition).
[The monoid of numbers under addition](numbers_addition.svg)
-The natural numbers also form a monoid under multiplication (this is another way of saying it).
+(if you see a **1 + 1 = 2** in your texbook you know you are working on math foundations(or you are in kindergarden)).
+
+The natural numbers also form a monoid under multiplication as well:
[The monoid of numbers under multiplication](numbers_multiplication.svg)
-To get the correct intuition about monoids, it's best to think of numbers not as quantities, but as operations, e.g. **+ 1** ** x 1** etc.
-
**Task:** Which are the identity elements of those monoids?
**Task:** Go through other mathematical operations and figure out why don't they are not monoidal.
@@ -56,9 +67,7 @@ To get the correct intuition about monoids, it's best to think of numbers not as
Monoids from boolean operations
---
-Thinking about other operations that we have covered (operation being a function which takes a pair of element of a given type and returns one element of the same type), we may remember the boolean operations **AND** and **OR**. which operate on the set, consisting of just two values **{ True, False }**. Those operations form monoids too.
-
-Do those operations form monoids? Proving that they do is easy enough by just ennumerating all cases.
+Thinking about other operations that we covered (operation being a function which takes a pair of element of a given type and returns one element of the same type), we may remember the boolean operations **AND** and **OR**. which operate on the set, consisting of just two values **{ True, False }**. Those operations form monoids too. Proving that they do is easy enough by just ennumerating all cases.
We can prove that **AND** is associative by expanding the formula **(A AND B) AND C = A AND (B AND C)** in all possible ways:
@@ -74,40 +83,74 @@ And we can prove that **TRUE** is the identity element by expanding the other fo
...and then do the same for **A AND I = A**.
-In general, we can use monoids and related structures as a way to model how a set of (associative) actions that are performed on a given object (or objects) alter it's state. We can do that provided that the object's state is determined solemnly by the actions that are performed on it - this allows us to leave the object out of the equation and concentrate on how the actions are combined.
-
-As per usual in the abstract algebra, the actions (and objects) can be anything, from mixing colors in paint, or adding a quantities to a given set of things.
-
-Other related structures
-===
-
-Monoid actions obey only one rule - they are associative (two if you count the existance of the identity element). In some cases we come across actions that obey other rules that are also interesting. Imposing more (or less) rules to the way in which actions are combinded results in the definition of other monoid-like structures.
-
-Commutative monoids
+Intuitions
---
-Monoids reflect the fact that sometimes the order in which the actions are performed might change the outcome. But sometimes action order does not matter i.e. combining a given set of actions yields the same result no matter which one is first and which one is second. Those operation are called commutative operations. A nice example of this is the addition of quantities - 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 i.e. **x + y = y + x**.
+In order to form the correct intuition about monoids, try to avoid thinking of the elements in the set as objects, but instead think of them as *actions*. For example, when thinking about numbers don't think of them as *quantities* (as in two apples, two oranges etc.), but as *operations*, (e.g. as the action of addding one to a given quantity). In other words, don't think of the element by itself, but only think of it together with the operation (in this case addition).
-Monoids with operations that are commutative are called *commutative monoids*. All monoids that we examined so far are also *commutative*.
+This touches a programming concept which is very popular in category-theory inspired languages - currying - that is based on the idea that a function that accepts two arguments together with one of those arguments already supplied can be viewed as a function which takes one argument. e.g. the function `add(number, number)` together with the element `2` is equivalent to the `addTwo(number)` function.
+
+In general, we use monoids and related structures as a way to model how a set of (associative) actions that are performed on a given object (or objects) alter it's state. We can do that, provided that the object's state is determined solemnly by the actions that are performed on it, this allows us to leave the object out of the equation and concentrate on how the actions are combined. And as per usual in the actions (and objects) can be anything, from mixing colors in paint, or adding a quantities to a given set of things etc.
+
+Other monoid-like objects
+===
+
+Monoid operations obey only one law - they are associative (two, if you count the existence of the identity element). In some cases we come across operations that also obey other rules that are also interesting. Imposing more (or less) rules to the way in which actions are combinded results in the definition of other monoid-like structures.
+
+Commutative 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, namely that the order in which the operations are applied is irrelevant to the end result.
[Commutative monoid operation](monoid_commutative.svg)
-s we discussed, not all monoids are commutative, and we will see some non-commutative ones later.
+Such operations (ones for which combining a given set of objects 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 i.e. **x + y = y + x**.
+
+[Commutative monoid operation](addition_commutative.svg)
+
+All monoids that we examined so far are also *commutative*, and we will see some non-commutative ones later.
Groups
---
-Monoids don't have any rules related to when (and if) a given set of action would result in the object going back in a previous step, i.e. monoid actions are onse that cannot be undone.
-
A group is just a monoid in which each element has what is called an "inverse" element where the element and its inverse cancel each other out when applied one after the other, in other words , **forall x, there must exist x' such that x • x' = i** ( where **i** is the identity element).
+If we view *monoids* as a means of modelling the effect of applying a set of (associative) actions, we use *groups* to model the eeffects of actions are also *reversible*.
+
An nice example of a group can be found in the realm of numbers (really, numbers are a nice example of almost all properties) - it is the set of integers under addition, where the inverse of each number is its opposite number. The above formula, then, becomes **x + (-x) = 0**
-The study of groups is a field that is much bigger than the theory of monoids (and perhaps bigger than category theory itself).
+The study of groups is a field that is much bigger than the theory of monoids (and perhaps bigger than category theory itself). And it all started with the what are now called the "symmetry groups" which we will look into with more details.
+
+Summary
+---
+Here are the algebraic structures that we have seen so far and the laws that they obey.
+
+| | Semigroups | Monoids | Groups |
+|---| --- | --- |
+|Associativity| X | X | X |
+|Identity| | X | X |
+|Invertability | | | X |
+
+Symmetry groups
+===
+
+An interesting set of groups/monoids of *symmetries* of some object
+
+Group of rotations
+---
+
+Group of reflections
+---
+
+Cancellation law
+---
+
+
Categories
----
-A
+===
Some more advanced examples
===
@@ -116,10 +159,6 @@ The trivial monoid
---
Peano arithmetic
-Symmetry monoids
----
-
-An interesting set of groups/monoids (which doesn't look like one at first is) are the groups of symmetries of some object
Monoids as categories
===