# n-ary definition of monoids and other algebraic structures

I've just started learning abstract algebra and seen the definition of a monoid as a binary operation $$\cdot : X \times X \to X$$ which is associative, meaning $$x(yz) = (xy)z$$ for any $$x, y, z \in X$$ and has an identitity element $$1$$ for which $$1x = x1 = x$$ for all $$x \in X$$.

Due to associativity, a sequence $$x_1 x_2 ... x_n$$ can be reduced to a single $$x \in X$$ by repeatedly applying the binary operation to adjacent elements until only one is left, with associativity implying the order of in which we do this doesn't matter. I find it then more intuitive to think of a monoid as an $$n$$-ary operation $$f : X^* \to X$$,

Now, the generalized associativity law for this definition would be that if we have a list of lists of elements of $$X$$, which we can write as $$(x_{11}x_{12}...x_{1m})(x_{21}x_{22}...x_{2m})...(x_{n1}x_{n2}...x_{nm}),$$ the result of computing this by applying $$f$$ to each list $$x_i$$, and then applying $$f$$ to the resulting list, should be the same as flattening to a single list $$x_{11}x_{12}...x_{1m}x_{21}x_{22}...x_{2m}...x_{n1}x_{n2}...x_{nm}$$ and then applying $$f$$ to this single list (in other words, we can remove the parentheses separating the lists, and get the same result). This implies as a special case not only the original binary associativity law: $$(x)(yz) = xyz = (xy)(z)$$), but also the identity law: $$()(x) = x$$ and $$(x)() = x$$, meaning $$1$$ is just the result of applying $$f$$ to the empty list.

The same idea could then be applied to other structures. For example, a commutative monoid could be described as an $$n$$-ary operation on multisets, with the fact that it's well defined, meaning $$f(\{x_1, x_2, ..., x_n\}) = f(\{x_{\sigma(1)}, x_{\sigma(2)}, ..., x_{\sigma(n)}\})$$ for any permutation $$\sigma$$, having binary commutativity $$xy = yx$$ as a special case, and the "generalized associativity rule" as described above implying identity and associativity.

Structures with two operations, such as rings, could then be defined as a single operation that takes in a multiset of lists of elements of $$x$$, which we can think of as mapping a sum of products expression $$x_{11}x_{12}...x_{1m} + x_{21}x_{22}...x_{2m} + ... + x_{n1}x_{n2}...x_{nm}$$ to a single element of $$X$$. Then, associativity and distributivity could be combined in the generalized statement that if we have a "sum of products of sum of products" expression, instead of evaluating the inner sums of products, and then evaluating the sum of products of the results, we can

1. transform our products of sums (of products) into sums of products by distributing, obtaining a sum of sum of products of products
2. flatten each product of products into a single product list
3. flatten the sum of sums into a single sum multiset

and then evaluate what $$f$$ gives us for this new "distributed and flattened" expression, and this should give us the same result as the first way. The original rules for the binary operations

I realize this isn't really saying anything new, and that the rules for the binary operator imply these generalized rules for the n-ary operator, but I personally find it easier and more intuitive to think of algebraic structures such as vector spaces as an operation taking in a linear combination (set of scalar-vector pairs), and figuring how a linear combination of linear combinations should flatten to a single linear combination to imply the usual axioms, than to remember 8 axioms that come out of nowhere.

Additionally, I could reverse this and think about starting with a structure that has some flattening operation, and seeing what the resulting algebraic structure is. For example, maybe I can define flattening a graph of graphs (a graph whose vertices are graphs) into a single graph turning each edge between graph vertices $$G_1, G_2$$ into edges between every pair of vertices $$v_1 \in G_1$$ and $$v_2 \in G_2$$, and then see what a function that maps graphs with vertices in $$X$$ to a single element of $$X$$ and respects the flattening rule looks like.

If this isn't all completely trivial or useless, I was hoping it has maybe been studied before, but due to being new to algebra and pure math in general, I don't know the right terms to search for. So I guess my question is, is there a standard name for this kind of construction turning a structure along with a "flattening rule" as described above into a type of algebraic structure? Is there any value of seeing what the structures look like for various objects, like with my graph example, and if so where could I find a list of various examples?

• You may be interested in the notion of a clone. Commented Jul 14 at 5:10
• Nice, James! In algebraic topology, the object encoding and algebraic structure is called operad. It is not at all trivial or useless! There are many applications but most of them requires a bit of topology; are you familiar with that? Commented Jul 14 at 7:39

Great question! What you are describing is a powerful and important general idea called a monad. Let me start with the case of monoids first since it's relatively easy to understand concretely: there is a gadget called the list monad

$$L(X) = \bigsqcup_{n=0}^{\infty} X^n$$

which given a set $$X$$ produces the set of lists of elements of $$X$$, which you've written $$X^{\ast}$$. I won't spell out the full definition of a monad here but one of the key features is that they have a "flattening" operation $$L \circ L \to L$$, which for the list monad concatenates a list of lists into a list.

Given a monad we can define what is called an "algebra" for that monad, and algebras for the list monad are exactly monoids. Again I won't spell out the full definition but the key feature is that an algebra $$M$$ is equipped with a function $$L(M) \to M$$; here if $$M$$ is a monoid this packages together all $$n$$-ary multiplications into a single function which given a list of elements of $$M$$ multiplies them all together. Generalized associativity is then given by part of the definition of an algebra over a monad which says that the two natural maps $$L(L(M)) \to M$$ (first concatenate lists then multiply, or first multiply then concatenate-and-multiply) agree, exactly as you've described.

Every algebraic theory and its models can be described in terms of a monad in a way which directly generalizes the above. Given such a theory (commutative monoids, groups, rings, etc.) the corresponding monad $$L$$ sends a set $$X$$ to the free algebra on $$X$$, which is obtained by repeatedly applying all possible operations in the signature of the theory subject to all the equational axioms of the theory. Going through the other examples you've listed:

• The free commutative monoid on a set $$X$$ is the set of multisets of elements of $$X$$, exactly as you've said.
• The free ring on a set $$X$$ is the ring $$\mathbb{Z}[X]$$ of noncommutative polynomials in variables $$x \in X$$ indexed by $$X$$. This is almost but not quite what you wrote; you've described the free semiring on a set $$X$$, which ignores subtraction.
• The free vector space on a set $$X$$ is the set $$k[X]$$ of formal linear combinations of elements of $$X$$, exactly as you've said.

Related to your example of vector spaces, there are some examples where it is significantly easier to describe the entire monad than to try to reduce everything to some operations of small arity. For example there is a monad describing affine spaces where instead of taking all linear combinations we take only affine linear combinations, meaning linear combinations $$\sum a_i x_i$$ where $$\sum a_i = 1$$. Similarly there is a monad describing convex spaces where we take convex linear combinations, meaning real linear combinations $$\sum a_i x_i$$ where $$\sum a_i = 1$$ and $$a_i \ge 0$$. These can be presented using families of binary operations but it's arguably much more annoying and less natural than the case of vector spaces.

Monads, however, turn out to be even more general than this. For example, there is a monad called the ultrafilter monad whose algebras are compact Hausdorff spaces $$X$$; the operation $$\beta X \to X$$, loosely speaking, contains the data of a family of infinitary operations describes how sequences converge in $$X$$, except that "sequences" have to be replaced by something more general.

Generally, the way monads arise in mathematics is via adjoint functors, which are studied in category theory. So if this style of thought appeals to you, you might be interested in studying some category theory; I personally found it extremely helpful for organizing a lot of phenomena in abstract algebra.