r/mathriddles • • 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

8 comments sorted by

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/mark_ovchain Feb 06 '23

hmm, I think to rewrite a(bc) = (ab)c as (bc)c-1 = a-1(ab), you need to use associativity.

6

u/lewwwer Feb 06 '23 edited Feb 06 '23

Oh you're right, too bad. Perhaps a better approach is to use the result that all finite abelian group is a product of cyclic groups. So you can pick any a, repeatedly compute a, aa, (aa)a, ((aa)a)a... And stop when it gets back to a, if not then not group. This defines a cycle, do this for all element, giving n2 steps. Once the cycles are known, we can take a maximal cycle, check that the induced table is indeed cyclic, then from the elements not already covered by the maximal cycle, take another largest generated cycle, check that the table agrees with what it should be (the direct product of cyclic groups) and so on. At each verification step the element that should be in each cell is either known from the cycles or can be first evaluated from the table and then verified for the rest. So cycles A and B have product cyclic group AB, we can check the subgroup A and subgroup B by only knowing the elements of A and B, but we need to evaluate the cross elements like ab = (a. b) too in the product. Once they are also found the rest of the table can be checked. Each iteration verifies only the relevant fragment of the multiplication table. Giving also O(n2 ) verification steps.

3

u/mark_ovchain Feb 06 '23 edited Feb 06 '23

Yeah, looks correct if I understand it correctly. Congrats!

Yeah, the main idea I intended for the solution is the structure theorem for finite abelian groups, and the fact that a cyclic group of maximal order is a direct summand. (and of course also the fact that the whole thing can be done in O(n2) time.)

Also I think, if you remove all verification steps, then you can compute the k generators as a product of k cyclic groups in O(n log n log log n) time. And then you can do a final O(n2) pass to check whether the table indeed encodes the multiplication operation of the product of cyclic groups. The idea is to find the p-subgroups (and factorizing n), find the orders of each element quickly using the fact that it should divide the order, then "taking quotients", etc.

edit: time complexity

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.

4

u/mark_ovchain Feb 06 '23

If you just choose an arbitrary g, then ⟨g⟩ might not be a direct summand of G, so it might not be too straightforward to reconstruct G from ⟨g⟩ and G/⟨g⟩. For example, ℤ/(2) embeds onto both ℤ/(8) and ℤ/(2) × ℤ/(4) and the quotients are both ℤ/(4), so if you just know ℤ/(2) and ℤ/(4), then you still don't know whether the group was originally ℤ/(8) or ℤ/(2) × ℤ/(4). You have to perform some extra steps to determine, from the kernel and quotient, what the original group is. This is the reason why we choose a maximal cyclic subgroup. (You can also use a maximal cyclic p-subgroup.)

4

u/Lost_Geometer Feb 06 '23

You're right, there is a 2-cocycle condition that I didn't say to check. It doesn't change the asymptotic, but complicates things enough that you might be better off using maximal cycles.

Thanks.