-
Notifications
You must be signed in to change notification settings - Fork 241
Expand file tree
/
Copy pathmain.py
More file actions
3991 lines (3658 loc) · 161 KB
/
Copy pathmain.py
File metadata and controls
3991 lines (3658 loc) · 161 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import re
import time
from collections import defaultdict, Counter
from flask import (
make_response,
redirect,
render_template,
request,
send_file,
url_for,
abort,
)
from markupsafe import Markup
#from six import BytesIO
from string import digits
from io import BytesIO
from sage.all import ZZ, latex, factor, prod, is_prime
from sage.misc.cachefunc import cached_function
from sage.databases.cremona import class_to_int
from lmfdb import db
from lmfdb.app import app
from lmfdb.utils import (
flash_error,
to_dict,
display_knowl,
SearchArray,
TextBox,
SneakyTextBox,
SneakySelectBox,
SelectBox,
CountBox,
YesNoBox,
parse_ints,
parse_bool,
clean_input,
parse_regex_restricted,
parse_bracketed_posints,
parse_noop,
parse_group_label_or_order,
dispZmat,
dispcyclomat,
search_wrap,
web_latex,
pluralize,
Downloader,
pos_int_and_factor,
sparse_cyclotomic_to_mathml,
integer_to_mathml,
redirect_no_cache,
CodeSnippet,
)
from lmfdb.utils.search_parsing import (parse_multiset, search_parser, collapse_ors)
from lmfdb.utils.interesting import interesting_knowls
from lmfdb.utils.search_columns import SearchColumns, LinkCol, MathCol, CheckCol, SpacerCol, ProcessedCol, MultiProcessedCol, ColGroup
from lmfdb.api import datapage
from . import abstract_page
from .web_groups import (
WebAbstractCharacter,
WebAbstractConjClass,
WebAbstractGroup,
WebAbstractRationalCharacter,
WebAbstractSubgroup,
group_names_pretty,
label_sortkey,
primary_to_smith,
abelian_gp_display,
abstract_group_display_knowl,
cc_data_to_gp_label,
gp_label_to_cc_data,
missing_subs,
)
from .stats import GroupStats
abstract_group_label_regex = re.compile(r"^(\d+)\.([a-z]+|\d+)$")
abstract_subgroup_label_regex = re.compile(
r"^(\d+)\.([a-z]+|\d+)\.(\d+)\.([a-z]+\d+|[a-z]+\d+\.[a-z]+\d+|[A-Z]+|_\.[A-Z]+)$"
)
abstract_cc_label_regex = re.compile(r"^(\d+)\.([a-z]+|\d+)\.\d+[A-Z]+(?:-\d+|\d+)?$")
abstract_char_label_regex = re.compile(r"^(\d+)\.([a-z]+|\d+)\.\d+[a-z]+\d*$")
#abstract_subgroup_label_regex = re.compile(
# r"^(\d+)\.([a-z0-9]+)\.(\d+)\.([a-z]+\d+)(?:\.([a-z]+\d+))?(?:\.(N|M|NC\d+))?$"
#)
#abstract_subgroup_partial_regex = re.compile(
# r"^(\d+)\.([a-z0-9]+)\.(\d+)\.([a-z]+[A-Z]+)(?:\.([a-z]+[A-Z]+))?(?:\.(N|M|NC\d+|CF\d+))?$"
#)
#abstract_subgroup_CFlabel_regex = re.compile(
# r"^(\d+)\.([a-z0-9]+)\.(\d+)\.(CF\d+)$"
#)
#abstract_noncanonical_subgroup_label_regex = re.compile(
# r"^(\d+)\.([a-z0-9]+)\.(\d+)\.([A-Z]+)(?:\.(N|M|NC\d+))?$"
#)
gap_group_label_regex = re.compile(r"^(\d+)\.(\d+)$")
# order_stats_regex = re.compile(r'^(\d+)(\^(\d+))?(,(\d+)\^(\d+))*')
abstract_group_hash_regex = re.compile(r"^(\d+)#(\d+)$")
def yesno(val):
return "yes" if val else "no"
def deTeX_name(s):
s = re.sub(r"[{}\\$]", "", s)
s = s.replace("Orth", "O").replace("Unitary", "U")
return s
@cached_function
def group_families(deTeX=False):
L = [(el["family"], el["tex_name"], el["name"]) for el in db.gps_families.search(projection=["family", "tex_name", "name"], sort=["priority"])]
L = [(fam, name if "fam" in tex else f"${tex}$") for (fam, tex, name) in L]
# Here, we're directly adding the individual Chevalley group families (i.e. 'A(n,q)', 'B(n,q)', ...) to the group families list
# (doing this here to avoid manually adding new families to the data; this avoids re-duplicating data which is already stored in the database)
chev_index = [t[0] for t in L].index("Chev")+1
for f in ['An','Bn','Cn','Dn','En','F4','G2']:
L.insert(chev_index, ("Chev"+f[0], "$"+f[0]+"({"+f[1]+"}, {q})$"))
chev_index += 1
twistchev_index = [t[0] for t in L].index("TwistChev")+1
for f in ['2An','2B2','2Dn','3D4','2E6','2F4','2G2']:
L.insert(twistchev_index, ("TwistChev"+f[:2], "$^{"+f[0]+"}{"+f[1]+"}({"+f[2]+"},{q})$"))
twistchev_index += 1
# Adding the individual irreducible Coxeter group families
cox_index = [t[0] for t in L].index("Cox")+1
for f in ['A','B','D','E','F']:
L.insert(cox_index, ("Cox"+f[0], "$W("+f+"_{{n}})$"))
cox_index += 1
if deTeX:
# Used for constructing the dropdown
return [(fam, deTeX_name(name)) for (fam, name) in L]
def hidden(fam):
return fam not in ["C", "S", "D", "A", "Q", "GL", "SL", "PSL", "Sp", "SO", "Sporadic", "Cox"]
L = [(fam, name, "fam_more" if hidden(fam) else "fam_always", hidden(fam)) for (fam, name) in L]
return L
# For dynamic knowls
@app.context_processor
def ctx_abstract_groups():
return {
"cc_data": cc_data,
"sub_data": sub_data,
"rchar_data": rchar_data,
"cchar_data": cchar_data,
"dyn_gen": dyn_gen,
"semidirect_data": semidirect_data,
"nonsplit_data": nonsplit_data,
"possibly_split_data": possibly_split_data,
"aut_data": aut_data,
"trans_expr_data": trans_expr_data,
}
def learnmore_list():
return [
("Source and acknowledgements", url_for(".how_computed_page")),
("Completeness of the data", url_for(".completeness_page")),
("Reliability of the data", url_for(".reliability_page")),
("Abstract group labeling", url_for(".labels_page")),
]
def learnmore_list_add(learnmore_label, learnmore_url):
return learnmore_list() + [(learnmore_label, learnmore_url)]
def learnmore_list_remove(matchstring):
return filter(lambda t: t[0].find(matchstring) < 0, learnmore_list())
def subgroup_label_is_valid(lab):
m = abstract_subgroup_label_regex.fullmatch(lab)
if m:
return m
def label_is_valid(lab):
return abstract_group_label_regex.fullmatch(lab)
#parser for conjugacy class search
@search_parser(clean_info=True, prep_ranges=True)
def parse_group(inp, query, qfield):
if label_is_valid(inp):
gp_ord, gp_count = gp_label_to_cc_data(inp)
query["group_order"] = gp_ord
query["group_counter"] = gp_count
elif re.fullmatch(r'\d+',inp):
query["group_order"] = int(inp)
else:
raise ValueError("It must be a valid group label or order of the group. ")
@search_parser
def parse_family(inp, query, qfield):
if inp not in ([el[0] for el in group_families(deTeX=True)] + ['any']):
raise ValueError("Not a valid family label.")
if inp == 'any':
query['familial'] = True
elif inp == 'C':
query["cyclic"] = True
elif inp == 'D':
query["dihedral"] = True
# Special cases to check if family is one of the individual Chevalley or twisted Chevalley families
elif inp[:4] == 'Chev' and len(inp) == 5:
query[qfield] = {'$in':list(db.gps_special_names.search({'family':"Chev", 'parameters.fam':inp[4]}, projection='label'))}
elif inp[:9] == 'TwistChev' and len(inp) == 11:
query[qfield] = {'$in':list(db.gps_special_names.search({'family':"TwistChev", 'parameters.twist':int(inp[9]), 'parameters.fam':inp[10]}, projection='label'))}
# Searching for Coxeter families should include all dihedral groups and all symmetric S_n for n >= 2
elif inp == 'Cox':
labels = list(db.gps_special_names.search({'family': {'$or': ['Cox', 'CoxH']}}, projection='label'))
collapse_ors(["$or", [{"dihedral":True}, {"label": {"$in": labels}}]], query)
# Case of CoxI2 (return all dihedral groups D_n)
elif inp == 'CoxI':
query["dihedral"] = True
# Case to check if family is one of the individual irreducible Coxeter families
elif inp[:3] == 'Cox' and inp[3] != "H":
query[qfield] = {'$in':list(db.gps_special_names.search({'family':"Cox", 'parameters.fam':inp[3]}, projection='label'))}
else:
query[qfield] = {'$in':list(db.gps_special_names.search({'family':inp}, projection='label'))}
@search_parser
def parse_hashes(inp, query, qfield, order_field):
if inp.count("#") == 0:
opts = [ZZ(opt) for opt in inp.split(",")]
if len(opts) == 1:
query[qfield] = opts[0]
else:
query[qfield] = {"$or": opts}
elif inp.count("#") == 1:
N, hsh = inp.split("#")
N, hsh = ZZ(N), ZZ(hsh)
if order_field not in query:
query[order_field] = N
elif query[order_field] != N:
raise ValueError(f"You cannot specify order both in the {order_field} input and the {qfield} input")
query[qfield] = hsh
else:
raise ValueError("To specify multiple hash values, all must have the same order; provide the order in the order input and then just give hashes separated by commas")
#input string of complex character label and return rational character label
def q_char(char):
return char.rstrip(digits)
def get_bread(tail=[]):
base = [("Groups", url_for(".index")), ("Abstract", url_for(".index"))]
if not isinstance(tail, list):
tail = [(tail, " ")]
return base + tail
def display_props(proplist, joiner="and"):
if len(proplist) == 0:
return ""
elif len(proplist) == 1:
return proplist[0]
elif len(proplist) == 2:
return f" {joiner} ".join(proplist)
else:
return ", ".join(proplist[:-1]) + f", {joiner} {proplist[-1]}"
def find_props(
gp,
overall_order,
impl_order,
overall_display,
implications,
hence_str,
show,
prefix="",
):
props = []
noted = set()
for prop in overall_order:
if not getattr(gp, prefix+prop, None) or prop in noted or prop not in show:
continue
noted.add(prop)
impl = [B for B in implications.get(prop, []) if B not in noted]
cur = 0
while cur < len(impl):
impl.extend(
[
B
for B in implications.get(impl[cur], [])
if B not in impl and B not in noted
]
)
cur += 1
noted.update(impl)
impl = [
overall_display.get(B)
for B in impl_order
if B in impl and B in show
]
if impl:
props.append(f"{overall_display[prop]} ({hence_str} {display_props(impl)})")
else:
props.append(overall_display[prop])
return props
group_prop_implications = {
"cyclic": ["abelian", "is_elementary", "Zgroup"],
"abelian": ["nilpotent", "Agroup", "metabelian"],
"pgroup": ["nilpotent", "is_elementary"],
"is_elementary": ["nilpotent", "is_hyperelementary"],
"nilpotent": ["supersolvable"], # for finite groups
"Zgroup": ["Agroup", "metacyclic"], # metacyclic for finite groups
"metacyclic": ["metabelian", "supersolvable"],
"supersolvable": ["monomial"], # for finite groups
"is_hyperelementary": ["monomial"],
"monomial": ["solvable"],
"metabelian": ["solvable"],
"nab_simple": ["quasisimple", "almost_simple"],
"quasisimple": ["nab_perfect"],
"nab_perfect": ["nonsolvable"],
}
def get_group_prop_display(gp, prefix="", cyclic_known=True):
# We want elementary and hyperelementary to display which primes, but only once
elementaryp = ''
hyperelementaryp = ''
if prefix == "":
if hasattr(gp, 'elementary'):
elementaryp = ",".join(str(p) for p, e in ZZ(gp.elementary).factor())
hyperelementaryp = ",".join(
str(p)
for p, e in ZZ(gp.hyperelementary).factor()
if not p.divides(gp.elementary)
)
if gp.order == 1: # here it will be implied from cyclic, so both are in the implication list
elementaryp = " (for every $p$)"
hyperelementaryp = ""
elif hasattr(gp, 'pgroup') and gp.pgroup: # We don't display p since there's only one in play
elementaryp = hyperelementaryp = ""
elif gp.cyclic: # both are in the implication list
if not cyclic_known: # rare case where subgroup is cyclic but not in db
elementarylist = str(gp.order.prime_factors()).replace("[",""). replace("]","")
elementaryp = f" ($p = {elementarylist}$)"
hyperelementaryp = ""
elif gp.elementary == gp.hyperelementary:
elementaryp = f" ($p = {elementaryp}$)"
hyperelementaryp = ""
else:
elementaryp = f" ($p = {elementaryp}$)"
hyperelementaryp = f" (also for $p = {hyperelementaryp}$)"
elif hasattr(gp, 'is_elementary') and gp.is_elementary: # Now elementary is a top level implication
elementaryp = f" for $p = {elementaryp}$"
if hasattr(gp, 'hyperelementary') and gp.elementary == gp.hyperelementary:
hyperelementaryp = ""
else:
hyperelementaryp = f" (also for $p = {hyperelementaryp}$)"
elif hasattr(gp, 'hyperelementary') and gp.hyperelementary: # Now hyperelementary is a top level implication
hyperelementaryp = f" for $p = {hyperelementaryp}$"
overall_display = {
"cyclic": display_knowl("group.cyclic", "cyclic"),
"abelian": display_knowl("group.abelian", "abelian"),
"nonabelian": display_knowl("group.abelian", "nonabelian"),
"nilpotent": display_knowl('group.nilpotent', 'nilpotent'),
"supersolvable": display_knowl("group.supersolvable", "supersolvable"),
"monomial": display_knowl("group.monomial", "monomial"),
"solvable": display_knowl("group.solvable", "solvable"),
"nonsolvable": display_knowl("group.solvable", "nonsolvable"),
"Zgroup": f"a {display_knowl('group.z_group', 'Z-group')}",
"Agroup": f"an {display_knowl('group.a_group', 'A-group')}",
"metacyclic": display_knowl("group.metacyclic", "metacyclic"),
"metabelian": display_knowl("group.metabelian", "metabelian"),
"quasisimple": display_knowl("group.quasisimple", "quasisimple"),
"almost_simple": display_knowl("group.almost_simple", "almost simple"),
"ab_simple": display_knowl("group.simple", "simple"),
"nab_simple": display_knowl("group.simple", "simple"),
"ab_perfect": display_knowl("group.perfect", "perfect"),
"nab_perfect": display_knowl("group.perfect", "perfect"),
"rational": display_knowl("group.rational_group", "rational"),
"pgroup": f"a {display_knowl('group.pgroup', '$p$-group')}",
"is_elementary": display_knowl("group.elementary", "elementary") + elementaryp,
"is_hyperelementary": display_knowl("group.hyperelementary", "hyperelementary")
+ hyperelementaryp,
}
# We display a few things differently for trivial groups
if gp.order == 1:
overall_display["pgroup"] += " (for every $p$)"
return overall_display
def create_boolean_subgroup_string(sgp, type="normal"):
# We put direct and semidirect after normal since (hence normal) seems weird there, even if correct
implications = {
"thecenter": ["characteristic", "central"],
"thecommutator": ["characteristic"],
"thefrattini": ["characteristic"],
"thefitting": ["characteristic", "nilpotent"],
"theradical": ["characteristic", "solvable"],
"thesocle": ["characteristic"],
"characteristic": ["normal"],
"cyclic": ["abelian"],
"abelian": ["nilpotent"],
"stem": ["central"],
"central": ["abelian"],
"is_sylow": ["is_hall", "nilpotent"],
"nilpotent": ["solvable"],
}
if type == "normal":
overall_order = [
"thecenter",
"thecommutator",
"thefrattini",
"thefitting",
"theradical",
"thesocle",
"characteristic",
"normal",
"maximal",
"direct",
"semidirect",
"cyclic",
"stem",
"central",
"abelian",
"nonabelian",
"is_sylow",
"is_hall",
"pgroup",
"is_elementary",
"nilpotent",
"Zgroup",
"metacyclic",
"supersolvable",
"is_hyperelementary",
"monomial",
"metabelian",
"solvable",
"nab_simple",
"ab_simple",
"Agroup",
"quasisimple",
"nab_perfect",
"ab_perfect",
"almost_simple",
"nonsolvable",
"rational",
]
impl_order = [
"characteristic",
"normal",
"abelian",
"central",
"nilpotent",
"solvable",
"supersolvable",
"is_hall",
"monomial",
"nonsolvable",
"is_elementary",
"is_hyperelementary",
"metacyclic",
"metabelian",
"Zgroup",
"Agroup",
"nab_perfect",
"quasisimple",
"almost_simple",
]
implications.update(group_prop_implications)
else:
overall_order = [
"thecenter",
"thecommutator",
"thefrattini",
"thefitting",
"theradical",
"thesocle",
"characteristic",
"normal",
"maximal",
"direct",
"semidirect",
"cyclic",
"stem",
"central",
"abelian",
"nonabelian",
"is_sylow",
"is_hall",
"nilpotent",
"solvable",
"nab_perfect",
"nonsolvable",
]
impl_order = [
"characteristic",
"normal",
"abelian",
"central",
"nilpotent",
"solvable",
"is_hall",
]
if not getattr(sgp,'normal'): #if gp isn't normal we don't store direct/semidirect
overall_order.remove('direct')
overall_order.remove('semidirect')
for A, L in implications.items():
for B in L:
assert A in overall_order and B in overall_order
assert overall_order.index(A) < overall_order.index(B)
assert B in impl_order
overall_display = {
"thecenter": display_knowl("group.center", "the center"),
"thecommutator": display_knowl(
"group.commutator_subgroup", "the commutator subgroup"
),
"thefrattini": display_knowl(
"group.frattini_subgroup", "the Frattini subgroup"
),
"thefitting": display_knowl("group.frattini_subgroup", "the Fitting subgroup"),
"theradical": display_knowl("group.radical", "the radical"),
"thesocle": display_knowl("group.socle", "the socle"),
"characteristic": display_knowl(
"group.characteristic_subgroup", "characteristic"
),
"normal": display_knowl("group.subgroup.normal", "normal"),
"maximal": display_knowl("group.maximal_subgroup", "maximal"),
"cyclic": display_knowl("group.cyclic", "cyclic"),
"stem": display_knowl("group.stem_extension", "stem"),
"central": display_knowl("group.central", "central"),
"abelian": display_knowl("group.abelian", "abelian"),
"nonabelian": display_knowl("group.abelian", "nonabelian"),
"is_sylow": f"a {display_knowl('group.sylow_subgroup', '$'+str(sgp.sylow)+'$-Sylow subgroup')}",
"is_hall": f"a {display_knowl('group.subgroup.hall', 'Hall subgroup')}",
"nilpotent": display_knowl("group.nilpotent", "nilpotent"),
"solvable": display_knowl("group.solvable", "solvable"),
"nab_perfect": display_knowl("group.perfect", "perfect"),
"nonsolvable": display_knowl("group.solvable", "nonsolvable"),
}
if getattr(sgp,'normal'): #if gp isn't normal we don't store direct/semidirect
norm_attr = {"direct": f"a {display_knowl('group.direct_product', 'direct factor')}","semidirect": f"a {display_knowl('group.semidirect_product', 'semidirect factor')}"}
overall_display.update(norm_attr)
if type == "normal":
if sgp.cyclic and sgp.subgroup is None: # deals with rare case where subgroup is cyclic but not in db
overall_display.update(get_group_prop_display(sgp.sub, cyclic_known=False))
else:
overall_display.update(get_group_prop_display(sgp.sub))
assert set(overall_display) == set(overall_order)
hence_str = display_knowl(
"group.subgroup_properties_interdependencies", "hence"
) # This needs to contain both kind of implications....
props = find_props(
sgp,
overall_order,
impl_order,
overall_display,
implications,
hence_str,
show=overall_display,
)
if type == "normal":
main = f"The subgroup is {display_props(props)}."
# unknown = [prop for prop in overall_order if getattr(sgp, prop, None) is None]
else:
main = f"This subgroup is {display_props(props)}."
unknown = [prop for prop in overall_order if getattr(sgp, prop, None) is None]
if {'ab_simple', 'nab_simple'} <= set(unknown):
unknown.remove('ab_simple')
if sgp.cyclic and sgp.subgroup is None: # deals with rare case of certain cyclic subgroups not in db
unknown.remove('is_elementary')
unknown.remove('is_hyperelementary')
unknown.remove('monomial')
unknown = [overall_display[prop] for prop in unknown]
if unknown:
main += f" Whether it is {display_props(unknown, 'or')} has not been computed."
return main
# function to create string of group characteristics
def create_boolean_string(gp, type="normal"):
# We totally order the properties in two ways: by the order that they should be listed overall,
# and by the order they should be listed in implications
# For the first order, it's important that A come before B whenever A => B
if not gp:
return "Properties have not been computed"
overall_order = [
"cyclic",
"abelian",
"nonabelian",
"pgroup",
"is_elementary",
"nilpotent",
"Zgroup",
"metacyclic",
"supersolvable",
"is_hyperelementary",
"monomial",
"metabelian",
"solvable",
"nab_simple",
"ab_simple",
"Agroup",
"quasisimple",
"nab_perfect",
"ab_perfect",
"almost_simple",
"nonsolvable",
"rational",
]
# Only things that are implied need to be included here, and there are no constraints on the order
impl_order = [
"abelian",
"nilpotent",
"solvable",
"supersolvable",
"monomial",
"nonsolvable",
"is_elementary",
"is_hyperelementary",
"metacyclic",
"metabelian",
"Zgroup",
"Agroup",
"nab_perfect",
"quasisimple",
"almost_simple",
]
short_show = {
"cyclic",
"abelian",
"nonabelian",
"nilpotent",
"solvable",
"nab_simple",
"nonsolvable",
"nab_perfect",
}
short_string = type == "knowl"
# Implications should give edges of a DAG, and should be listed in the group.properties_interdependencies knowl
implications = group_prop_implications
for A, L in implications.items():
for B in L:
assert A in overall_order and B in overall_order
assert overall_order.index(A) < overall_order.index(B)
assert B in impl_order
overall_display = get_group_prop_display(gp)
assert set(overall_display) == set(overall_order)
hence_str = display_knowl("group.properties_interdependencies", "hence")
props = find_props(
gp,
overall_order,
impl_order,
overall_display,
implications,
hence_str,
show=(short_show if short_string else overall_display),
)
if type == "ambient":
main = f"The ambient group is {display_props(props)}."
elif type == "quotient":
main = f"The quotient is {display_props(props)}."
elif type == "knowl":
main = f"{display_props(props)}."
else:
main = f"This group is {display_props(props)}."
unknown = [prop for prop in overall_order if getattr(gp, prop, None) is None]
if {'ab_simple', 'nab_simple'} <= set(unknown):
unknown.remove('ab_simple')
if gp.abelian and gp.monomial is None: #if abelian then monomial
unknown.remove('monomial')
unknown = [overall_display[prop] for prop in unknown]
if unknown and type != "knowl":
main += f" Whether it is {display_props(unknown, 'or')} has not been computed."
return main
def create_boolean_aut_string(gp, prefix="aut_", type="normal", name="automorphism group"):
overall_order = [
"cyclic",
"abelian",
"nonabelian",
"pgroup",
"nilpotent",
"supersolvable",
"solvable",
"nonsolvable",
]
# Only things that are implied need to be included here, and there are no constraints on the order
impl_order = [
"abelian",
"nilpotent",
"solvable",
"supersolvable",
"monomial",
"nonsolvable",
"is_elementary",
"is_hyperelementary",
"metacyclic",
"metabelian",
"Zgroup",
"Agroup",
"nab_perfect",
"quasisimple",
"almost_simple",
]
overall_display = get_group_prop_display(gp, prefix=prefix)
hence_str = display_knowl("group.properties_interdependencies", "hence")
props = find_props(
gp,
overall_order,
impl_order,
overall_display,
group_prop_implications,
hence_str,
show=overall_display,
prefix=prefix,
)
if type == "knowl":
main = f"{display_props(props)}."
else:
main = f"This {name} is {display_props(props)}."
unknown = [prop for prop in overall_order if getattr(gp, prefix+prop, None) is None]
if {'abelian', 'nonabelian'} <= set(unknown):
unknown.remove('nonabelian')
if {'solvable', 'nonsolvable'} <= set(unknown):
unknown.remove('nonsolvable')
prop = 'pgroup' # if p-group, we know it is nilpotent, solvable, and supersolvable
if getattr(gp,prefix+prop,None) > 1:
unknown = [z for z in unknown if z not in ['nilpotent','solvable','supersolvable']]
unknown = [overall_display[prop] for prop in unknown]
if unknown and type != "knowl":
if display_props(props) == "":
return f"We have not determined whether the {name} is {display_props(unknown, 'or')}."
main += f" Whether it is {display_props(unknown, 'or')} has not been computed."
return main
def url_for_label(label):
if label == "random":
return url_for(".random_abstract_group")
return url_for("abstract.by_label", label=label)
def url_for_subgroup_label(label):
if label == "random":
return url_for(".random_abstract_subgroup")
return url_for("abstract.by_subgroup_label", label=label)
#label is the label of a complex character
def url_for_chartable_label(label):
gp = ".".join(label.split(".")[:2])
return url_for(".char_table", label=gp, char_highlight=label)
#Here the input is a dictionary with certain data from the gps_conj_classes table filled in
def url_for_cc_label(record):
gplabel = cc_data_to_gp_label(record["group_order"], record["group_counter"])
return url_for(".char_table", label=gplabel, cc_highlight=record["label"], cc_highlight_i=record["counter"])
@abstract_page.route("/")
def index():
bread = get_bread()
info = to_dict(request.args, search_array=GroupsSearchArray())
if request.args:
search_types = request.args.getlist("search_type")
info["search_type"] = search_type = search_types[-1] if search_types else info.get("hst", "")
if search_type in ["List", "", "Random", "Diagram"]:
return group_search(info)
# Preserve old abstract-group search URLs while directing users to the
# new, object-specific landing pages. Keep Random* as a search type so
# that SearchWrapper still performs a random lookup on the new route.
legacy_searches = {
"Subgroups": (".sub_index", None),
"RandomSubgroup": (".sub_index", "RandomSubgroup"),
"ComplexCharacters": (".char_index", None),
"RandomComplexCharacter": (".char_index", "RandomComplexCharacter"),
"ConjugacyClasses": (".conjugacy_class_index", None),
}
if search_type in legacy_searches:
endpoint, new_search_type = legacy_searches[search_type]
args = request.args.to_dict(flat=False)
args.pop("search_type", None)
if new_search_type is not None:
args["search_type"] = [new_search_type]
return redirect(url_for(endpoint, **args), 307)
info["stats"] = GroupStats()
info["count"] = 50
info["order_list"] = ["1-64", "65-127", "128", "129-255", "256", "257-383", "384", "385-511", "513-1000", "1001-1500", "1501-2000", "2001-"]
info["nilp_list"] = range(1, 10)
info["prop_browse_list"] = [
("abelian=yes", "abelian"),
("abelian=no", "nonabelian"),
("solvable=yes", "solvable"),
("solvable=no", "nonsolvable"),
("simple=yes", "simple"),
("perfect=yes", "perfect"),
("rational=yes", "rational"),
]
info["maxgrp"] = db.gps_groups.max("order")
info["families"] = group_families()
return render_template(
"abstract-index.html",
title="Abstract groups",
bread=bread,
info=info,
learnmore=learnmore_list(),
related_sections=[
("Subgroups", url_for(".sub_index")),
("Characters", url_for(".char_index")),
("Conjugacy classes", url_for(".conjugacy_class_index")),
],
)
@abstract_page.route("/Subgroups")
def sub_index():
info = to_dict(request.args, search_array=SubgroupSearchArray())
if request.args:
return subgroup_search(info)
info["ambient_order_list"] = ["1-64", "65-127", "128", "129-255", "256", "257-383", "384", "385-511", "513-1000", "1001-1500", "1501-2000", "2001-"]
info["subgroup_order_list"] = ["1-16", "17-32", "33-64", "65-128", "129-256", "257-512", "513-1000", "1001-"]
info["prop_browse_list"] = [
("normal=yes", "normal"),
("normal=no", "non-normal"),
("abelian=yes", "abelian"),
("cyclic=yes", "cyclic"),
("maximal=yes", "maximal"),
("central=yes", "central"),
("perfect=yes", "perfect"),
("characteristic=yes", "characteristic"),
]
info["stats"] = GroupStats()
info["search_array"] = SubgroupSearchArray()
info["count"] = 50
return render_template(
"abstract-subgroup.html",
title="Subgroups of abstract groups",
bread=get_bread([("Subgroups", " ")]),
info=info,
learnmore=learnmore_list(),
related_sections=[
("Groups", url_for(".index")),
("Characters", url_for(".char_index")),
("Conjugacy classes", url_for(".conjugacy_class_index")),
],
)
@abstract_page.route("/ComplexCharacters")
def char_index():
info = to_dict(request.args, search_array=ComplexCharSearchArray())
if request.args:
return complex_char_search(info)
info["search_array"] = ComplexCharSearchArray()
info["degree_list"] = ["1", "2", "3", "4", "5", "6", "7", "8", "9-16", "17-"]
info["stats"] = GroupStats()
info["count"] = 50
return render_template(
"abstract-characters.html",
title="Complex characters of abstract groups",
bread=get_bread([("Characters", " ")]),
info=info,
learnmore=learnmore_list(),
related_sections=[
("Groups", url_for(".index")),
("Subgroups", url_for(".sub_index")),
("Conjugacy classes", url_for(".conjugacy_class_index")),
],
)
@abstract_page.route("/ConjugacyClasses")
def conjugacy_class_index():
info = to_dict(request.args, search_array=ConjugacyClassSearchArray())
if request.args:
return conjugacy_class_search(info)
# no random since lots of groups with cc don't have characters also computed
info["search_array"] = ConjugacyClassSearchArray()
info["order_list"] = ["1", "2", "3", "4", "5", "6", "7", "8", "9-16", "17-32", "33-"]
info["size_list"] = ["1", "2", "3", "4", "5", "6-10", "11-20", "21-50", "51-"]
info["stats"] = GroupStats()
info["count"] = 50
return render_template(
"abstract-cc.html",
title="Conjugacy classes of abstract groups",
bread=get_bread([("Conjugacy classes", " ")]),
info=info,
learnmore=learnmore_list(),
related_sections=[
("Groups", url_for(".index")),
("Subgroups", url_for(".sub_index")),
("Characters", url_for(".char_index")),
],
)
@abstract_page.route("/stats")
def statistics():
title = "Abstract groups: Statistics"
return render_template(
"display_stats.html",
info=GroupStats(),
title=title,
bread=get_bread([("Statistics", " ")]),
learnmore=learnmore_list(),
)
@abstract_page.route("/dynamic_stats")
def dynamic_statistics():
info = to_dict(request.args, search_array=GroupsSearchArray())
GroupStats().dynamic_setup(info)
title = "Abstract groups: Dynamic statistics"
return render_template(
"dynamic_stats.html",
info=info,
title=title,
bread=get_bread([("Dynamic statistics", " ")]),
learnmore=learnmore_list(),
)
@abstract_page.route("/random")
@redirect_no_cache
def random_abstract_group():
label = db.gps_groups.random(projection="label")
return url_for(".by_label", label=label)
@abstract_page.route("/interesting")
def interesting():
return interesting_knowls(
"group.abstract",
db.gps_groups,
url_for_label,
title="Some interesting groups",
bread=get_bread([("Interesting", " ")]),
learnmore=learnmore_list(),
)
@abstract_page.route("/<label>")
def by_label(label):
if label_is_valid(label):
return render_abstract_group(label)
else:
flash_error("The label %s is invalid.", label)
return redirect(url_for(".index"))
AB_LABEL_RE = re.compile(r"\d+(_\d+)?(\.\d+(_\d+)?)*")
def canonify_abelian_label(label, smith=False):
parts = defaultdict(list)
for piece in label.split("."):
if "_" in piece:
base, exp = map(ZZ, piece.split("_"))
else:
base = ZZ(piece)
exp = 1
for p, e in base.factor():
parts[p].extend([p ** e] * exp)
for v in parts.values():
v.sort()
if smith:
M = max(len(v) for v in parts.values())
for p, qs in parts.items():
parts[p] = [1] * (M - len(qs)) + qs
return [prod(qs) for qs in zip(*parts.values())]
else:
return sum((parts[p] for p in sorted(parts)), [])
@abstract_page.route("/ab/<label>")
def by_abelian_label(label):
# For convenience, we provide redirects for abelian groups:
# m1_e1.m2_e2... represents C_{m1}^e1 x C_{m2}^e2 x ...
if not AB_LABEL_RE.fullmatch(label):
flash_error(
r"The abelian label %s is invalid; it must be of the form m1_e1.m2_e2... representing $C_{m_1}^{e_1} \times C_{m_2}^{e_2} \times \cdots$",
label,
)
return redirect(url_for(".index"))