Monoids and Monoid Morphisms

Discussion in 'Discussions' started by Kaidelong, Mar 14, 2013.

  1. Kaidelong

    Kaidelong Member

    I am a tad bit drunk right now, but I thought I would bring these two concepts up cause I just love them so much and they're everywhere and they're a shame to miss when you miss them and sometimes it is worth changing around an idea that doesn't have them around to one that does.

    These are abstract mathematical kinds of things from category theory, which is a kind of algebra about algebras, and thus probably really counts as "algebra" at some level, but I do not think of them that way and although I have read and penetrated some of the texts mathematicians wrote they're pretty hard to read and penetrate. The usefulness and love of abstract concepts is thus a tad bit hard to convey since I can't use the formal stuff and wouldn't convey it that way anyway. With enough examples the love develops, which is how it did for me, but you can't just go listing off a bunch of examples either. So the reason I love them I can express is not really the same as the reason I love them, which is running into them all the time (or nearby cases that can easily be changed to them).

    Monoids are a very simple concept. A thing is in a monoid if it can combine with any other element in that monoid and if there is a single element in that monoid it can combine with that doesn't change it in any way. Take for example, colors and alpha blending. A foreground color can be alpha-blended with a background color to get a new background (or foreground, depending on which kind of associativity you want) color ready for another blend. A rather solid red and a unfortunately ethereal teal might make for a pleasingly solid magenta, or something. Or a pleasantly solid but vaguely tealified red. Depends which is the foreground and which is the background. Also, there is a completely transparent color which doesn't do anything if you blend it with another color.

    Monoid morphisms are a little more difficult to explain and the abstract explanation that they map between two monoids isn't very useful. A monoid morphism is basically what enables you to use the monoid properties of some primitive element of your system, like an alpha-blending algorithm, and apply it to something that uses those primitive elements. What is a (raster) image but a grid of pixels? What is a pixel but a color? As it turns out, if the individual things you are putting in a grid form a monoid, you get a monoid for whole grids of those things pretty much for free! Just go and add all the pixels on the same cell positions together! Are they different sizes? No problem, just use the zero element of the underlying monoid as filler for the space on the two grids that don't overlap. That is, pad out stuff with empty pixels on the edges to make them the same size. It's actually slightly better than that, you only need a weaker although closely related restriction on elements called a semigroup to get a monoid out of a grid of elements, really, as adding zero is the same as doing nothing at all anyway.

    Since you decided that individual colors should look like a monoid, your pictures look like a monoid, for the small cost of implementing a monoid morphism (usually in the form of "to add things of p and things of q, make a thing of p added to q, and to get a 0 for things, make a thing of the 0 of their contents"), or for utterly free in some programming languages where some other programmer might have noticed the morphism in the abstract and wrote it down ("instance (Monoid pq) => Monoid (Thing pq) where..."). Plus and zero, a simple concept, easy to work with and extremely versatile. See it at the beginning, and it pops up in variations over and over again even as stuff grows in complexity. So awesome.
     
    OmniaNigrum and Kazeto like this.