# closed non associative binary operation

I'm Trying to show that a binary operation does not have to be associative in order to maintain closure, identity element and inverse element - on a 5 elements set. Any ideas for a set + binary operation that shows that? I can't find a way to lose associativity without throwing out closure as well.

Consider the set $\{0,1,2,3,4\}$ and the opertion $+$ thus defined:

1. $n+n=n$;
2. $0+n=n+0=n$;
3. otherwise, $m+n=0$.

It has an identity element ($0$) and each element has an inverse (several, indeed, except for $0$). But $(2+1)+1=0+1=1$, whereas $2+(1+1)=2+1=0$.

The example given in the accepted answer is brilliant but, there, the inverse element is not unique for any given element of the set. Otherwise, in a group context, inverse must be unique.

For $$n=5$$, we have six different isotopy classes of loops, only one being a group (integers mod $$5$$). Two of the other five: $$\begin{array}{c|ccccc} \ast & 0 & 1 & 2 & 3 & 4\\ \hline 0 & 0 & 1 & 2 & 3 & 4\\ 1 & 1 & 0 & 3 & 4 & 2\\ 2 & 2 & 4 & 0 & 1 & 3\\ 3 & 3 & 2 & 4 & 0 & 1\\ 4 & 4 & 3 & 1 & 2 & 0 \end{array}\qquad\begin{array}{c|ccccc} \bullet & 0 & 1 & 2 & 3 & 4\\ \hline 0 & 0 & 1 & 2 & 3 & 4\\ 1 & 1 & 0 & 4 & 2 & 3\\ 2 & 2 & 3 & 0 & 4 & 1\\ 3 & 3 & 4 & 1 & 0 & 2\\ 4 & 4 & 2 & 3 & 1 & 0 \end{array}$$ The set $$A=\{0,1,2,3,4\}$$ is closed under both $$\ast$$ and $$\bullet$$.

None of the two is commutative since $$1\ast 2\ne 2\ast 1$$ and $$1\bullet 2\ne 2\bullet 1$$.

None of the two is associative since $$(2\ast 3)\ast 4\ne 2\ast (3\ast 4)$$ and $$(1\bullet 3)\bullet 4\ne 1\bullet (3\bullet 4).$$ Finally, for both the above operations, $$0$$ is the identity element and each element of $$A$$ is the inverse of itself (unique).