Monoid homomorphisms
Keywords: main

Next: Monoid comprehensions Up: Monoid homomorphisms and comprehensions Previous: Monoid homomorphisms and comprehensions

###
Monoid homomorphisms

Because many operations and data structures are monoids, it is interesting to use the associated concepts as the computational building block of an essential calculus. In particular, iteration over collection types can be elegantly formulated as computing a monoid homomorphism. This notion coincides with the usual mathematical notion of homomorphism, albeit given here from an operational standpoint and biased toward collection monoids. Basically, a monoid homomorphism maps a function f from a collection monoid to any monoid by collecting all the f-images of elements of a -collection using the operation. For example, the expression applied to the list [1,2,1,3,2] returns the set . In other words, the monoid homomorphism of a function f applied to a list Lcorresponds to the following loop computation:

This is formulated formally as follows:

DEFINITION 4.1 (Monoid Homomorphism) A Monoid Homomorphism defines a mapping from a collection homomorphism to any monoid such that by:

for any function , , and , where .

Again, computationally, this amounts to executing the following iteration:

| (1)

The reader may be puzzled by the condition in Definition 4.1. It means that a monoid homomorphisms may only be defined from a collection monoid to a monoid that has at least the same equational theory. In other words, one can only go from an empty theory monoid, to either a -monoid or an -monoid, or yet to a -monoid. This requirement is due to an algebraic technicality, and relaxing it would enable a monoid homomorphism to be ill-defined. To see this, consider going from, say, a commutative-idempotent monoid to one that is commutative but not idempotent. Let us take, for example, . Then, this entails:

The reader may have noticed that this restriction has the unfortunate consequence of disallowing potentially useful computations, notable examples being computing the cardinality of a set, or converting a set into a list. However, this drawback can be easily overcome with a suitable modification of the third clause in Definition 4.1, and other expressions based on it, ensuring that anomalous cases such as the above are dealt with by appropriate tests.

Also of importance for the consistency of Definition 4.1 is the fact that a non-idempotent monoid must be anti-idempotent, and a non-commutative monoid must be anti-commutative. Indeed, if is non-idempotent as well as non-anti-idempotent (say, for some x0), then this entails:

which is not necessarily true for non-idempotent . A similar argument may be given for commutativity. This consistency condition is in fact not restrictive operationally as it is always verified (e.g., a list will not allow partial commutation of any of its element).

Here are a few familar functions expressed with well-defined monoid homomorphisms:

Next: Monoid comprehensions Up: Monoid homomorphisms and comprehensions Previous: Monoid homomorphisms and comprehensions