<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\documentclass{article}
\input{packages}
\input{def}

\lecture{Monoids}

\begin{document}
\maketitle

\begin{definition}[(Biased) Monoid]
A tuple $\langle M, *, \prf{a}, e, \prf{i} \rangle$ where the components have the following types:
\begin{framed}
\begin{description}
\item[Underlying Set $M$:] $\Type$
\item[Operator $*$:] $M \times M \to M$ (infix)
\item[Associativity $\prf{a}$:] $\forall m_1, m_2, m_3 : M.\; (m_1 * m_2) * m_3 = m_1 * (m_2 * m_3)$
\item[Identity Element $e$:] $M$
\item[Identity $\prf{i}$:] $\forall m : M.\; e * m = m = m * e$
\end{description}
\end{framed}
\end{definition}

\begin{notation}
We use $M : \Type$ to say what the reader may more familiarly interpret as saying $M$ is a set.
We use $\Type$ to indicate that we do not tie our discussion to any particular set theory.
In particular, in category theory one often needs higher universes (e.g.~the class of all sets, and the conglomerate of all classes), which we will denote with $\TYPE{0}$, $\TYPE{1}$, and so on.
In particular, $\TYPE{i}$ is an element of $\TYPE{i+1}$.
We use $\Type$ as shorthand for $\TYPE{0}$.
Note that all this of course should in fact be polymorphic with respect to universes, but we do not want to get distracted by such details.
\end{notation}

\begin{remark}
We assume proof irrelevance.
That is, all proofs of the same proposition are equal.
This way we can avoid coherence requirements of proofs.
Consequently, often such proofs will be omitted when apparent from context or proven elsewhere, denoted by $\noprf$.
\end{remark}

\begin{notation}
In situations where an infix operator~$*$ is associative, we use $a * b * c$ to denote either of the equal terms $(a * b) * c$ and $a * (b * c)$.
\end{notation}

\begin{example}
\begin{description}
\setlength{\itemsep}{0pt}
\item[$\N_+ =$] $\langle \N, +, \noprf, 0, \noprf \rangle$
\item[$\N_* =$] $\langle \N, *, \noprf, 1, \noprf \rangle$
\item[$\N_{\max} =$] $\langle \N, \max, \noprf, 0, \noprf \rangle$
\item[$\Z_+ =$] $\langle \Z, +, \noprf, 0, \noprf \rangle$
\item[$\Z_* =$] $\langle \Z, *, \noprf, 1, \noprf \rangle$
\item[$\R_+ =$] $\langle \R, +, \noprf, 0, \noprf \rangle$
\item[$\R_* =$] $\langle \R, *, \noprf, 1, \noprf \rangle$
\item[$\N^\infty_+ =$] $\langle \N^\infty, +, \noprf, 0, \noprf \rangle$ where $\N^\infty = \N \uplus \{\infty\}$ and $\forall n : \N^\infty.\; \infty + n = \infty = n + \infty$
\item[$\N^\infty_{\min} =$] $\langle \N^\infty, \min, \noprf, \infty, \noprf \rangle$ where $\forall n : \N^\infty.\; \min(\infty, n) = n = \min(n, \infty)$
\item[$\B_\wedge =$] $\langle \B, \wedge, \noprf, \true, \noprf \rangle$ where $\B$~denotes the Booleans, $\wedge$~denotes Boolean ``and'', and $\true$~denotes the true Boolean
\item[$\B_\vee =$] $\langle \B, \vee, \noprf, \false, \noprf \rangle$ where $\vee$~denotes Boolean ``or'' and $\false$~denotes the false Boolean
\item[$(\List T)_{\append} =$] $\langle \List T, \append, \cdot, \nil, \cdot \rangle$ where $\List T$ denotes (finite) lists of~$T$ and $\append$~denotes list appending
\item[$(\Multiset T)_+ =$] $\langle \Multiset T, +, \cdot, \nil, \cdot \rangle$ where $\Multiset T$ denotes multisets (a.k.a.~bags) of~$T$ and $+$~denotes multiset addition
\item[$(\Finset T)_\cup =$] $\langle \Finset T, \cup, \cdot, \varnothing, \cdot \rangle$ where $\Finset T$ denotes finite subsets of~$T$ and $\cup$~denotes finite-set union
\item[$(\Set T)_\cup =$] $\langle \Set T, \cup, \cdot, \varnothing, \cdot \rangle$ where $\Set T$ denotes subsets of~$T$ and $\cup$~denotes subset union
\item[$(\Set T)_\cap =$] $\langle \Set T, \cap, \cdot, T, \cdot \rangle$ where $\cap$~denotes subset intersection
\item[$(\R\to\R)_{\cocomp} =$] $\langle \R \to \R, \cocomp, \cdot, \lambda x.~x, \cdot \rangle$ where $f \cocomp g = \lambda x. g(f(x))$
\item[$(\R\to\R)_\circ =$] $\langle \R \to \R, \circ, \cdot, \lambda x.~x, \cdot \rangle$ where $f \circ g = \lambda x. f(g(x))$
\end{description}
\end{example}

\begin{notation}
The operator~$\uplus$ denotes disjoint union; we will never use~$\cup$ or union except when the two sets are established to be subsets of some larger set in the context.
Technically, one needs to explicitly inject elements into the left or right parts of a disjoint union, but the injection to use can usually be inferred from context.
\end{notation}

\begin{remark}
Note that many of the above have the same underlying set, and some of those even have the same identity element, but no two have the same operator (where $*$ on $\N$ is not considered the same as $*$ on $\R$ or $\Z$).
\end{remark}

\begin{exercise}
Prove that two monoids are equal if (and only if) their operators are equal (possible only if their underlying sets are equal).
Due to proof irrelevance, this is equivalent to proving that their identity elements are equal.
\end{exercise}

\end{document}</pre></body></html>