# [E-Lang] Operator expansion names, Part 1: Intro

Ralph Hartley hartley@aic.nrl.navy.mil
Tue, 10 Apr 2001 09:03:00 -0400

```Mark S. Miller wrote:

> At 04:28 PM Monday 4/9/01, Bill Frantz wrote:
>
>> Normal addition obeys the rule: a + b equals b + a.  If the goal is to
>> encourage people building types to model the mathematical concepts of group
>> and ring, then we want:
>>
>> If a and b are in T, then a + b is always in T
>> a + 0 equals a
>> a + b equals b + a
>> (a + b) + c equals a + (b + c)
>>
>> My naive belief is that bags and sets obey these rules.
>
If + is union, they do. A set with an operation like that is a
commutative monoid. Leaving out "0" makes a semi-group, and adding
inverses makes a group.

> What's it called when we have these properties except for commutativity?  I
> don't want to specify that "+" is generally commutative.

A non-commutative monoid. Groups (but groups only) are called abelian or
non abelian as well, I don't know why.

It is traditional in mathematics to use "+" ONLY for commutative
operations. Any form of multiplication syntax (whitespace, dot,  cross,
etc. Often you have more than one kind) generally does not imply
commutativity, though some (cross) are less likely to be commutative
than others. I think this is because + is most often used as part of a
pair with a multiplication, (as in a ring, or field), and those don't
usually make sense unless + is commutative.

Mathematicians (which I conceed are a small minority of the target
group) will generally be "surprised" by non commutative addition, but
not mutiplication. Most other people, I'm afraid, will be bothered if
EITHER addition or mutliplication are not commutative. I would have
preferred multiplication syntax for concatenation, but I may not be a
good test audiance for this one.

By the way, non associative operators ( (a op b) op c != a op (b op c) )
are quite rare, need warning labels, and NEVER use "+". Maybe that's why
java's ("a"+1)+2 == "a12" != "a3" == "a"+(1+2) bothers me so much.

Generally, if there is just one kind of multiplication it is usually
whitespace or dot, especially if the product is of the same type as the
factors. Cross often (but not always, for 3 dimensional vectors it is of
the same type) has a result that is a more complex type of object, and
for dot it is often simpler (e. g. scalar product).

Ralph Hartley

```