It is a well-known result on group theory that if a group has *many pairs of commuting elements* then it is abelian.

This motivated the following pseudo-conjecture.

If a (possibly infinite) set $S$ with a binary operation $\cdot$ is such that for

manytriples $a,b,c\in S$ it holds $(a\cdot b)\cdot c = a \cdot (b\cdot c)$, then $(S,\cdot)$ is a semigroup.

Exploring a little bit on this, a colleague told me he has read somewhere (he can't remember where) that the statement above is false.

If $S$ is a finite set, then there exists a binary operation $\star$ that satisfies $(a\star b)\star c = a\star(b\star c)$ for all but just one ordered triple $(a,b,c)\in S\times S\times S$.

Such a result implies that an algorithm that checks if a certain operation is associative must check indeed all triples of elements, which is kind of funny and rather unintuitive (to me, at least).

We couldn't find a proof of this last result, although playing with small sets it seems to be true.

My questions are the following:

1) Does anybody here know a reference for this result?

2) Is there a constructive proof for such an example?