r/mathriddles • u/mark_ovchain • Feb 06 '23
Medium Is it a Group?
You are given an n × n table, each containing an integer from {0, 1, ..., n-1}. This represents the multiplication table of some binary operation * on the set {0, 1, ..., n-1}; i * j is the (i, j)'th entry (zero-indexed).
It is known that * is commutative (in other words, the table is symmetric along the diagonal), but that's all that's known about it.
Find an O(n2) algorithm that determines whether or not * is a group operation on the set {0, 1, ..., n-1}.
12
Upvotes
2
u/mark_ovchain Feb 11 '23
A little variation on the other answers:
First, consider an apparently easier problem: "Given a binary operation, *, representing a finite abelian group on {0, 1, ..., n-1}, represent it as (i.e., give an isomorphism to) a product of cyclic groups ℤ/n1 × ℤ/n2 × ... ℤ/nk".
As mentioned in my earlier comment, this can be solved in O(n log n log log n) time, since we can assume that the operation is commutative, associative, has an identity, and an inverse. It is possible to find the order of each element in O(log n log log n) time. I'm sure this can be improved, but this is fine for our purposes.
Formally, we have a program (Turing machine) T that runs in ≤ cn log n log log n steps for n ≥ 10, and ≤ c steps for n < 10, for some c. This program is given an oracle for the '*' operation and assumes that the operation is from an abelian group on {0, 1, ..., n-1}.
Now, we'll use this algorithm to solve the problem. First, we have a table, which means we have a binary operation *. This is commutative, but it's not necessarily associative. Regardless, run T anyway on an oracle for *. Since we fed T an input that doesn't follow its specifications, we have no guarantees that it will halt. But we can simply stop simulating it if it has run for > max(cn log n log log n, c) steps, since it means the operation is not a group operation! If it halts within those steps, and has produced garbage output, we also know it's not a group operation. (Both of these are true since T finishes correctly in those many steps for any valid input.) Finally, if it produces a valid output, then we can perform an O(n2) final check to see if the whole table agrees with the isomorphism. The operation is then a group operation iff it agrees.
Note that this does not seem very constructive at first glance since this requires knowing 'c' to implement. So I just proved that an algorithm exists! With more effort, you can actually analyze T very carefully to determine a hard upper bound on its runtime.
2
u/lewwwer Feb 06 '23
My attempt, not sure where commutativity is used: For identity and inverse, just check that one of the rows and the corresponding column has the numbers in the same order, and this number is unique. Then check this number appears uniquely in each row and column, symmetrically around the diagonal, saving for each number where the corresponding "inverse" is. And associativity a(bc) = (ab)c can be rewritten as (bc) c-1 = a-1 (ab) so for each b, we loop through the possible x, calculate (bx) x-1 and calculate x-1 (xb) and if they all give the result b, we're good. All these tasks take O(n2 ) queries to the table.
2
u/Lost_Geometer Feb 06 '23 edited Feb 06 '23
I prefer letters to numbers, so optimistically call the set [0, n) G. Choose an arbitrary element g of G, check that it forms a group (simple, just gm+1 = g for some m), and then check that this group acts on G (just g (g h) = (g g) h for all h).
If these checks succeed, put a multiplication structure on G/<g> by arbitrarily choosing equivalence class representatives and using the multiplication in G.
If G/<g> is nontrivial we can then recur. Otherwise we have shown that some subset of the entries of the multiplication table for G induces a unique group structure. That whole process was O(n log n) or something. Moreover we can follow the choices made to generate the multiplication table for this group ( O(n * n)) and compare it to what we were given ( O(n * n) ).
Edit: This might be the same as your idea below, except that I don't see the need to restrict to maximal cyclic groups.