## Monoids

A set has no structure. It’s just a collection of things, all of them equally unimportant.

Figure 1. *A set.*

Figure 2. *Another set, the one-element set we’ll call “1.”*

A *function*, or *map*, “goes between” sets. It has a source set (also called the *domain*) and a target set (also called the *range*). To each element of the source set, it assigns an element of the target set. We’ll use the usual shorthand for denoting functions, with the name of the function, a colon, the source set, an arrow, and the target set. Underneath, we’ll write a typical element of the source, an arrow with a small bar at the start, and the element of the target it goes to. For example, consider the function mapping each integer to its double. The integers are denoted by the symbol (German *Zahlen*, “numbers”), so we have

Perhaps the simplest structure we can add to a set is to pick an element of it and make that element important. A *pointed set* is

- a set equipped with
- a function , where 1 is the one-element set

The special element of is given by The name should bring to mind the word “element,” since there’s a different choice for what this map should be for each element of For example, given the set , there are three possible choices for the function corresponding to the three different elements we could pick:

A monoid is a pointed set with a little more structure. Way back in kindergarten, they taught us how to count. We counted fingers and marbles and cookies. We used base 1, unary, tally marks:

Sometimes they had us add things that weren’t the same:

Note that when we add this way, the order matters:

While the number of symbols is the same, the result is not!

It takes a long time to teach kids to abstract the concept of a number that’s independent of the order of the symbols in the result. Since that’s one of the earliest things we learn in math, it’s particularly hard to forget, so when anyone says “addition,” we automatically assume it’s commutative. When we get to sticking things like matrices together, there are a couple of natural ways to do it; the commutative way we call “addition,” and the noncommutative one we call “multiplication.”

The only thing a generic monoid knows how to do is stick things together like a kindergartener who hasn’t abstracted the concept of a number yet. Since (in the general case) that’s noncommutative, we call it “multiplication.” When we learned about multiplication in school, we had to memorize our “times table.” The table had numbers across the top and numbers down the sides. Given a row and a column of the table, we could look up the result of multiplying those two numbers.

A “times table” is a function the set cosists of ordered pairs of elements of a pointed set a row and a column. The output of the function is the value in that cell of the table. When we were memorizing the times table, the easiest row was multiplying by 1. You just got the same thing back! So one of the elements of should behave like 1. And the function tells us which one we should pick!

So that’s one constraint on the table: multiplying by shouldn’t do anything. We call this “obeying the left-and right-unit laws.” When we use real numbers, we write it like this:

so in our multiplication table, we have

The other constraint on the table is that if you’re multiplying three things, it shouldn’t matter in what order you multiply the pairs. We call this “being associative.” For real numbers, it looks like this:

so in our multiplication table, we have

Now we’re ready for the definition: a *monoid* consists of a pointed set where the special point is called the “multiplicative identity,” and a times table that’s associative and obeys the left-and right-unit laws above. Here are several more examples of monoids:

1. The trivial monoid:

2. The free monoid on one element (tally marks under concatenation)

- (blank)

3. The whole numbers under addition:

4. The free monoid on two elements (binary strings under concatenation):

- (blank)
- where is the string followed by the string

5. The reals under multiplication:

- Note: the multiplicative group of real numbers excludes 0, because a group has to have inverses. A monoid does not have to have inverses, so we can include it here.

6. Functions from a set to itself under composition

- all functions of the form
- the identity function
- where is composition of functions:

So, for example, given the set we have

- contains the four possible functions from back to itself:

00) The constant function mapping everything to zero:01) The identity function:

10) The function that toggles the input:

11) The constant function mapping everything to one:

- the identity function

The identity function is the unit for composition:

Exercise: verify that composition is associative.

summerstaysaid, on 2007 October 1 at 7:56 amI like this and I’m glad you’re attempting to create an explanation. I tried to think of things that might improve it.

This mixes too many levels of ability in the same explanation. If you really want to explain it to everyone, you need to start with junior high math and work your way up.

I liked the explanation with the cookies. Maybe you could start with that, and use it as an example whenever you start a new concept.

Avoid words like monoid, composition, commutitive, etc… In fact, avoid the concepts where possible. Decide the main point you want to get across and don’t go off on too many tangents. Don’t worry about being complete in your explanation. Ordinary people are different from mathematicians that way. Give us the approximate truth first, make us understand it, and put the rigor in a footnote or appendix.

Example 6 is too difficult for now.

No one in the family except for you and me have studied abstract algebra. The whole concept is very tricky to wrap your head around at first. You need to keep emphasizing that this is not “math”in the sense of solving equations, but the study of patterns. You need to explain the idea that there are all kinds of different things that can be “added” or “multiplied” in lots of different ways, and that you’re talking about studying the rules that apply no matter which set or operation you’re using. People are used to the idea that 3+3=6 can refer to 3 apples plus 3 apples or 3 oranges plus 3 oranges, but the idea that + can refer to some other operation is completely new to most people.

Whenever you use an example, use at least two examples. That helps people to see what the examples have in common.

Don’t show the completely trivial example first. Its okay to show it later, after people have the idea in their heads how it usually works.

Repeat yourself often. Tell us what you are going to explain, explain it, and then tell us what you just explained.

Monoids: What They Are « Ireneo’s Memorysaid, on 2008 April 29 at 1:43 am[…] Monoids: What They Are April 29, 2008 at 8:43 am | In Mathematics | Tags: computer science, logic, math, Mathematics, monoids Curious about monoids? Learn more here! […]

Link (1) « .junksaid, on 2009 April 24 at 1:51 pm[…] Link (1) Daca esti interesat de structuri algebrice, uite un post introductiv despre monoizi aici. […]

drozzysaid, on 2011 December 19 at 11:55 amGreat article!

Is it also possible to make “m(a,b) = a composed b” as opposed to “b composed a”?

reperiendisaid, on 2011 December 19 at 1:52 pmSure! It’s called the “opposite monoid”.