Monoid object in “arrows-only” single-sorted definition of a category

category-theorymonoid

There's a way to define a category as "arrows-only" single-sorted.

An object is an identity morphism : a → a

https://ncatlab.org/nlab/show/single-sorted+definition+of+a+category

There are Remarks

Specializations

A monoid is a single-sorted category in which s is a constant function (hence so is t, and they are equal).

So when a monoid object is 5, is it expressed like:

(f → 5)(a → a)

or simply

(a → a)(5)

Thanks.

In Haskell it should be

main :: IO ()
main = do
  print $ (\f -> 5)(\a -> a)
  print $ (\a -> a)(5)

Thanks.

EDIT: to make the problem clearer, I will quote

Categories for the Working Mathematician, I.1 and XII.5.

I.1

enter image description here

XII.5

enter image description here

enter image description here

Best Answer

Consider a category $\mathscr C$ with a single object $X$. Then the one-sorted presentation of $\mathscr C$ will have a collection of morphisms $C = \mathscr C(X, X)$ and functions $s, t : C \to C$ such that $\forall c \in \mathscr C . s(c) = t(c) = \mathrm{id}_X$. That is, $s = t = \lambda c . \mathrm{id}_X$. The composition of morphisms reduces to a binary operation on $C$, because the source and target of each morphism is $\mathrm{id}_X$, and $\mathrm{id}_X$ also acts as an identity for the binary operation. The definition thus reduces exactly to that of a traditional monoid (albeit one with a class of elements, rather than a set of elements, when $\mathscr C$ is not necessarily locally small).

In terms of Haskell, the definition of $s$ and $t$ is therefore given by \c -> id_X, for some id_X.

Therefore, a one-sorted presentation of a category in Haskell may be described by a Monoid, which we will call X, along with two functions s :: X -> X and t :: X -> X. s and t are both defined by \x -> mempty X. (Here, mempty is the identity for the monoid.)

class Monoid m => OneObjectOneSortedCategory m where
  s :: m -> m
  t :: m -> m
  s _ = mempty
  t _ = mempty

-- An example of a monoid as a one-object single-sorted category.
instance OneObjectOneSortedCategory [a]

main = do
  -- Prints `[]`, the identity element.
  print (s [1, 2, 3])

Alternatively, in Rust:

trait OneObjectOneSortedCategory: Sized {
    fn id() -> Self;
    
    fn mul(&self, other: &Self) -> Self;
    
    fn s(&self) -> Self {
        Self::id()
    }
    
    fn t(&self) -> Self {
        Self::id()
    }
}

impl OneObjectOneSortedCategory for i8 {
    fn id() -> i8 {
        0
    }
    
    fn mul(&self, other: &i8) -> i8 {
        self + other
    }
}

fn main() {
    println!("{}", 5.s());
}

Since there's still confusion, let me try rephrasing the following quote, which seems to be the issue.

A monoid is a single-sorted category in which $s$ is a constant function (hence so is $t$, and they are equal).

What does this mean?

If we take a monoid $(M, \otimes, I)$, then we can form a single-sorted category $\mathbf C = M$. The functions $s : \mathbf C \to \mathbf C$ and $t : \mathbf C \to \mathbf C$ are both defined to be the constant function $x \mapsto I$. Therefore, the category $\mathbf C$ has a single object, $I$. The composite $a \circ b$ of two morphisms $a, b \in \mathbf C$ is given by $a \otimes b$. The identity is given by $I \in \mathbf C$.

Alternatively, take a single-sorted one-object category $\mathbf C$. Let $U$ be the object of $\mathbf C$ (i.e. the value of $s(x)$ for any $x \in \mathbf C$). We can define a monoid $(M, \otimes, I)$, where $M = \mathbf C$. Given elements $a, b \in M$, we define their multiplication $a \otimes b := a \circ b$. We define $I := \mathrm{id}_U$.

Therefore, the two presentations are equivalent.

Related Question