11

I'm trying to understand category theory to increase my coding skills and epimorphism and monomorphism aren't clear to me.
Unfortunately, my last formal education was when I was 12 due to circumstances and I have a hard time understanding algebraic expressions.

I understand what morphisms are and what isomorphism is. $f : X \to Y$ and $g : Y \to X$. Meaning, if there is a morphism going from $X$ to $Y$ then there must be a morphism that goes back and reverses it.

But I don't understand what epimorphism and monomorphism are. Could someone please elaborate in a way a non-mathematician could understand?

Mike Pierce
  • 18,938
J. Reku
  • 213
  • 1
    hm... this is tough to do without writing fluff (as I am finding out.) I assume you dont want tags group theory or general topology. – Andres Mejia Aug 16 '18 at 20:03
  • Perhaps some details about where you are seeing these concepts would help – Andres Mejia Aug 16 '18 at 20:07
  • Just curious - why would learning category theory help your coding? – David C. Ullrich Aug 16 '18 at 20:13
  • 2
    @AndresMejia I can understand pseudo-math, if it looks like code syntax. I understand logic, but when I see symbols like a reversed A and reversed E it's confusing. I understand it must be hard to explain, if there is anything I can do to make it easier I'd love to help. – J. Reku Aug 16 '18 at 20:13
  • 2
    @DavidC.Ullrich Firstly, general curiousity. Secondary, functional programming. I want deep knowledge in FP paradigm. – J. Reku Aug 16 '18 at 20:14
  • 3
    I confess I don't see the connection. Regardless, given that you're saying things like "I have a hard time understanding algebraic expressions", I really doubt that category theory is the place to start learning math! Something less abstract would surely give you a better chance. Like maybe a little "abstract algebra" - groups and so on. After knowing a little math you'd have a chance of understanding what category theory is about... – David C. Ullrich Aug 16 '18 at 20:48
  • 2
    Your whole premise is wrong. You admit "my last formal education was when I was 12". This implies you have no mathematical maturity to even begin to understand category theory. Second, you want "to increase my coding skills" but learning category theory wont help you in that area. FP in no way depends on category theory. The Wikipedia article "Functional programming" only mentions it once in the context of Haskell. – Somos Aug 16 '18 at 21:30

4 Answers4

8

When we were little we learned that $$c+a=c+b \;\;\iff\;\; a=b$$ and the notions of epi- and mono-morphism are the same idea of cancellation but for functions, or morphisms of a category. Simply replace "$+$" with "$\circ$", composition ;-)


Now addition doesn't care about the order of its arguments, it's symmetric: $x + y = y + x$. However this is not the case for morphisms in-general!

As such we have two cancellation properties and we name them

  • epi: $f$ is pre-cancellable, i.e., can be cancelled at the beginning of a composition; i.e., $$g \circ f = h \circ f \;\;\iff\;\; g = h$$
  • mono: $f$ is post-cancellable, i.e., can be cancelled at the end of a composition; i.e., $$f \circ g = f \circ h \;\;\iff\;\; g = h$$

It is interesting to note that we speak of a particular $f$ having such a cancellation property, whereas for numbers we know that the cancellation property holds for all numbers.

Can the same be done for all functions?

No, an immediate counterexample is the always-zero function $Z(x)=0$. It is in-general neither epic nor monic! Hence, for functions these properties do not always hold. As such, we may refine our analogy to be more like multiplication than addition: $$\text{ Provided } c \ne 0: \quad c \times a = c \times b \;\;\iff\;\; a = b$$ Just as "Provided $c$ is non-zero, we have (post)cancellation", we can say "Provided $f$ is monic, we have post-cancellation."


Aside: That $f \circ g \;=\; g \circ f$ is not generally true can be seen by considering a counter example.

Indeed, consider the functions $f(x) = x+1$ and $g(x) = 0$ then $$(f \circ g)(x) = f(g\;x) = f(0) = 1 \;\;\neq\;\; 0 = g(x + 1) = g(f\; x) = (g \circ f)(x)$$

4

I've been recently starting to learn some category theory, and even though it's fairly self-contained (or, at least, the basics are), from it's very construction it was made to generalize situations arising in mathematics (of course, it has afterwards developed an intrinsic importance).

This means that it will be a bit hard to fully get why some things are the way the are without some mathematical examples from other topics.

The definitions state that a morphism $h: X \to Y$ is a monomorphism if and only if for all $f,g : Z \to Y$ we have that $hf = hg$. That is, $h$ embodies left-cancellability in an equality of morphisms. In the same spirit, $h$ will be an epimorphism if $fh = gh$ impies $f = g$ for all $f,g$, that is, we can right-cancel $h$ from an equality of morphisms.

In a way, this is related to the reversibility you had mentioned: if two morphisms are equal after being composed with a monomorphism, then they must be equal. Dually, if two morphisms 'transform' an epimorphism in the same way, they must be the same. That is, epis and monos give us information about other morphisms depending on how they 'change' or 'get changed' by them.

This can give (at least intuitive) information about objets as well. I don't think much else can be said without being a bit technical, but let's try a simple example. Take the integers $\mathbb{Z}$ and the rational numbers (i.e. 'fractions') $\mathbb{Q}$. These are two examples of rings, which intuitively are mathematical objects in which you can sum and multiply as you are used to, but with much more generality. These form a category, $\operatorname{Ring}$, and the morphisms are functions which behave well with respect to sums and multiplication. Concretely, if $R$ and $S$ are objects of $\operatorname{Ring}$, then a morphism between them is a function $f : R \to S$ that verifies

(i) $f(x+y) = f(x) + f(y)$ for all $x$ and $y$ elements of $R$.

(ii) $f(xy) = f(x)f(y)$ for all $x$ and $y$ elements of $R$.

Let's see an example: the inclusion morphism from the integers to the fractions,

$$ \iota : \mathbb{Z} \rightarrow \mathbb{Q} \\ k \mapsto \frac{k}{1} $$

which in a sense, does 'nothing': we are just thinking about the integers in the context of fractions as a special kind of them. However, from the rigid structure that the morphisms of $\operatorname{Ring}$ have, and by that I mean that they verify some strong properties, it is not hard to show that $\iota$ is actually an epimorphism: if $f \iota = g \iota$ , then $f = g$. What this tells us is that it is this category, it is enough to see if two morphisms behave in the same way with the integers, to know if they behave in the same way with any fraction. I hope this gives at least some motivation for the usefulness of this concepts.

qualcuno
  • 17,121
2

In the context of standard algebra, a morphism is a map that is transparent to the laws of structured sets.

For example, let $X = (\mathbb{Z}, +)$, integers with addition, and $Y = (\mathbb{R^*}, \times)$ the reals with standard multiplication. In this case, both structures are groups, but this is not specific to the definition.

Then, a morphism (or homomorphism) $f: X \rightarrow Y$ is a map such that for any $a, b \in \mathbb{N}, f(a+b) = f(a) \times f(b)$. In this case, $f(a), f(b) \in \mathbb{R}$.

An example of this would be $f: a \mapsto 2^a$. The values taken by $f$ include $2^{-1} = 1/2$, $2^3 = 8$ and so on. You can check that $f(a + b) = 2^{a+b} = 2^a2^b = f(a)f(b)$.

Then, an epimorphism is another word for a surjective morphism. A monomorphism is way to denote an injective morphism.

To understand this, you only need the definitions of injectivity and surjectivity.

A function $\phi : A \mapsto B$ is injective if it has the following property: for $a, b \in A$, $\phi(a) = \phi(b) \Rightarrow a = b$. In other word, it cannot map two distinct elements to the same value.

A function $\phi : A \mapsto B$ is surjective if it has the following property: for any $x \in B$, you can find an $a$ in $A$ such that $\phi(a) = x$. In other word, you can build the set $B$ only by applying $\phi$ to the elements of $A$.

In our case, you can check that $f$ is a monomorphism. However, real numbers such as 3 will never be reached by $f$, thus it is not a bijective function, i.e. this is not an epimorphism.

Horace
  • 241
  • In the category of sets, "surjective morphism" is synonymous with "epimorphism", but that's not true in general: for example, $\mathbb{Z} \to \mathbb{Q}$ is an epimorphism of rings. Similarly with injective vs monomorphism, although I think counterexamples are less common. –  Aug 17 '18 at 01:03
  • Good to know, thanks. Although, I am not sure how this will benefit the author in intuitive understanding. – Horace Aug 17 '18 at 07:54
  • This is factually correct, but a bad answer to the question OP asked. They specifically said they don’t know much about maths! – Andrea Aug 17 '18 at 07:57
  • @AndreaDiBiagio I did not use any quantifier to explain the concepts. Do you think I could have used more examples? – Horace Aug 17 '18 at 08:04
  • @Hurkyl apparently this equivalence also holds in the case of groups. – Horace Aug 17 '18 at 08:09
  • @horace I assume that OP is not familiar with $\mathbb{R}, \mathbb{N}$ as symbols. But you did give a few examples, so he could let you know actually. – Andrea Aug 17 '18 at 13:56
1

For me personally, the best analogy involves thinking of information and how different morphisms preserve it.

Recall that a morphism is an "arrow" from a domain object to a codomain object. My mnemonic/analogy is:

  • A monomorphism is a morphism that preserves all the information in its domain
  • An epimorphism is a morphism that reflects all the information in its codomain

Importantly, what "information" means exactly depends on the category we're working with.


Now, it is hard to explain why this analogy works without seeing some concrete mathematical examples, some of which are difficult to explain in layman terms. Even if you don't understand some of the examples, hopefully you will still agree with the general gist which is explained in words above.

When a mathematician first encounters monomorphisms and epimorphisms, usually what they think of is injective and surjective functions between sets, which are the monomorphisms and epimorphisms respectively in the category of sets. And indeed, this makes sense with the information analogy. Keep in mind that the only notion of "information" in the category of sets is how many elements you have, or at most which elements you have. Then:

  • An injective set function $f : A \to B$ is one that doesn't repeat output values. So, to check equality of two elements in $A$ it is enough to check their equality when they're mapped under $f$, because $f(x) = f(y)$ if and only if $x = y$.

    So, when you have two functions $g, h : X \to A$, since checking their equality means checking the equality of each of their outputs, it doesn't matter whether you check it directly ($g = h$) or whether you first map their outputs (which live in $A$) with $f$ to $B$ and then check equality there (i.e. check $fg = fh$). This is the mono property.

    This intuitively means that the information of $A$ is preserved in $B$ via $f$. To be more precise, the image of $A$ under $f$ contains exactly the same information as $A$ itself.

  • A surjective set function $f: A \to B$ is one that attains every possible output value in $B$.

    So, when you have two functions $g, h: B \to Y$, if they agree on all the elements "coming from $A$" (in the sense that $gf = hf$), then they agree on all of $B$ (that is, $g = h$), since any element of $B$ "comes from" an element of $A$ via $f$. This is the epi property.

    This intuitively means that all the (set-theoretical) information of $B$ is reflected in $A$ via $f$.

However, this notion of information preservation/reflection is more general than just injectivity/surjectivity, or rather it's a notion that is determined by the category. Here are a few examples:

  1. In the category of commutative unital rings, the embedding $\mathbb{Z} \hookrightarrow \mathbb{Q}$ is an epimorphism (even though it's not surjective). This is because all the information of $\mathbb{Q}$ as a ring is reflected in $\mathbb{Z}$ via this morphism. What I mean by this is that if you have a ring homomorphism $\phi$ from $\mathbb{Q}$ to some other ring, it is enough to define what it does to integers in order to define it on all of $\mathbb{Q}$, since $\phi(a/b)$ where $a$ and $b$ are integers has to equal $\phi(a)\phi(b)^{-1}$ by the properties of homomorphisms.

    The fact that this map is not surjective tells us in a way that $\mathbb{Q}$ contains redundant information of $\mathbb{Z}$ (as rings).

  2. As a generalization of the previous example, in the category of commutative unital rings, if $R$ is a ring and $S$ any multiplicatively closed subset, the natural map $R \to S^{-1}R$ is an epimorphism.

  3. In the category of connected, path connected, locally connected and locally path connected based topological spaces, a covering map $(\mathbb{R}, 0) \to (S^1, 1)$ (for instance $x \mapsto e^{2\pi i x}$) is a monomorphism (that is nevertheless not injective), because all of the information in the based real line is preserved in the based circle. What I mean by this is that any morphism from $(X, *)$ into the real line is uniquely determined by its projection onto the circle.

    Indeed, since we're working with path-connected etc. etc. spaces, we can have a complete picture of the map by wandering off of the basepoint $*$ and seeing what the image looks like as we go. This will make us wander about the real line, starting at the origin, but since the covering map is a local homeomorphism, any small enough walk in the real line corresponds to a unique walk around the circle, and we can piece all these small pieces together to get an overall unique wander around the circle. Said from another perspective, this means that if we find out what the wander around the circle is under the composite $X \to \mathbb{R} \to S^1$, we can uniquely reconstruct the corresponding wander in the real line.

    The fact that this map is not injective tells us that in this category, in some sense, the real line contains redundant information of the circle. (This makes complete sense if you think of the definition/properties of a covering map.)

  4. The example above generalizes to any non-trivial covering map.

  5. As an algebraic version of a covering map, consider the quotient map $\mathbb{Q} \to \mathbb{Q}/\mathbb{Z}$ in the category of divisible abelian groups. This map is a non-injective monomorphism (see this answer), and in a way it says that to determine a homomorphism of divisible abelian groups to $\mathbb{Q}$ you need only be concerned with the proper fraction part of its output when you write it as a mixed fraction.

  6. In the category of Hausdorff spaces, if $X$ is an object and $U \subsetneq X$ any proper dense subset, then the inclusion $U \hookrightarrow X$ is a (non-surjective) epimorphism, because any continuous function between Hausdorff spaces is uniquely determined by what it does to a dense subset of its domain.

    Again, broadly speaking, this says that all the necessary information of $X$ is already contained in any dense subset thereof.

Anakhand
  • 2,572