Semigroup cleanup on aisle 5

Citation
, XML
Authors
The mathematical definition of a semigroup is, “an algebraic structure consisting of a nonempty set S together with an associative binary operation.” (Wikipedia).

If you are not sufficiently put off by that definition, and still curious as to what a semigroup really is, here goes.

An easy example of a semigroup can be found in any supermarket. The members of this semigroup consist of every possible customer order, from a single bottle of wine to everything in the store. Think of each member of the semigroup as being the contents of a grocery bag. Here are some examples:

Example 1:
1 bottle of Brand X Merlot wine
1 gallon of Acme orange juice

Example 2:
1 gallon of Brand Y milk
1 gallon of Acme orange juice
2 boxes of Kleene laundry detergent

Example 3:
2 bottles of Brand X Merlot wine

Notice that we make a distinction between a grocery bag with one bottle of wine and a grocery bag with two of the same bottle of wine. This is very important in what follows.

Now we need to define the binary operation. This is simply a rule which allows you to feed in two members of the semigroup (their order of feeding matters) and you get a member as a result. So we need to define a way to take two bags of groceries and get one bag as a result.

Well, you guessed it, the rule is simply the bag of groceries consisting of the contents of the first bag combined with the contents of the second bag. If our first input bag contained {1 bottle of Brand X Merlot wine, 1 gallon of Acme orange juice} and the second input bag contained {1 gallon of Brand Y milk, 1 gallon of Acme orange juice, 2 boxes of Kleene laundry detergent}, then we define
{1 bottle of Brand X Merlot wine, 1 gallon of Acme orange juice}
+
{1 gallon of Brand Y milk, 1 gallon of Acme orange juice, 2 boxes of Kleene laundry detergent}
={1 bottle of Brand X Merlot wine, 2 gallons of Acme orange juice, 1 gallon of Brand Y milk, 2 boxes of Kleene laundry detergent}

Here I use the symbol “+” to represent the binary operation, but this choice is arbitrary.

Finally we need to check that our semigroup operation is associative. This just means that if you have three grocery bags, call them A, B, and C, and if we add A and B and then add C to the result, we get exactly the same grocery bag as if we had added A to the result of B+C. It should be clear that this is so.

Therefore our set of members and the bag combining operation satisfy the requirements for a semigroup.