# operation that is commutative but not associative [duplicate]

Does there exist an operation that is commutative but not associative?

do you know what is operation?

Take rock-paper-scissors, for example.

More precisely: $*\colon \{0,1,2\}\times\{0,1,2\} \to \{0,1,2\}$ given by multiplication table

$$\begin{array}{c | c c c} & 0 & 1 & 2\\ \hline 0 & 0 & 1 & 0\\ 1 & 1 & 1 & 2\\ 2 & 0 & 2 & 2 \end{array}$$

which is obviously commutative, but not associative: $$(0*1)*2 = 1*2 = 2$$ $$0*(1*2) = 0*2 = 0$$

• The rock-paper scissors analogy would have been clearer if you had used something like r, p, and s, instead of 0, 1, and 2, but I guess some people might be confused by a function from {r, p, s}^2 to {r, p, s} and better understand functions using numbers. Commented Jun 6, 2023 at 18:32
• @H.H. I don't think it's very important, I used it just to motivate how one could come up with this multiplication table. Also, quite easy to memorize: "example of commutative, non-associative operation is rock-paper-scissors." Although I agree with you it would be more approachable to use letters if someone wanted to show this to kids in school. Commented Jun 7, 2023 at 1:15
• Actually, I never figured out in what way it is rock-paper-scissors. I would think the ties should all evaluate to the same number, for one thing. Commented Jun 7, 2023 at 23:49
• @H.H. if there are rock and rock, why should paper or scissors win, for example? If you choose extra number, you need to include it in the multiplication table and it's no longer rock-paper-scissors. Think of it like $0\leq 1 \leq 2 \leq 0$, without transitivity. Commented Jun 8, 2023 at 10:01
• I see. The "product" is which object wins, not which player wins. That makes the interpretations of 1, 2, and 3 consistent, so it really would work to replace them with 0=rock, 1=paper, 2=scissors (or one of the other 2 rotations of that). Commented Jun 8, 2023 at 13:58

Take for instance $f(x,y)=2x+2y$ on $\mathbb{N}$. Then $f(x,f(y,z))=2x+4y+4z$ and $f(f(x,y),z)=4x+4y+2z$.

Another example is $f(x,y)=2^{x +y}$ on $\mathbb{N}$. Then $f(x,f(y,z))=2^{x + 2^{y + z}}$ and $f(f(x,y),z) = 2^{2^{x + y} +z}$.

Take any Lie algebra over a field of characteristic $2$, where the Lie bracket is not associative (in particular, is not $2$-step nilpotent). Then $[x,y]=[y,x]$ for all $x,y$, but $[x,[y,z]]\neq [[x.y],z]$. An example is the $3$-dimensional simple Witt algebra over characteristic $2$, with basis $(x,y,h)$ and brackets $[x,y]=h,[h,x]=x$ and $[h,y]=y$. If you prefer $x\cdot y$ for the Lie bracket, then $x\cdot y=y\cdot x$ is the commutativity, and $(x\cdot y)\cdot z\neq x\cdot (y\cdot z)$ the non-associativity.