Expressing associativity with only two variables

To answer the question negatively, it suffices to find an algebra $(A, \cdot)$ such that each subalgebra generated by two elements is associative, but such that $A$ itself is non-associative.

Let $A=\{a,b,c\}$, and let $\cdot$ be defined by $$ab=ba=bb=b\\ bc=cb=cc=c\\ ca=ac=aa=a.$$

Every subset of $A$ of size $2$ is the domain of a subalgebra, isomorphic to $(\{0,1\},\max)$, which is associative. But $A$ is not associative, since $(ab)c = bc = c$, but $a(bc) = ac = a$.


No, this is not possible - and, rather luckily, while it seems like this question could potentially be very hard, this particular instance works out okay.

First, let $F:\mathbf{Set}\rightarrow\mathbf{Magma}$ be the free magma functor. Let $S=\{a,b,c\}$ be a set of three elements and consider $FS$. Let's define an equivalence relation $\sim$ on $FS$ generated by the following relations:

  1. If $p\sim p'$ and $q \sim q'$ then $pq\sim p'q'$.

  2. For any $x,y\in FS$ and any $p,q,r\in \langle x,y\rangle$ we have $p(qr)\sim (pq)r$.

The first condition ensures that we can define multiplication on the quotient $FS/\sim$ and the second condition ensures that every equation in two variables that follows from associativity holds in $FS/\sim$ - or, equivalently, that for every two elements $x,y\in FS/\sim$ there is a map from the free semigroup on two elements to $FS/\sim$ taking the generators to $x$ and $y$ respectively. Note that $\langle x,y\rangle$ refers to generation in $FS$ not in $FS/\sim$.

However, we can prove that $a(bc)\not\sim (ab)c$ without too much trouble because there's just not really any relation we can usefully apply to it. The particularly nice thing about $FS$ is that every element is either a generator, or can uniquely be written as a product of two others.

First, $a$ and $b$ and $c$ are not of the form $pq$, so none of the generating relations apply to them - so their equivalence classes are singletons. Similarly, $ab$ and $bc$ have singletons as equivalence classes because they are products of elements whose equivalence classes are singletons - so (1) applies, but doesn't generate any equivalences. They are not of the form necessary to apply (2).

Finally, let's show that the equivalence class of $a(bc)$ is a singleton. The first rule applies, but doesn't generate any relations because $a$ and $bc$ both have singleton equivalence classes. The second rule only references $a(bc)$ if $p=a$ and $q=b$ and $r=c$ - however, there is no set of two generators that generates all of $\{a,b,c\}$ in $FS$. Thus $a(bc)$ is a singleton - and in particular $a(bc) \not\sim (ab)c$ so $FS/\sim$ is not associative, yet satisfies every two element equation following from associativity.

This reasoning probably extends to answer similar questions of this form, but it seems pretty hard to write down exactly what that generalization would be.