Associativity test for a magma

Say I have the operation table for a magma. I want to know whether or not the operation is associative. However, associativity is defined for an operation on 3 elements, and the operation table deals only with two. So it is not clear to me how to determine whether operation is associative by looking only at the table. Is it possible, or does one just need to try every combination of three elements by brute force?

6 Answers

In the absence of any further information then, yes, you need to check every triple. There is a theorem (due to G. Szasz) which asserts that on any set with at least four elements, there is a binary operation for which there is exactly one non-associative triple. (In fact, there are such operations on three-element sets also; $10$ of them, up to isomorphism.)

A reference for the Szasz theorem is:

@ARTICLE{Szasz1953,
AUTHOR = {G. Szasz},
TITLE = {{D}ie {U}nabh\"{a}ngigkeit der {A}ssoziativit\"{a}tsbedingungen},
JOURNAL = {Acta Sci. Math. Szeged},
VOLUME = {15},
YEAR = {1953},
PAGES = {20--28},
LANGUAGE = {German},
REVIEW = {\MR{56575 (15,95d) 09.1X}},
}


I should add that I've not actually seen this paper. (I've never found it online, and I don't read German anyway.) However, the proof is not difficult. Suppose you have a set $S$ with four distinct elements $a$, $u$, $v$ and $w$. Define the binary operation $\cdot$ on $S$ by putting $a\cdot a = u$, $a\cdot u = v$, and $x\cdot y = w$, for all pairs $(x,y)$ other than $(a,a)$ and $(a,u)$. Then it is easy to see that $(a\cdot a)\cdot a\neq a\cdot(a\cdot a)$. It is then tedious, but completely elementary to check (case by case, as it were) that every other triple does associate.

• I'd be really interested in a link or other reference. Commented Feb 8, 2013 at 17:43
• @EricStucky I've added a reference to the Szasz paper, and the guts of the proof. Commented Feb 8, 2013 at 18:08
• If you know $((ab) c) d = (ab)(cd)$, $a((bc)d) = (a(bc))d$, $b(cd) = (bc)d$, and $(ab)c = a(bc)$, then it automatically follows that $a(b(cd)) = (ab)(cd)$. So, in principle, you don't have to check every triple if you can arrange to check equations that imply other equations.
– user14972
Commented Mar 28, 2013 at 8:07
• @EricStucky There is also a proof in Rajagopalan and Schulman "Verification of Identities" (1997).
– MJD
Commented Nov 27, 2013 at 16:28
• @Hurkyl The apparent discrepancy to Szasz's result is explained by the fact that he essentially uses only a black box that can check for any triple $(x,y,z)\in S^3$ whether or not $x(yz)=(xy)z$ without looking at the intermediate results. Your remarks goes in the direction of Light's test with a generating set. Commented Dec 11, 2013 at 16:00

In Rajagopalan and Schulman "Verification of Identities" (1997), an algorithm is given that probabilistically checks whether a given operation $\circ$ on a set $S$ is associative. If the operation is nonassociative, the test detects this fact with with any desired probability $\delta$ in $$O(\kappa n^2\log\delta^{-1})$$ time, where $n=|S|$ and$\kappa$ is the time to calculate $\circ$ for one pair of arguments. A variant of the algorithm will generate a specific triple $\langle a,b,c\rangle$ for which $(a\circ b)\circ c\ne a\circ (b\circ c)$, when one exists, in time $$O(\kappa n^2\log n\log \delta^{-1}).$$

This algorithm works for arbitrary operations. Unlike Light's test, it works even for "noncancellative" operations, where the equations $x\circ a = b$ and $a\circ x = b$ may not have solutions for all given $a,b$.

The paper also shows that if the operation $\circ$ is cancellative, one can compute a small ($O(\log n)$)set that generates it in time $O(n^2)$, and then apply Light's test to deterministically verify associativity in total time $O(\kappa n^2\log n)$.

Generally, checking for associativity can be computationally very difficult. There are no easy visual criteria on the multiplication table to discern associativity.

• Thanks. Do you know if there are conditions for non-associativity. Where you can see from the table that it's definitely not associative? Commented Feb 8, 2013 at 11:45
• not to the best of my knowledge. Commented Feb 8, 2013 at 11:50
• @MatthewMatic:If your structure is finite, so maybe there is a way to check the associativity by using GAP. If you'd like, give me that structure. Perhaps, I can make a code to verify it. Commented Feb 8, 2013 at 15:14
• @IttayWeiss, there is a geometric interpretation via commutativity on Stasheff polytopes aka en.wikipedia.org/wiki/Associahedron Commented Dec 6, 2014 at 14:19
• @alancalvitti what does the associahedron have to do with any of this??? Commented Dec 6, 2014 at 18:39

A method to structure the checking of associativity is Light's associativity test. It doesn't improve the speed of the algorithm (nor can it, as James' answer shows), but it should make you less cross-eyed.

More on this subject can be found in this answer.

What follows was extracted from a personal manuscript of mine written in July 2004. I’ve changed the reference citation numbers to be consecutive beginning with 1, and I’ve included internet links when I could find them. None of the references are very recent (even in 2004) because they were mostly collected (as photocopies I made from library journal volumes) in the 1980s and 1990s when I came across them while browsing these journals in college/university libraries for various topics of interest to me. Also, nearly all are from expository/elementary journals and thus would likely be of interest to teachers (and some students) of beginning abstract algebra courses. I have not attempted to search for more recent references that would fit with those I've given below—I'll leave that to others who might be interested.

Associativity can sometimes be difficult to verify when the operation is not based on known associative operations in certain ways, such as subgroup or direct product group settings. The following give tips on some efficient ways to prove associativity in finite groups: Abdali [1], Aczel [2], Budden [5] (pp. 36−42, 96), Burn [6], Di Paola [7], Dobyns [8], Ferrero/Ferrero [9], Hammel [10], Parker [11], Rosenberg [12], Siu [13], Spielman [14], Watson [15], and Zassenhaus [16].

Borenson [3] gives a short proof that at most $$n^3 – n$$ verifications are needed to prove associativity for an arbitrary binary operation defined on a set of $$n$$ elements. Bruckheimer/Scott [4], by assuming that an identity and inverses exist for the binary operation, manage to slightly improve on this last result. They show that $$n^3 – 3n^2 +2n$$ verifications are needed to prove associativity. Bruckheimer/Scott’s result winds up being about $$27\%$$ less than $$n^3 – n$$ when $$n=10$$ and about $$3\%$$ less when $$n = 100.$$

[1] S. Kamal Abdali, Verification of associativity of a binary operation, Mathematical Gazette 54 #390 (December 1970), pp. 372−374.

[2] ‪János Aczél, Conditions for a loop to be a group and for a groupoid to be a semigroup, American Mathematical Monthly 76 #5 (May 1969), pp. 547−549.

[3] Henry Borenson, Verifying associativity (Solution to Problem 6238), American Mathematical Monthly 87 #5 (May 1980), pp. 409−410

[4] Maxim Bruckheimer and Jean V. Scott, Testing for associativity, Mathematics Teaching 45 (Winter 1968), pp. 44−46.

[5] Francis James Budden, The Fascination of Groups, Cambridge University Press, 1972, xviii + 596 pages.

[6] Robert Pemberton Burn, Cayley tables and associativity, Mathematical Gazette 62 #422 (December 1978), pp. 278−281.

[7] Jane W. Di Paola, When is a totally symmetric loop a group?, American Mathematical Monthly 76 #3 (March 1969), pp. 249−252.

[8] Roy Dobyns, A condition equivalent to associativity for finite groups, Two-Year College Mathematics Journal [after 1983: College Mathematics Journal] 3 #1 (Spring 1972), pp. 10−13.

[9] Giovanni Ferrero and Celestina Cotti Ferrero, Verifying the associative property, Bollettino della Unione Matematica Italiana (4) 11 (1975), pp. 322−329.

[10] Arnold Dean Hammel, Verifying the associative property for finite groups, Mathematics Teacher 61 #2 (February 1968), pp. 136−139.

[11] Francis D. Parker, When is a loop a group?, American Mathematical Monthly 72 #7 (August−September 1965), pp. 765−766.

[12] Edwin A. Rosenberg, A question of associativity, or many are the uses of commutativity, School Science and Mathematics 84 #7 (November 1984), pp. 566−572.

[13] Man-Keung Siu, Which Latin squares are Cayley tables?, American Mathematical Monthly 98 #7 (August−September 1991), pp. 625−627.

[14] Bryan Spielman, A test for associativity, Mathematical Gazette 55 #391 (February 1971), p. 59.

[15] Donald Ross Watson, Condition for a loop to be a group, American Mathematical Monthly 74 #7 (August−September 1967), pp. 843−844.

[16] Hans Zassenhaus, What makes a loop a group?, American Mathematical Monthly 75 #2 (February 1968), pp. 139−142.

As somebody already wrote, there are some tests that can be done (this wikipedia page links to the same other one cited by @yatima2975).

Personally, I am interested in these matters but I only know sufficient conditions over the Cayley table, for associativity.

If it may help, this is a simple draft of Matlab script to check associativity by brute force (see @James's answer also):

disp('ASSOCIATIVITY TEST FOR A FINITE MAGMA OF ORDER n, WITH ELEMENTS 1,2,...,n, WHOSE CAYLEY TABLE IS GIVEN.');
n=input('Insert the order of the groupoid, n: ');
A=zeros(n);
for i=1:n
r=zeros(1,n);
r=input('Insert Cayley table line as [a_1,...,a_n]: ');
A(i,:)=r;
end
disp('The Cayley table is:');
disp(A);
B=zeros(n,n,n);
for i=1:n
for j=1:n
for k=1:n
if A(A(i,j),k)==A(i,A(j,k))
B(i,j,k)=1;
end
end
end
end
if B==ones(n,n,n)
disp('*** THIS MAGMA IS A SEMIGROUP ***');
else
disp('*** THIS MAGMA IS NOT A SEMIGROUP ***');
end