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

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)

(blank)

3. The whole numbers under addition:

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



(blank)

(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

all functions of the form the identity function

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:

contains the four possible functions from back to itself: 00) The constant function mapping everything to zero: the identity function

the identity function

The identity function is the unit for composition:

Exercise: verify that composition is associative.