def mapkGElt(h, f, x):
if x == x - x:
return x
else:
L = x.CoefficientsAndMagmaElements()
result = L[2]*gap.Image(f, gap.Image(h, L[1]))
i = 3
while i+1 <= len(L):
result = result + L[i+1]*gap.Image(f, gap.Image(h, L[i]))
i +=2
return result
def preservesList(f, G, I, L, type='end',verbose=False):
E = []
type_str = ""
if type == 'end':
E = G.Endomorphisms()
type_str = "endomorphism"
elif type == 'aut':
E = G.Automorphisms()
type_str = "automorphism"
else:
print("Invalid type")
return
i = 1
for t in L:
for h in E:
image = mapkGElt(h, f, t)
if not image in I:
if verbose:
print("The ", type_str)
print(h)
print("sends element " + str(i) + ":")
print(t)
print("to the element:")
print(image)
print("which is outside the ideal.")
return False
if verbose:
print("Every", type_str, "takes element " + str(i) + ":")
print(t),
print("into the ideal.")
i += 1
return True
def GEmbeds(G, f, id, I):
embeds = True
for g in G.Elements():
x = gap.Image(f, g)
if x != id and x - id in I:
embeds = False
break
return embeds
def analyzekGmodI(G, f, id, I, kGmodI, Igens, skipFRCheck=False):
print("G = " + str(gap.StructureDescription(G)) + " of order " + str(G.Order()) + '.')
embeds = GEmbeds(G, f, id, I)
if embeds:
print("G embeds in kG/I.")
numUnits = kGmodI.Units().Order()
print("kG/I has", kGmodI.Size(), "elements and", numUnits, "units.")
if numUnits == G.Order():
if not skipFRCheck:
preserves = preservesList(f, G, I, Igens)
if preserves:
print("G is fully realizable.")
else:
print("kG/I realizes but does not fully realize G.")
else:
print("kG/I realizes G. I didn't check whether it fully realizes G.")
else:
print("kG/I does not realize G.")
else:
print("G does not embed in kG/I.")