Let $R=\mathbb{Z}/1024\mathbb{Z}$ and $G=GL(3,R)$. Let $H$ be the subgroup of $G$ consisting of all matrices with determinant $1$ which are congruent to the identity matrix modulo the ideal $4R$. Let


$A=\begin{pmatrix} 1 &0&512\\ 0& 1&0\\0&0 &1\end{pmatrix}$ and $B=\begin{pmatrix} 1 &4&2\\ 8& 1&4\\16 &8 &1\end{pmatrix}$.


Can one use GAP (or other software) to find out if $A\in B^H$? (Here $B^H$ is the subgroup of $G$ generated by the set $\{ B^h\mid h\in H\}$.)



A question about the possibilities of GAP
It is contained. Here is the way I did the calculation with GAP. It ought to work nicer, but there is a stupid technical issue in the way that makes it hard to implement a membership test in a subgroup. (The issue is basically that we cannot guarantee that elements will always lie in one big parent group.)


Thus, one needs to do things in a somewhat pedestrian way.
You will need my `matgrp` package for some calculations in the large groups over residue class rings to work:



```
gap> LoadPackage("matgrp");
true
gap> A:=[[1,0,512],[0,1,0],[0,0,1]];
[ [ 1, 0, 512 ], [ 0, 1, 0 ], [ 0, 0, 1 ] ]
gap> B:=[[1,4,2],[8,1,4],[16,8,1]];
[ [ 1, 4, 2 ], [ 8, 1, 4 ], [ 16, 8, 1 ] ]
gap> r:=Integers mod 1024;
(Integers mod 1024)
gap> Ar:=A*One(r);
[ [ ZmodnZObj( 1, 1024 ), ZmodnZObj( 0, 1024 ), ZmodnZObj( 512, 1024 ) ],
  [ ZmodnZObj( 0, 1024 ), ZmodnZObj( 1, 1024 ), ZmodnZObj( 0, 1024 ) ],
  [ ZmodnZObj( 0, 1024 ), ZmodnZObj( 0, 1024 ), ZmodnZObj( 1, 1024 ) ] ]
gap> Br:=B*One(r);
[ [ ZmodnZObj( 1, 1024 ), ZmodnZObj( 4, 1024 ), ZmodnZObj( 2, 1024 ) ],
  [ ZmodnZObj( 8, 1024 ), ZmodnZObj( 1, 1024 ), ZmodnZObj( 4, 1024 ) ],
  [ ZmodnZObj( 16, 1024 ), ZmodnZObj( 8, 1024 ), ZmodnZObj( 1, 1024 ) ] ]
gap> G:=GL(3,r);
GL(3,Z/1024Z)
gap> FittingFreeLiftSetup(G);; # build a data structure for group order
gap> Size(G);
406199075390515402701275136

```

Next we look at the image modulo 4. We construct it also as a permutation group (so we can use permutation group functionality for homomorphisms:



```
gap> rf:=Integers mod 4;
(Integers mod 4)
gap> gens:=List(GeneratorsOfGroup(G),m->List(m,r->List(r,x->Int(x)*One(rf))));;
gap> q:=Group(gens);
<matrix group with 5 generators>
gap> Size(q);
86016
gap> Size(GL(3,rf));
86016
gap> isop:=IsomorphismPermGroup(q);;
gap> p:=Image(isop);

```

We now construct a map from this permutation group to the matrix group and collect generators for its co-kernel -- these are evaluated relators for the factor that together will generate the kernel of the reduction map on $G$:



```
gap> reverse:=GroupGeneralMappingByImagesNC(p,G,GeneratorsOfGroup(p),
> GeneratorsOfGroup(G));;
gap> it:=CoKernelGensIterator(reverse);
<iterator>
gap> hg:=[];;
gap> for i in it do
>   if not IsOne(i) then
>     Add(hg,i);
>   fi;
> od;
gap> Length(hg);
448

```

This number of generators is a bit too large. We just pick 20 random ones and verify they still generate the kernel. (Would iterate/try more generators if not):



```
gap> preH:=Group(List([1..20],x->Random(hg)));
<matrix group with 20 generators>
gap> FittingFreeLiftSetup(preH);;
gap> Size(G)/Size(preH);
86016

```

Now for determinant 1. We use the same idea for the homomorphism onto the determinant, and get $H$ as kernel



```
gap> dets:=List(GeneratorsOfGroup(preH),DeterminantMat);;
gap> d:=Group(det); # GAP will issue a harmless warning that it assumes the elements indeed are invertible
<group with 20 generators>
gap> Size(d);
256
gap> isop:=IsomorphismPermGroup(d);;
gap> p:=Image(isop);;
gap> reverse:=GroupGeneralMappingByImagesNC(p,preH,GeneratorsOfGroup(p),
> GeneratorsOfGroup(preH));;
gap> it:=CoKernelGensIterator(reverse);;
gap> hg:=[];;
gap> for i in it do
>   if not IsOne(i) then
>     Add(hg,i);
>   fi;
> od;
gap> Length(hg);
4873
gap> H:=Group(List([1..20],x->Random(hg)));;FittingFreeLiftSetup(H);;
gap> Size(preH)/Size(H);
256

```

Now we are ready to calculate $B^H$. We use a standard closure algorithm, starting with $B$ and then take conjugates of generators with generators of $H$ until no new conjugates arise, that is the group is normal.


To test membership $x\in S$, we check (this is the kludge I mentioned) whether $|S|=|\langle S,x\rangle|$. (Indeed this ought to be better, but it still beats hand-calculations.)



```
gap> bco:=[Br];;
gap> sub:=Group(bco);;
gap> FittingFreeLiftSetup(sub);;
gap> Size(sub);
512
gap> for i in bco do
>   for j in GeneratorsOfGroup(H) do
>     x:=i^j;
>     t:=Group(Concatenation(bco,[x]));
>     FittingFreeLiftSetup(t);
>     if Size(t)<>Size(sub) then
>       Add(bco,x);
>       sub:=t;
>     fi;
>   od;
> od;

```

We now use the same kludgy element test to see whether $A\in B^H$:



```
gap> Size(sub);
4503599627370496
gap> t:=Group(Concatenation(bco,[Ar]));
<matrix group with 11 generators>
gap> FittingFreeLiftSetup(t);;
gap> Size(t);
4503599627370496

```

The order stays the same after adding $A$, thus $A\in B^H$.


