Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
AndrewVSutherland
GitHub Repository: AndrewVSutherland/lmfdb
Path: blob/main/scripts/sato_tate/smallgroups.m
1128 views
1
function bsonify(obj)
2
case Type(obj):
3
when BoolElt:
4
return obj select "True" else "False";
5
when RngIntElt:
6
if obj le -2^31 or obj ge 2^31 then
7
printf "bson_string: integer %o is too large to fit into an int, you should use a string", obj;
8
assert obj gt -2^31 and obj lt 2^31;
9
end if;
10
return Sprintf("int(%o)", obj);
11
when MonStgElt:
12
return "u'" cat obj cat "'";
13
when Assoc:
14
keys := Keys(obj);
15
if #keys eq 0 then return "{}"; end if;
16
assert &and[Type(k) eq MonStgElt : k in keys];
17
objs := [<k,$$(obj[k])> : k in Sort([k: k in keys])];
18
str := Sprintf("{'%o': %o", objs[1][1], objs[1][2]);
19
for i:=2 to #objs do str cat:= Sprintf(", '%o': %o", objs[i][1], objs[i][2]); end for;
20
return str cat "}";
21
when SeqEnum:
22
if #obj eq 0 then return "[]"; end if;
23
str := "[" cat $$(obj[1]);
24
for i:=2 to #obj do str cat:= ", " cat $$(obj[i]); end for;
25
return str cat "]";
26
when Tup:
27
if #obj eq 0 then return "[]"; end if;
28
str := "[" cat $$(obj[1]);
29
for i:=2 to #obj do str cat:= ", " cat $$(obj[i]); end for;
30
return str cat "]";
31
when Rec:
32
str := "{"; n:= 0;
33
for field in Names(obj) do
34
if assigned obj``field then
35
if n gt 0 then str cat:= ", "; end if;
36
str cat:= "'" cat field cat "': " cat $$(obj``field);
37
n +:= 1;
38
end if;
39
end for;
40
return str cat "}";
41
else:
42
printf "bson_string: don't know how to handle type %o", Type(obj);
43
assert false;
44
end case;
45
end function;
46
47
OTHER := 0; DIGIT := 1; LETTER := 2; TIMES := 3;
48
chartypes := [OTHER : i in [1..127]];
49
for i:=StringToCode("0") to StringToCode("9") do chartypes[i]:=DIGIT; end for;
50
for i:=StringToCode("A") to StringToCode("Z") do chartypes[i]:=LETTER; end for;
51
for i:=StringToCode("a") to StringToCode("z") do chartypes[i]:=LETTER; end for;
52
chartypes[StringToCode("*")] := TIMES;
53
54
function prettify(name)
55
types := [chartypes[StringToCode(name[i])] : i in [1..#name]];
56
pretty := name[1];
57
inbrackets := false;
58
for i:=2 to #name do
59
c := name[i];
60
case types[i]:
61
when DIGIT:
62
if types[i-1] eq LETTER then
63
pretty cat:= "_";
64
if i lt #name and types[i+1] eq DIGIT then pretty cat:= "{"; inbrackets := true; end if;
65
end if;
66
pretty cat:= c;
67
when LETTER:
68
if inbrackets then pretty cat:= "}"; inbrackets := false; end if;
69
pretty cat:= c;
70
when TIMES:
71
if inbrackets then pretty cat:= "}"; inbrackets := false; end if;
72
pretty cat:= "\\\\times ";
73
else:
74
if inbrackets then pretty cat:= "}"; inbrackets := false; end if;
75
pretty cat:= c;
76
end case;
77
end for;
78
if inbrackets then pretty cat:= "}"; end if;
79
return pretty;
80
end function;
81
82
function id_to_label(id)
83
return Sprintf("%o.%o",id[1],id[2]);
84
end function;
85
86
function small_group_data(G)
87
A:=AssociativeArray();
88
A["label"] := id_to_label(IdentifyGroup(G));
89
A["abelian"] := IsAbelian(G);
90
A["cyclic"] := IsCyclic(G);
91
A["perfect"] := IsPerfect(G);
92
A["simple"] := IsSimple(G);
93
A["solvable"] := IsSolvable(G);
94
A["order"] := Order(G);
95
A["exponent"] := Exponent(G);
96
A["name"] := GroupName(G);
97
A["pretty"] := prettify(A["name"]);
98
S:={*<c[1],c[2]>:c in ConjugacyClasses(G)*};
99
S:=Sort([<c[1],c[2],Multiplicity(S,c)>:c in Set(S)]);
100
A["clases"] := S;
101
S:={*IdentifyGroup(H`subgroup):H in MaximalSubgroups(G)*};
102
S:=Sort([<c,Multiplicity(S,c)>:c in Set(S)]);
103
S:=[<id_to_label(c[1]),c[2]>:c in S];
104
A["maximal_subgroups"] := S;
105
S:={*IdentifyGroup(H`subgroup):H in NormalSubgroups(G)*};
106
S:=Sort([<c,Multiplicity(S,c)>:c in Set(S)]);
107
S:=[<id_to_label(S[i][1]),S[i][2]> : i in [2..#S-1]]; // omit trivial and whole group
108
A["normal_subgroups"] := S;
109
A["center"] := id_to_label(IdentifyGroup(Center(G)));
110
A["derived_group"] := id_to_label(IdentifyGroup(DerivedSubgroup(G)));
111
A["abelian_quotient"] := id_to_label(IdentifyGroup(AbelianQuotient(G)));
112
return A;
113
end function;
114
115
procedure dump_small_groups_data(maxN:filename:="")
116
if #filename gt 0 then fp := Open(filename,"w"); end if;
117
n:=0;
118
for N:=1 to maxN do
119
if #filename gt 0 then printf "Generating data for %o subgroups of order %o...\n", NumberOfSmallGroups(N), N; end if;
120
for G in SmallGroups(N:Warning:=false) do
121
data:=bsonify(small_group_data(G));
122
if #filename gt 0 then Puts(fp,data); else print data; end if;
123
n+:=1;
124
end for;
125
end for;
126
if #filename gt 0 then
127
Flush(fp);
128
printf "Wrote %o records to file %o\n", n, filename;
129
end if;
130
end procedure;
131
132