I have a list of vectors $\texttt{A}$ with coordinates in $\{0,1,\ldots, n-1\}$ that happen to make a group under addition. How do I make GAP understand that it is a group?

One possible solution that my friend found is to use $\texttt{B := A*One(Integers mod n)}$ and then $\texttt{C := AdditiveGroup(B)}$. This gives an additive group (which for GAP is just an additive magma-with-zero and inverses) and I can compute sums of elts etc., but I can't use the standard functions for groups (such as $\texttt{StructureDescription(C)}$). Indeed, when you ask $\texttt{IsGroup(C)}$ the answer is $\texttt{false}$.

I feel like there should be a good way to make GAP treat that as a group, I checked $\texttt{AsGroup(C)}$, but it didn't work. Any ideas how to do it?


GAP only supports multiplicative groups. To deal with this, you need to construct an isomorphic multiplicative groups. I'll describe below how to do that.

You group C is isomorphic to $C_n^d$, where $d$ is the length of your vectors. In GAP, there are are many ways to construct these groups, e.g. like so:

G := AbelianGroup(ListWithIdenticalEntries(d, n));

We could also have used DirectProduct plus CyclicGroup; or asked for the groups in different representations.

Now we need a way to map the $d$-tuples generating your group $C$ into the group $G$. We can do that as follows (were we use that in this particular case, the generators of $G$ set by GAP happen to correspond to the $d$ factors of $C_n^d$):

gens := GeneratorsOfGroup(G);
# define a function mapping vectors to group elements
f := v -> Product([1..d], i -> gens[i]^Int(v[i]));

Using $f$, we can map your set $A$ into a subset of $G$, and then study the group generated by that, which is isomorphic to $C$

Let's combine this to a concrete example:

n := 12;; d := 3;;
A := List([1..2], i->List([1..d],j->Random(0,n-1)));
G := AbelianGroup(ListWithIdenticalEntries(d, n));
gens := GeneratorsOfGroup(G);
f := v -> Product([1..d], i -> gens[i]^v[i]);
H := Subgroup(G, List(A, f));

If we run this, we might get something like this (depending on the state of the random number generator):

gap> n := 12;; d := 3;;
gap> A := List([1..2], i->List([1..d],j->Random(0,n-1)));
[ [ 4, 3, 9 ], [ 10, 9, 11 ] ]
gap> G := AbelianGroup(ListWithIdenticalEntries(d, n));
<pc group of size 1728 with 3 generators>
gap> gens := GeneratorsOfGroup(G);
[ f1, f4, f7 ]
gap> f := v -> Product([1..d], i -> gens[i]^v[i]);
function( v ) ... end
gap> H := Subgroup(G, List(A, f));
Group([ f3*f4*f5*f7*f9^2, f2*f3^2*f4*f6^2*f7*f8*f9^2 ])
gap> Size(H);
gap> StructureDescription(H);
"C12 x C6"
  • $\begingroup$ Thanks! Can I have a meta question too? How do you put in code nicely in the posts? $\endgroup$ – Paweł Piwek Aug 15 '19 at 18:15
  • $\begingroup$ Sure thing; actually, when I edit or write answers, it shows info about this in a sidebar on the right; but you can also read up on it here: math.stackexchange.com/editing-help#code $\endgroup$ – Max Horn Aug 15 '19 at 18:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.