# Just How Strong is Associativity?

A friend of mine is using a lot of algebra that is not associative for an advanced Chemistry project. We were discussing it recently and I found it rather amusing how often she said things like "brackets actually exist" and "associativity is really underrated".

She's right, of course. I'm surprised by what's out there. Have a look at this other question on associativity in magma for instance. I'm curious.

So just how strong is associativity? What striking (counter)examples are there of the strength of the assumption that a binary operation is associative?

Thoughts.

This isn't particularly unique to associativity but (who cares? and) a little rewording & emphasis can go a long way.

Let $(S, \cdot)$ be a semigoup. Then by associativity we know that for every single triple $a, b, c\in S$, we have some $d, e\in S$ with $\color{red}{a\cdot b=d}$ and $\color{blue}{b\cdot c=e}$ (by the fact that $\cdot$ is a binary operation) and $$\color{red}{\underbrace{(a\cdot b)}_{d}}\cdot c=\color{red}{d}\cdot c=a\cdot \color{blue}{e}=a\cdot\color{blue}{\overbrace{(b\cdot c)}^{e}}.$$

Moreover, if $\lvert S\rvert=5$, to verify that $S$ is indeed a semigroup, we must consider $\underline{5^3=125}$ triples.

To quote MJD in this answer:

If nothing else, the existence of Light's algorithm seems to rule out the possibility that anyone knows an easy way to [see if a magma is a semigroup] just by looking at the original Cayley table.

Proving associativity of word reduction in the standard construction of the free group over a set is notoriously labour-intensive/tedious.

• What kind of nonassociative algebra is relevant to a chemistry project? – Qiaochu Yuan Nov 15 '14 at 20:43
• She's doing something with matrices. I don't know what exactly. I presume she means in the sense of magmas, so associativity is not necessarily assumed. – Shaun Nov 15 '14 at 20:45
• The rock-paper-scissors example of a commutative, non-associative magma is cute enough to mention here :) – Shaun Nov 19 '14 at 18:23
• @QiaochuYuan, it has something to do with hereditary traits, so there's a lot of Biology in there too. It's something to the effect that if $A, B, C$ are members of a species, then $(A\heartsuit B)\heartsuit C\neq A\heartsuit(B\heartsuit C)$, where $(X\heartsuit Y)$ is the offspring of $X$ and $Y$, except that she's working with genes or something - I don't know. – Shaun Jan 7 '15 at 9:13
• Oh cute: all answers got a downvote for some reason. – rschwieb Jan 12 '15 at 21:54

For all associative binary operations on a set, there is a faithful representation as a sub-semigroup of the semigroup $(X^X,\circ)$ for some set $X$.

That is the nature of associativity, on some level - it is function composition.

This puts us into the area of category theory, too. It would be probably not very useful to do category theory without associativity of composition.

The most basic place I've seen non-associativity is in $\lambda$-calculus and/or combinatory logic, where $ab$ represents application of $a$ to $b$.

If you look at lambda calculus, you can think of it as $a\star b=\phi_a(b)$. That's actually true for all binary operations, of course - we can define $\phi_a(b)=a\star b$. For associative operators, however, we have the lovely feature $\phi_a\circ \phi_b = \phi_{a\star b}$.

A particularly notorious example of non-associative binary operations are addition and multiplication of numbers - when done in a computer using floating point arithmetic. That is, the results of x = a+(b+c); and x=(a+b)+c; may be very different. One needs to be careful in programming additions to avoid excessive rounding errors in such situations.

## Associativity of a binary operation allows us to represent it with mappings

Studying the transformations of a set $X$ into itself (we can write $\mathrm{Hom}(X,X)$) is a very natural thing to do: how can $X$ be rearranged? Its binary operation (function composition) is associative by nature.

In group theory, this leads to Cayley's theorem that every group $G$ is a subgroup of $\mathrm{Sym}(G)\subset \mathrm{Hom}(G,G)$.

But after thinking briefly, you can see that pretty much the same line of thought applies to any semigroup $S$ acting on itself via a binary operation. The only caveat is that you need a condition to ensure $as=bs$ for all $s\in S$ implies that $a=b$ so that the map is injective.

If $S$ is a monoid, or if $S$ is cancellative, then we would get this condition for free, and $S$ can be injected into $\mathrm{Hom}(S,S)$ using the same scheme as Cayley's theorem.

(This block added later:) As pointed out in the comments, it now seems painfully obvious you can adjoin an identity to make any semigroup into a monoid, and then represent the semigroup as a set of endomorphisms of the monoid, so all semigroups are covered as well. So, associativity turns out to characterize which binary operations that can be represented this way and those that can't.

The same could not be said for an operation on a set $X$ which isn't associative. There is no way to find an isomorphic copy of it in $\mathrm{Hom}(Y,Y)$ for any set $Y$ at all.

Nonassociativity means the operation is going to be too pathological for this nice type of representation.

I have the suspicion that one might be able to frame this in terms of representable functors, but after thinking a while (being the armchair category theorist that I am) I couldn't decide if the connection was real.

• I really like this answer. Thanks :) – Shaun Jan 10 '15 at 8:23
• Technically, though, you can represent all semigroups as a sub-semigroup of some $\mathrm{Hom}(Y,Y)$, just not necessarily with $Y$ the same set as $S$, but $Y$ can be made to be either $S$ or $S\sqcup\{\cdot\}$. – Thomas Andrews Jan 11 '15 at 0:46
• And this is all related to the adjunction: $\mathrm{Hom}(X\times Y,Z)\cong \mathrm{Hom}(X,\mathrm{Hom}(Y,Z))$. – Thomas Andrews Jan 11 '15 at 0:49
• Basically, you just add an identity to $S$ if it doesn't have one (or even if it does, if you desire to.) Basically, there is a trivial and functorial way to make a semigroup into a monoid - it is the adjoint of the forgetful functor from monoids to semigroups. @rschwieb – Thomas Andrews Jan 11 '15 at 1:32
• @ThomasAndrews Ah, of course. – rschwieb Jan 11 '15 at 1:50

One of the most important places where non-associativity plays an important role is in computations. A lot of useful algorithms rely on the fact the computational complexity of evaluations is non-associative. For instance, consider a rank $1$ matrix-vector product. Let the matrix $A = uv^T$ and the vector be $x$. Let $u,v,x \in \mathbb{R}^{n\times 1}$. To evaluate $b=Ax$, there are two ways.

1. Evaluate $A=uv^T$. Computational cost is $\mathcal{O}(n^2)$. Now evaluate $b=Ax$ and the computational cost is $\mathcal{O}(n^2)$.
2. Evaluate $a=v^Tx$. Computational cost is $\mathcal{O}(n)$. Now evaluate $b=u \cdot a$ and the associated computational cost is $\mathcal{O}(n^2)$.

If a binary operation is not associative, we lose commutativity of powers of $a$. That is we can't say for instance that $a^2 a=a a^2$. Which means for instance that we don't know the meaning of something like $a^3$, without some additional convention.

Associative and non-associative algebra usual refers to algebras over rings, that is $R$-modules with an additional multiplicative composition.

But I guess you are asking for an arbitrary algebraic systems with one composition, and of course there is no reason at all to suppose that $f(f(x,y),z)=f(x,f(y,z))$ for an arbitrary function $f:X\times X \to X$.

The associativity in algebra often comes from Euclidean geometry and from composition of functions. Any group is a subgroup of a group of automorphisms $A\to A$ for some set $A$. And I guess that important classes of semigroups are sets of functions.