# Is it useful to view magmas as diagrams?

I am new to category theory so please forgive me if this is a silly question.

Classically, a magma is usually defined as an ordered pair $(M,*)$ where

• $M$ is a set, and
• $*$ is a binary operation on $M$.

Here's another point of view. A magma can be viewed as a diagram in the category $\mathsf{Set}$, whose scheme consists of two objects, $A$ and $B$, and three morphisms, $f,g,h : A \rightarrow B$, as well as the identity morphisms, such that

• The two objects $A$ and $B$ are labeled $M^2$ and $M$ respectively, and
• Two of the morphisms $f,g,h : A \rightarrow B$, are labeled by the natural projection maps $\pi_0,\pi_1 : M^2 \rightarrow M$, with the remaining morphism labeled by the composition map $* : M^2 \rightarrow M$.

For precision, lets call diagrams of this kind magma diagrams.

My general question: Does this idea go anywhere?

A few specific questions...

1. Are the natural transformations between magma diagrams precisely the usual magma homomorphisms? I'm sorry if this is a trivial question but my intuition for these sorts of things does not yet exist.

2. How to define things like "The magma diagram $M$ is a monoid," for example? And would it be better to view a monoid as a particular kind of magma diagram, or would a monoid be a different shape diagram altogether?

-

Yes, it does! In the category-theoretic approach to formal logic, models of theories are usually some sort of functor, and theories themselves are usually made into a category of some sort, possibly together with additional conditions.

An approach that is convenient is using sketches. A sketch is a category together with a selection of cones and cocones that are meant to be limits and colimits; so, a model of a sketch is a functor that takes those cones and cocones and maps them to limits and colimits in the target category. (and the morphisms of models are indeed the natural transformations between such functors)

(note how easily this approach lets you define models in categories other than $\mathbf{Set}$!)

e.g. your suggestion about magmas is exactly this. We take the category of the sketch (see wikipedia or ncatlab) to be the one presented by the graph

$$M^2 \begin{matrix}\xrightarrow{p_1}\\\xrightarrow{p_2}\\\xrightarrow{\mu}\end{matrix} M$$

and we specify that the cone

$$M \xleftarrow{p_1} M^2 \xrightarrow{p_2} M$$

should be a limit. A model of this sketch in $\mathbf{Set}$, then, is exactly what you described.

For a monoid, though, we want a different sketch. Also, we should take the more algebraic definition of monoid, where there is a constant $i$ satisfying the axioms of a multiplicative unit, rather than the existential assertion of "there exists a multiplicative unit".

The usual sketch for a monoid needs four objects: $M^0, M^1, M^2, M^3$. We include arrows $M^0 \xrightarrow{i} M^1$ for the identity, and $M^2 \xrightarrow{\mu} M^1$ for the product. But our category also has a commutative diagram

$$\begin{matrix} M^3 & \xrightarrow{\mu \times 1_M}& M^2 \\ \downarrow{1_M \times \mu} & & \downarrow{\mu} \\ M^2 &\xrightarrow{\mu}& M^1 \end{matrix}$$

and similarly, two other diagrams that express the axioms for the multiplicative unit must also commute.

Recall that we can present a category by specifying a graph and taking the free category on that graph, then specifying a set of equations (in the form of commutative diagrams, if we like!) and modding out by the congruence relation that they generate. So the above data really does let us form a category. (But it's not terribly useful to grind through all of the detail of the exact set of morphisms of the category)

Of course, we also specify the set of cones that insist that $M^0$ is a terminal object and $M^2$ and $M^3$ are appropriate products, and we also need to add in the commutative diagrams that insist $\mu \times 1_M$ really is the morphism that gives you $\mu$ and $1_M$ after composing with the appropriate projections, and so forth.

A less convenient approach (but one that doesn't require developing sketches) that works for essentially algebraic theories is to define a theory to be a Cartesian category (i.e. it has all finite limits). Then a model of the theory is a functor from this category that preserves finite limits. Morphisms of models are still natural transformations.

In this approach, though, the categorical theory of magmas $T$ is the opposite category to the category of finitely presented magmas (as defined in the usual set theoretic way).

Other than defining the notion of a Cartesian category presented by a limit sketch, I know of no simpler description of the category described above.

To help wrap your head around this, each finitely presented magma can be thought of as expressing a formal "construction" -- much in the same way the free magma on $n$ objects has the interpretation as being the set of all $n$-ary operations -- and so they give a convenient realization of the category of formal "constructions" one can make from a given magma using products and equalizers. (and magma morphisms give realizations of the relationships between them)

-
Hey, I am very new to category theory, what does the $1_M \times \mu$ denote? And why is $M^3$ needed? – goblin Apr 19 '13 at 9:55
Intuitively $1_M\times \mu$ is the product map $M\times M^2\rightarrow M^2$ which acts as the identity on the first factor and multiplies to two last factors. Explicitly, it is the canonical map induced from $1_M:M\rightarrow M$ and $\mu:M^2\rightarrow M$ by the universal property of the product. $M^3$ is needed because we want to express associativity, and then you need at least three copies of $M$. – Espen Nielsen Apr 19 '13 at 10:12
Okay... there's still something I'm confused about. In the classical approach, a monoid satisfies some equations, but those equations aren't part of the data of the monoid. However, in the approach you describe, it seems that the data of the monoid includes the diagrams which express the different axioms. Is this correct, or have I misunderstood what you're saying? – goblin Apr 19 '13 at 10:33
The data is a diagram, and the axiom is that the diagram commutes! – Zhen Lin Apr 19 '13 at 11:10
@Hurkyl, I'm still not getting it, and I've read your answer like 100 times. In what sense is $M \xleftarrow{p_1} M^2 \xrightarrow{p_2} M$ a cone to the diagram immediately above it? It doesn't seem to be a cone in the sense that wikipedia describes, for example. In fact, why do we even need to specify cones/cocones in the definition of a sketch? – goblin Apr 23 '13 at 3:01

The natural type of category to do this in is a monoidal category. Then we talk about magma objects and monoid objects in that category.

Does it go anywhere? Yes, you are able to introduce algebraic structures in almost arbitrary categories. In cartiesian cateogries, taking suitable hom functors then recovers the classical set-based structure. One immediate advantage to doing algebra like this is that you have a straightforward dualization procedure. Flipping all the arrows in the diagrams describing a structure will give you the corresponding costructure. In your case, you will get a comagma or a comonoid. Many common structures, like Hopf algebras, exploit this idea in their construction.

1. Yes, that's correct. The information carried by the natural transformation $\eta$ is precisely that $$m\circ\eta_{M\otimes M}(a,b)=f(a)f(b)=f(ab)=\eta_M\circ m(a,b)$$

2. A monoid has more structure then a magma, so you need more diagrams, one per axiom. A magma has just about no structure, so its diagram is very simple: $m:M\otimes M\rightarrow M$. For a monoid you also need a diagram to express associativity and one to express the identity element. For the latter, the unit element is replaced by a unit map $\iota:I\rightarrow M$ where $I$ is the unit object in your monoidal category. See here for the diagrams in question.

-
"Taking suitable hom functors then recovers the classical set-based structure." is only true for cartesian categories, not monoidal categories in general. In particular, this does not work for Hopf algebras. – Martin Brandenburg Apr 21 '13 at 18:37
You're right, of course. Thank you for the head's up. – Espen Nielsen Apr 21 '13 at 19:17