Monoids in Category Theory

919 Views Asked by At

I don't have a strong math background (engineering math) so I am at a bit of a disadvantage here but I have been trying to learn the broad strokes of Category Theory to help get a fuller picture of some of the Functional programming languages I use (Haskell, Scala, F#, etc.).

I am reading 'An Introduction to Category Theory' by Harold Simmons and ran into something in the first chapter regarding Monoids that leaves me a bit confused.

He states that a Monoid is a structure $(R, *, 1)$ where $R$ is a set, $*$ is a binary operation on $R$ and $1$ is an element of $R$ that functions as an identity element. So far, so good.

He goes on to state that a monoid morphism between two monoids:

$$p: R \to S$$

is a function that respects the structure of the monoids. He then explains that this means:

$$p(r*s) = p(r) * p(s),\quad\mathrm{and}\quad p(1) = 1$$

where $r$ and $s$ are elements of $R$.

The question I have is that this seems to make certain assumptions: specifically, that $R$ and $S$ are the same monoid. I say this since $p(r)$ is a morphism from $R$ to $S$ and $*$ is defined for $R$, but not necessarily for $S$.

Have I missed something here?

3

There are 3 best solutions below

0
On BEST ANSWER

A more detailed way to write the statment (i.e. without abuse of notation) would be the following:

Let $(R,*_R,1_R)$ and $(S,*_S,1_S)$ be two monoids, then a function $p:R\to S$ is called a monoid morphism if for any $r_1,r_2\in R$ $$p(r_1*_Rr_2) = p(r_1)*_Sp(r_2)$$ and $$p(1_R) = 1_S.$$

However, in most sources the subscript indicating the monoid we're in is left away to ease notation, as it is assumed that the reader can easily deduce it. You'll get used to it, don't worry.

4
On

This is what a mathematician might call abuse of notation and what a computer scientist might call overloading: the * symbol is being used to denote the monoid operation in both $R$ and $S$.

1
On

Why not write this out in Haskell! The monoid type class is defined as

class Monoid m where
  mempty :: m          -- Simmons calls this `1`
  (<>) :: m -> m -> m  -- aka `*`. (Or `mappend`.)

If now the types R and S are monoids, i.e.

instance Monoid R where { ... }
instance Monoid S where { ... }

then a function p :: R -> S is a monoid morphism if p (a<>b) ≡ p a <> p b, and p mempty ≡ mempty. Or, with explicit type annotations,

p (a<>b :: R) :: S
    ≡ (p a :: S) <> (p b :: S)
p (mempty :: R) ≡ (mempty :: S)

Note that the instantiations of <> and mempty belong to different instances of the monoid methods: on the LHS, it's the Monoid R instance, on the RHS it's the Monoid S instance. (Haskell's HM type system infers this by itself, if you don't write out the type signatures explicitly.)