Is there a category of partially defined binary operations

abstract-algebracategory-theorymagma

A magma is a set $Y$ with a binary operation $m:Y \times Y \rightarrow Y.$ A partial magma is the same idea, but where the binary operation $m$ may not be defined on some pairs of elements of $Y.$ My question is, is there a category where the objects are partial magmas ? If there is such a category then I would like to know how the arrows are defined, whether the category has any nice properties, and whether there is any literature about the idea. Although any information would be most welcome.

Best Answer

This answer contains three separate ways to do this.

First: a partial magma could be defined as a set $Y$, together with a function $m\colon Y\times Y \to Y + 1$ representing the binary operation, where $1$ is the one-element set and $+$ is the coproduct of sets (disjoint union).

This suggests that a natural notion of morphism between partial magmas $(Y,m)$ and $(Y',m')$ would be a function $f\colon Y\to Y'$ such that $f(m(x,y)) = m'(f(x),f(y))$, for all $x,y\in Y$, as you suggested in the comments.


Another option, which I think is more natural, is to define it as a magma in the category of partial maps. To define that category, take the objects as sets and let a morphism $f\colon X\to Y$ be any function $f\colon X\to Y+1$, so it either returns an element of $X$ or a special element meaning "undefined", which I'll write as $\bot$. Define composition as $$(f;g)(x) = \begin{cases} \bot &\text{if $f(x)=\bot$}\\ g(f(x)) &\text{otherwise.} \end{cases} $$ This is the Kleisli category of what Haskell people call the Maybe monad. We can make it into a symmetric monoidal category by letting $\otimes$ be the Cartesian product of sets on objects, and letting $$ (f\otimes g)((x,y)) = \begin{cases} \bot &\text{if $f(x)=\bot$ or $g(y)=\bot$}\\ (f(x),g(y)) &\text{otherwise.} \end{cases} $$

A magma in this category consists of a set $Y$, together with a partial map $m\colon Y\times Y\to Y$, so it's also a partial magma as you defined it. But now a magma homomorphism from $(Y,m)$ to $(Y',m')$ is a partial function $f\colon Y\to Y'$, such that $f(m(x,y)) = m'(f(x),f(y))$ for all $x,y\in Y$. The difference between this and the other construction above is that $f$ is a partial function, so that $m'(f(x),f(y))$ is allowed to be undefined even if $m(x,y)$ is defined.

As well as seeming more natural, this second solution is probably easier to work with. Being a magma in some category means that many of the things you can prove about magmas will also be true of partial magmas, since the proof will still work unless it relies on some specific property of $\mathsf{Set}$ that isn't shared by the category of partial maps.


It occurs to me that you might want something different to either of the above. You mentioned in a comment that you want to generalise categories, where you see composition as a partial magma on the set of morphisms. In that case it seems like you would want a functor to be a special case of a magma morphism. But functors behave kind of opposite to what I just described. You can have morphisms $f$ and $g$ that aren't composable in a category $\mathscr{C}$, but their images under a functor $F\colon\mathscr{C}\to\mathscr{D}$ are composable in $\mathscr{D}$. But you can't have it the other way around - if two morphisms are not composable in $\mathscr{D}$ then they also have to be non-composable in $\mathscr{C}$.

So perhaps you want a morphism to be a function (not a partial function) $f\colon Y\times Y\to Y$, such that if $m'(f(x),f(y))=\bot$ then $f(m(x,y))=\bot$, otherwise $f(m(x,y))=m'(f(x),f(y))$.

I don't currently know a more abstract way to construct that, or have much intuition about its properties. I'll think about it.

Related Question