-
Notifications
You must be signed in to change notification settings - Fork 2
/
Stat.mag
1441 lines (1277 loc) · 44.8 KB
/
Stat.mag
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 "Utils.mag": has_root, roots, factorization, extension, not_implemented, is_subpartition_of, all_binnings, mset_apply, xdiv, Z;
declare type PGGStat;
declare type PGGStat_EqSimple: PGGStat;
declare type PGGStat_HasRoot: PGGStat_EqSimple;
declare type PGGStat_NumRoots: PGGStat_EqSimple;
declare type PGGStat_FactorDegrees: PGGStat_EqSimple;
declare type PGGStat_Degree: PGGStat_EqSimple;
declare type PGGStat_Order: PGGStat_EqSimple;
declare type PGGStat_AutGroup: PGGStat_EqSimple;
declare attributes PGGStat_AutGroup: conjugacy_classes;
declare type PGGStat_NumAuts: PGGStat_EqSimple;
declare type PGGStat_Tup: PGGStat_EqSimple;
declare attributes PGGStat_Tup: stats;
declare type PGGStat_Factors: PGGStat_EqSimple;
declare attributes PGGStat_Factors: stat;
declare type PGGStat_Factors2: PGGStat;
declare attributes PGGStat_Factors2: strict, stat1, stat2;
declare type PGGStat_Stab: PGGStat_EqSimple;
declare attributes PGGStat_Stab: stat;
declare type PGGStat_GaloisGroup: PGGStat;
declare attributes PGGStat_GaloisGroup: alg, degmax;
declare type PGGStat_SubfieldDegrees: PGGStat_EqSimple; // pair <(L:K), {*(M:K) : L/M/K*}>
declare type PGGStat_FactorDegreesSeq: PGGStat_EqSimple;
declare type PGGStatVal;
declare attributes PGGStatVal: stat, value, norbits, hash, hashable;
intrinsic MakeValue(S :: PGGStat, value, norbits :: RngIntElt) -> PGGStatVal
{A value for the statistic S.}
x := New(PGGStatVal);
x`stat := S;
x`value := value;
x`norbits := norbits;
return x;
end intrinsic;
intrinsic MakeValue(S :: PGGStat, value) -> PGGStatVal
{"}
return MakeValue(S, value, 1);
end intrinsic;
intrinsic Hash(v :: PGGStatVal) -> .
{Hash of v.}
if not assigned v`hash then
v`hash := Hash(Hashable(v));
end if;
return v`hash;
end intrinsic;
intrinsic Hashable(v :: PGGStatVal) -> .
{Hashable value for v.}
if not assigned v`hashable then
v`hashable := _Hashable(v`stat, v);
end if;
return v`hashable;
end intrinsic;
intrinsic 'eq'(S1 :: PGGStat, S2 :: PGGStat) -> BoolElt
{Equality.}
return IsIdentical(S1, S2);
end intrinsic;
intrinsic 'eq'(S1 :: PGGStat_HasRoot, S2 :: PGGStat_HasRoot) -> BoolElt
{"}
return true;
end intrinsic;
intrinsic 'eq'(S1 :: PGGStat_NumRoots, S2 :: PGGStat_NumRoots) -> BoolElt
{"}
return true;
end intrinsic;
intrinsic 'eq'(S1 :: PGGStat_FactorDegrees, S2 :: PGGStat_FactorDegrees) -> BoolElt
{"}
return true;
end intrinsic;
intrinsic 'eq'(S1 :: PGGStat_Degree, S2 :: PGGStat_Degree) -> BoolElt
{"}
return true;
end intrinsic;
intrinsic 'eq'(S1 :: PGGStat_AutGroup, S2 :: PGGStat_AutGroup) -> BoolElt
{"}
return true;
end intrinsic;
intrinsic 'eq'(S1 :: PGGStat_NumAuts, S2 :: PGGStat_NumAuts) -> BoolElt
{"}
return true;
end intrinsic;
intrinsic 'eq'(S1 :: PGGStat_Order, S2 :: PGGStat_Order) -> BoolElt
{"}
return true;
end intrinsic;
intrinsic 'eq'(S1 :: PGGStat_Factors, S2 :: PGGStat_Factors) -> BoolElt
{"}
return S1`stat eq S2`stat;
end intrinsic;
intrinsic 'eq'(S1 :: PGGStat_Stab, S2 :: PGGStat_Stab) -> BoolElt
{"}
return S1`stat eq S2`stat;
end intrinsic;
intrinsic 'eq'(S1 :: PGGStat_Tup, S2 :: PGGStat_Tup) -> BoolElt
{"}
return #S1`stats eq #S2`stats and forall{i : i in [1..#S1`stats] | S1`stats[i] eq S2`stats[i]};
end intrinsic;
intrinsic 'eq'(v1 :: PGGStatVal, v2 :: PGGStatVal) -> BoolElt
{Equality.}
require v1`stat eq v2`stat: "must be values of the same statistic";
require v1`norbits eq v2`norbits: "must have the same number of orbits";
return 'eq'(v1`stat, v1, v2);
end intrinsic;
intrinsic 'subset'(v1 :: PGGStatVal, v2 :: PGGStatVal) -> BoolElt
{True if v1 is possibly a statistic for a subgroup of the group v2 is a subset for.}
require v1`stat eq v2`stat: "must be values of the same statistic";
require v1`norbits eq v2`norbits: "must have the same number of orbits";
return 'subset'(v1`stat, v1, v2);
end intrinsic;
intrinsic Print(v :: PGGStatVal)
{Prints.}
_Print(v`stat, v);
end intrinsic;
intrinsic PGGStat_HasRoot_Make() -> PGGStat_HasRoot
{Makes a new PGGStat.}
return New(PGGStat_HasRoot);
end intrinsic;
intrinsic PGGStat_NumRoots_Make() -> PGGStat_NumRoots
{Makes a new PGGStat.}
return New(PGGStat_NumRoots);
end intrinsic;
intrinsic PGGStat_FactorDegrees_Make() -> PGGStat_FactorDegrees
{Makes a new PGGStat.}
return New(PGGStat_FactorDegrees);
end intrinsic;
intrinsic PGGStat_FactorDegreesSeq_Make() -> PGGStat_FactorDegreesSeq
{"}
return New(PGGStat_FactorDegreesSeq);
end intrinsic;
intrinsic PGGStat_AutGroup_Make() -> PGGStat_AutGroup
{"}
return New(PGGStat_AutGroup);
end intrinsic;
intrinsic PGGStat_NumAuts_Make() -> PGGStat_NumAuts
{"}
return New(PGGStat_NumAuts);
end intrinsic;
intrinsic PGGStat_Degree_Make() -> PGGStat_Degree
{Makes a new PGGStat.}
return New(PGGStat_Degree);
end intrinsic;
intrinsic PGGStat_Order_Make() -> PGGStat_Order
{"}
return New(PGGStat_Order);
end intrinsic;
intrinsic PGGStat_Factors_Make(:Stat:=false) -> PGGStat_Factors
{"}
S := New(PGGStat_Factors);
S`stat := Stat cmpne false select Stat else PGGStat_Degree_Make();
return S;
end intrinsic;
intrinsic PGGStat_Factors2_Make(:Stat1:=false,Stat2:=false,Strict:=false) -> PGGStat_Factors2
{"}
S := New(PGGStat_Factors2);
S`stat2 := Stat2 cmpne false select Stat2 else PGGStat_Degree_Make();
S`stat1 := Stat1 cmpne false select Stat1 else PGGStat_Degree_Make();
S`strict := Strict;
return S;
end intrinsic;
intrinsic PGGStat_Tup_Make(args) -> PGGStat_Tup
{Makes a new PGGStat.}
S := New(PGGStat_Tup);
S`stats := args;
return S;
end intrinsic;
intrinsic PGGStat_Stab_Make(:Stat:=false) -> PGGStat_Stab
{"}
S := New(PGGStat_Stab);
S`stat := Stat cmpne false select Stat else PGGStat_Degree_Make();
return S;
end intrinsic;
intrinsic PGGStat_GaloisGroup_Make(:Alg:=false,DegreeLimit:=false) -> PGGStat_GaloisGroup
{"}
S := New(PGGStat_GaloisGroup);
S`degmax := DegreeLimit cmpne false select DegreeLimit else Infinity();
if Alg cmpne false then
S`alg := Alg;
end if;
return S;
end intrinsic;
intrinsic PGGStat_SubfieldDegrees_Make() -> PGGStat_SubfieldDegrees
{"}
S := New(PGGStat_SubfieldDegrees);
return S;
end intrinsic;
intrinsic Print(S :: PGGStat_HasRoot)
{Print.}
printf "has root";
end intrinsic;
intrinsic Print(S :: PGGStat_NumRoots)
{"}
printf "number of roots";
end intrinsic;
intrinsic Print(S :: PGGStat_FactorDegrees)
{"}
printf "degrees of factors";
end intrinsic;
intrinsic Print(S :: PGGStat_FactorDegreesSeq)
{"}
printf "degrees of factors (sequence)";
end intrinsic;
intrinsic Print(S :: PGGStat_AutGroup)
{"}
printf "automorphism group";
end intrinsic;
intrinsic Print(S :: PGGStat_NumAuts)
{"}
printf "number of automorphisms";
end intrinsic;
intrinsic Print(S :: PGGStat_Degree)
{"}
printf "degree";
end intrinsic;
intrinsic Print(S :: PGGStat_Factors)
{"}
printf "factors -> ";
Print(S`stat);
end intrinsic;
intrinsic Print(S :: PGGStat_Factors2)
{"}
print "factors of factors";
IndentPush();
printf "stat2 = "; Print(S`stat2);
print "";
printf "stat1 = "; Print(S`stat1);
print "";
printf "strict = %o", S`strict;
IndentPop();
end intrinsic;
intrinsic Print(S :: PGGStat_Tup)
{"}
if #S`stats eq 0 then
printf "tuple (empty)";
else
print "tuple";
IndentPush();
for i in [1..#S`stats] do
Print(S`stats[i]);
if i lt #S`stats then
print "";
end if;
end for;
IndentPop();
end if;
end intrinsic;
intrinsic Print(S :: PGGStat_Stab)
{"}
printf "stabilizer -> "; Print(S`stat);
end intrinsic;
intrinsic Print(S :: PGGStat_GaloisGroup)
{"}
printf "galois group";
if assigned S`alg then
print "";
IndentPush();
printf "alg = ";
Print(S`alg);
IndentPop();
end if;
if S`degmax lt Infinity() then
print "";
IndentPush();
printf "max degree = %o", S`degmax;
IndentPop();
end if;
end intrinsic;
intrinsic Print(S :: PGGStat_Order)
{"}
printf "galois group order";
end intrinsic;
intrinsic Print(S :: PGGStat_SubfieldDegrees)
{"}
printf "degrees of subfields";
end intrinsic;
intrinsic ConjugacyClasses(S :: PGGStat_AutGroup, d :: RngIntElt) -> PGGSetSubgrpcls
{The conjugacy classes of Sym(d).}
if not assigned S`conjugacy_classes then
S`conjugacy_classes := AssociativeArray();
end if;
if not IsDefined(S`conjugacy_classes, d) then
S`conjugacy_classes[d] := PGG_SubgroupClasses(SymmetricGroup(d));
end if;
return S`conjugacy_classes[d];
end intrinsic;
intrinsic GroupStat(S :: PGGStat, G :: GrpPerm) -> PGGStatVal
{The value of the statistic on the group.}
return GroupStat(S, G, [GSet(G)]);
end intrinsic;
intrinsic GroupStat(S :: PGGStat, G :: GrpPerm, os :: [GSetIndx[RngIntElt]]) -> PGGStatVal
{The value of the statistic on the group, with the distinguished orbits os.}
not_implemented("GroupStat:", Type(S));
end intrinsic;
intrinsic GroupStat(S :: PGGStat_HasRoot, G :: GrpPerm) -> PGGStatVal
{"}
return MakeValue(S, exists{o : o in Orbits(G) | #o eq 1});
end intrinsic;
intrinsic GroupStat(S :: PGGStat_NumRoots, G :: GrpPerm) -> PGGStatVal
{"}
return MakeValue(S, #[o : o in Orbits(G) | #o eq 1]);
end intrinsic;
intrinsic GroupStat(S :: PGGStat_FactorDegrees, G :: GrpPerm) -> PGGStatVal
{"}
return MakeValue(S, {* #o : o in Orbits(G) *});
end intrinsic;
intrinsic GroupStat(S :: PGGStat_FactorDegreesSeq, G :: GrpPerm, os :: [GSetIndx[RngIntElt]]) -> PGGStatVal
{"}
assert #os ge 1;
if #os eq 1 then
return MakeValue(S, {* #o : o in Orbits(OrbitImage(G, os[1])) *});
elif #os eq 2 then
return MakeValue(S, {* <#o, GroupStat(S, Go, os[2..#os])> where Go:=Stabilizer(G,Rep(o)) : o in Orbits(G,os[1]) *}, #os);
else
not_implemented("GroupStat: PGGStat_FactorDegreesSeq: more than 2 orbits");
end if;
end intrinsic;
intrinsic GroupStat(S :: PGGStat_Degree, G :: GrpPerm) -> PGGStatVal
{"}
return MakeValue(S, Degree(G));
end intrinsic;
intrinsic GroupStat(S :: PGGStat_Order, G :: GrpPerm) -> PGGStatVal
{"}
return MakeValue(S, #G);
end intrinsic;
intrinsic GroupStat(S :: PGGStat_AutGroup, G :: GrpPerm) -> PGGStatVal
{"}
assert IsTransitive(G);
stab := Stabilizer(G, 1);
norm := Normalizer(G, stab);
aut := CosetImage(norm, stab);
return MakeValue(S, ConjugacyClasses(S, Degree(aut)) ! aut);
end intrinsic;
intrinsic GroupStat(S :: PGGStat_NumAuts, G :: GrpPerm) -> PGGStatVal
{"}
assert IsTransitive(G);
stab := Stabilizer(G, 1);
norm := Normalizer(G, stab);
return MakeValue(S, Index(norm, stab));
end intrinsic;
intrinsic GroupStat(S :: PGGStat_Tup, G :: GrpPerm) -> PGGStatVal
{"}
return MakeValue(S, <GroupStat(S2, G) : S2 in S`stats>);
end intrinsic;
intrinsic GroupStat(S :: PGGStat_Factors, G :: GrpPerm) -> PGGStatVal
{"}
return MakeValue(S, {* GroupStat(S`stat, OrbitImage(G, o)) : o in Orbits(G) *});
end intrinsic;
intrinsic GroupStat(S :: PGGStat_Factors2, G :: GrpPerm) -> PGGStatVal
{"}
return MakeValue(S,
< [GroupStat(S`stat1, OrbitImage(G,o)) : o in os]
, [ [ {* GroupStat(S`stat2, OrbitImage(Go,o2)) : o2 in Orbits(Go) *}
where Go := OrbitImage(So,o)
: o in os
]
where So := Stabilizer(G,Rep(o))
: o in os
]
>
where os := [o : o in Orbits(G)]
);
end intrinsic;
intrinsic GroupStat(S :: PGGStat_Stab, G :: GrpPerm) -> PGGStatVal
{"}
error if not IsTransitive(G), "only applies to transitive groups";
return MakeValue(S, GroupStat(S`stat, Stabilizer(G,1)));
end intrinsic;
intrinsic GroupStat(S :: PGGStat_GaloisGroup, G :: GrpPerm) -> PGGStatVal
{"}
return MakeValue(S, Degree(G) le S`degmax select G else sub<G | []>);
end intrinsic;
intrinsic GroupStat(S :: PGGStat_SubfieldDegrees, G :: GrpPerm) -> PGGStatVal
{"}
error if not IsTransitive(G), "only applies to transitive groups";
d := Degree(G);
return MakeValue(S, <d, {* xdiv(d, #X) : X in AllPartitions(G) join {{1},{1..d}}*}>);
end intrinsic;
intrinsic ResolventStat(S :: PGGStat, R :: PGGPol) -> PGGStatVal
{The value of the statistic on the resolvent.}
return ResolventStat(S, [R]);
end intrinsic;
intrinsic ResolventStat(S :: PGGStat, Rs :: [PGGPol]) -> PGGStatVal
{The value of the statistic on the sequence of resolvents.}
not_implemented("ResolventStat:", Type(S));
end intrinsic;
intrinsic ResolventStat(S :: PGGStat_HasRoot, R :: PGGPol) -> PGGStatVal
{"}
return MakeValue(S, HasRoot(R));
end intrinsic;
intrinsic ResolventStat(S :: PGGStat_NumRoots, R :: PGGPol) -> PGGStatVal
{"}
return MakeValue(S, NumRoots(R));
end intrinsic;
intrinsic ResolventStat(S :: PGGStat_FactorDegrees, R :: PGGPol) -> PGGStatVal
{"}
return MakeValue(S, {* d : d in FactorDegrees(R) *});
end intrinsic;
intrinsic ResolventStat(S :: PGGStat_FactorDegreesSeq, R :: [PGGPol]) -> PGGStatVal
{"}
assert #R ge 1;
if #R eq 1 then
return MakeValue(S, {* d : d in FactorDegrees(R[1]) *});
else
return MakeValue(S, {* <Degree(fac), ResolventStat(S, [PolynomialRing(Extension(fac))| f : f in R[2..#R]])> : fac in Factorization(R[1]) *}, #R);
end if;
end intrinsic;
intrinsic ResolventStat(S :: PGGStat_Degree, R :: PGGPol) -> PGGStatVal
{"}
return MakeValue(S, Degree(R));
end intrinsic;
intrinsic ResolventStat(S :: PGGStat_AutGroup, R :: PGGPol) -> PGGStatVal
{"}
K := BaseRing(R);
L := Extension(R);
aut := AutomorphismGroup(L, K);
return MakeValue(S, ConjugacyClasses(S, Degree(aut)) ! aut);
end intrinsic;
intrinsic ResolventStat(S :: PGGStat_NumAuts, R :: PGGPol) -> PGGStatVal
{"}
K := BaseRing(R);
L := Extension(R);
f := DefiningPolynomial(L,K);
naut := #Roots(ChangeRing(f, L));
return MakeValue(S, naut);
end intrinsic;
intrinsic ResolventStat(S :: PGGStat_Tup, R :: PGGPol) -> PGGStatVal
{"}
return MakeValue(S, <ResolventStat(S2, R) : S2 in S`stats>);
end intrinsic;
intrinsic ResolventStat(S :: PGGStat_Factors, R :: PGGPol) -> PGGStatVal
{"}
return MakeValue(S, {* ResolventStat(S`stat, fac) : fac in Factorization(R) *});
end intrinsic;
intrinsic ResolventStat(S :: PGGStat_Factors2, R :: PGGPol) -> PGGStatVal
{"}
return MakeValue(S,
< [ ResolventStat(S`stat1, fac) : fac in facs ]
, [ [ {* ResolventStat(S`stat2, fac2) : fac2 in Factorization(ChangeRing(fac, L)) *}
: fac in facs
]
where L := certs[i]`Extension
: i in [1..#facs]
]
>
where facs, certs := Factorization(R : Extensions)
);
end intrinsic;
intrinsic ResolventStat(S :: PGGStat_Stab, R :: PGGPol) -> PGGStatVal
{"}
L := Extension(R);
// facs, certs := Factorization(R : Extensions);
// error if #facs ne 1, "only applies to irreducible polynomials";
return MakeValue(S, ResolventStat(S`stat, ChangeRing(R, L)));
end intrinsic;
intrinsic ResolventStat(S :: PGGStat_GaloisGroup, R :: PGGPol) -> PGGStatVal
{"}
if Degree(R) gt S`degmax then
return MakeValue(S, sub<SymmetricGroup(Degree(R)) | []>);
elif assigned S`alg then
PGG_GlobalTimer_Push("galois group");
IndentPush();
G := PGG_GaloisGroup(R : Alg:=S`alg);
IndentPop();
PGG_GlobalTimer_Pop();
return MakeValue(S, G);
else
error "ResolventStat: Galois group algorithm not specified";
end if;
end intrinsic;
intrinsic ResolventStat(S :: PGGStat_SubfieldDegrees, R :: PGGPol) -> PGGStatVal
{"}
K := BaseRing(R);
L := Extension(R);
return MakeValue(S, <Degree(L,K), {*1, Degree(L,K)*}>); // TODO!!!
end intrinsic;
intrinsic 'eq'(S :: PGGStat, v1, v2) -> BoolElt
{Equality.}
not_implemented("equality:", Type(S));
end intrinsic;
intrinsic 'eq'(S :: PGGStat_EqSimple, v1, v2) -> BoolElt
{Equality.}
return v1`value eq v2`value;
end intrinsic;
intrinsic 'eq'(S :: PGGStat_AutGroup, v1, v2) -> BoolElt
{"}
return Degree(Rep(v1`value)) eq Degree(Rep(v2`value)) and v1`value eq v2`value;
end intrinsic;
intrinsic 'eq'(S :: PGGStat_GaloisGroup, v1, v2) -> BoolElt
{"}
return Degree(v1`value) eq Degree(v2`value) and IsConjugate(SymmetricGroup(Degree(v1`value)), v1`value, v2`value);
end intrinsic;
procedure assoc_append(~A, k, x)
if IsDefined(A, k) then
Append(~A[k], x);
else
A[k] := [x];
end if;
end procedure;
function is_conjugate2(G, X, xs, ys)
H := G;
for i in [1..#xs] do
ok, g := IsConjugate(H, X, xs[i], ys[i]);
if ok then
for j in [i..#xs] do
xs[j] := xs[j]^g;
end for;
assert xs[i] eq ys[i];
H := Stabilizer(H, X, xs[i]);
else
return false;
end if;
end for;
return true;
end function;
intrinsic 'eq'(S :: PGGStat_Factors2, v1, v2) -> BoolElt
{"}
if Hash(v1) ne Hash(v2) then
return false;
elif Hashable(v1) ne Hashable(v2) then
return false;
elif S`strict then
xs1, yss1 := Explode(v1`value);
xs2, yss2 := Explode(v2`value);
n := #xs1;
assert n eq #yss1;
assert n eq #xs2;
assert n eq #yss2;
A1 := AssociativeArray();
B1 := AssociativeArray();
A2 := AssociativeArray();
B2 := AssociativeArray();
for i in [1..n] do
assoc_append(~A1, xs1[i], [i,n+1]);
assoc_append(~A2, xs2[i], [i,n+1]);
for j in [1..n] do
assoc_append(~B1, yss1[i][j], [i,j]);
assoc_append(~B2, yss2[i][j], [i,j]);
end for;
end for;
S := DirectProduct(SymmetricGroup(n), SymmetricGroup(1));
as := SetToSequence(Keys(A1));
bs := SetToSequence(Keys(B1));
X := {[i,j] : i,j in [1..n+1]};
GX := GSet(S, X, map<car<X, S> -> X | p :-> [p[1][1]^p[2], p[1][2]^p[2]] >);
ok := is_conjugate2(S, GX, [SequenceToSet(B1[b]) : b in bs] cat [SequenceToSet(A1[a]) : a in as], [SequenceToSet(B2[b]) : b in bs] cat [SequenceToSet(A2[a]) : a in as]);
if not ok then
vprint PGG_GaloisGroup: "***** Factors2", v1, v2;
end if;
return ok;
else
return true;
end if;
end intrinsic;
intrinsic 'subset'(S :: PGGStat, v1, v2) -> BoolElt
{True if v1 is a refinement of v2.}
not_implemented("subset:", Type(S));
end intrinsic;
intrinsic 'subset'(S :: PGGStat_HasRoot, v1, v2) -> BoolElt
{"}
return (not v2`value) or (v1`value);
end intrinsic;
intrinsic 'subset'(S :: PGGStat_NumRoots, v1, v2) -> BoolElt
{"}
return v1`value ge v2`value;
end intrinsic;
intrinsic 'subset'(S :: PGGStat_FactorDegrees, v1, v2) -> BoolElt
{"}
return is_subpartition_of(v1`value, v2`value);
end intrinsic;
intrinsic 'subset'(S :: PGGStat_FactorDegreesSeq, v1, v2 : Partial:=false) -> BoolElt
{"}
// put an ordering on the unique values
uvs1 := SetToSequence(MultisetToSet(v1`value));
uvs2 := SetToSequence(MultisetToSet(v2`value));
// try to bin them
bs := all_binnings(
[Multiplicity(v1`value, x) : x in uvs1],
[Multiplicity(v2`value, x) : x in uvs2]:
limit := 1,
is_semivalid := v1`norbits eq 1
select func<i,b |
// check the degrees
&+mset_apply(b,func<j | uvs1[j]>) le uvs2[i]
>
else func<i,b |
// check the first degrees
(&+mset_apply(b,func<j | uvs1[j][1]>) le uvs2[i][1]) and
// check the inner statistics, after joining and multiplying by first degrees
'subset'(S,
'&join'(S, mset_apply(b, func<j | '*'(S, uvs1[j][2], uvs1[j][1])>)),
'*'(S, uvs2[i][2], uvs2[i][1])
: Partial)
>,
is_valid := Partial
select func<i,b | true>
else v1`norbits eq 1
select func<i,b |
// check the degrees
&+mset_apply(b,func<j | uvs1[j]>) eq uvs2[i]
>
else func<i,b |
// check the first degrees
(&+mset_apply(b,func<j | uvs1[j][1]>) eq uvs2[i][1]) and
// check the inner statistics
'subset'(S,
'&join'(S, mset_apply(b, func<j | '*'(S, uvs1[j][2], uvs1[j][1])>)),
'*'(S, uvs2[i][2], uvs2[i][1])
)
>
);
return #bs ne 0;
end intrinsic;
intrinsic 'subset'(S :: PGGStat_Degree, v1, v2) -> BoolElt
{"}
return v1`value eq v2`value;
end intrinsic;
intrinsic 'subset'(S :: PGGStat_Tup, v1, v2) -> BoolElt
{"}
return forall{i : i in [1..#S`stats] | 'subset'(S`stats[i], v1`value[i], v2`value[i])};
end intrinsic;
intrinsic 'subset'(S :: PGGStat_Stab, v1, v2) -> BoolElt
{"}
return 'subset'(S`stat, v1`value, v2`value);
end intrinsic;
// intrinsic 'subset'(S :: PGGStat_Factors, v1, v2) -> BoolElt
// {"}
// w1s := SetToSequence(MultisetToSet(v1`value));
// w2s := SetToSequence(MultisetToSet(v2`value));
// bs := all_binnings(
// [Multiplicity(v1`value, w1) : w1 in w1s],
// [Multiplicity(v2`value, w2) : w2 in w2s]:
// limit:=1,
// is_semivalid:=func<i,b | PartialLe(ProductStat(S`stat, mset_apply(b, func<j | w1s[j]>)), w2s[i])>,
// is_valid:=func<i,b | ProductStat(S`stat, mset_apply(b,func<j | w1s[j]>)) subset w2s[i]>
// );
// return #bs gt 0;
// end intrinsic;
intrinsic 'subset'(S :: PGGStat_Factors2, v1, v2) -> BoolElt
{"}
// v`value[1][i] corresponds to factor i
// v`value[2][i][i] corresponds to the stabilizer of factor i
// v`value[2][i][j] for i ne j do not behave well in the ordering, so are ignored
S2 := PGGStat_Stab_Make(S`stat2);
S3 := PGGStat_Factors_Make(S2);
S4 := PGGStat_Tup_Make(<S`stat1, S3>);
S5 := PGGStat_Factors_Make(:Stat:=S4);
m := func<v | MakeValue(S5, {* MakeValue(S4, <v`value[1][i], MakeValue(S3, {*MakeValue(S2,x) : x in v`value[2][i][i]*})>) : i in [1..n]*}) where n:=#v`value[1]>;
return m(v1) subset m(v2);
end intrinsic;
intrinsic 'subset'(S :: PGGStat_GaloisGroup, v1, v2) -> BoolElt
{"}
return Degree(v1`value) eq Degree(v2`value) and IsConjugateSubgroup(SymmetricGroup(Degree(v1`value)), v2`value, v1`value);
end intrinsic;
intrinsic 'subset'(S :: PGGStat_SubfieldDegrees, v1, v2) -> BoolElt
{"}
return v1`value[1] eq v2`value[1] and v2`value[2] subset v1`value[2];
end intrinsic;
intrinsic '&join'(S :: PGGStat_FactorDegreesSeq, vs :: SetMulti) -> PGGStatVal
{The values of this statistic are multisets; this joins them together.}
norbits := Rep(vs)`norbits;
return MakeValue(S, &join mset_apply(vs, func<v | v`value>), norbits);
end intrinsic;
intrinsic '*'(S :: PGGStat_FactorDegreesSeq, v :: PGGStatVal, d :: RngIntElt) -> PGGStatVal
{Multiplies the degrees by d.}
if v`norbits eq 1 then
return MakeValue(S, mset_apply(v`value, func<x | x*d>));
else
return MakeValue(S, mset_apply(v`value, func<x | <x[1]*d, x[2]>>), v`norbits);
end if;
end intrinsic;
// intrinsic ProductStat(S :: PGGStat_Degree, vs :: {*PGGStatVal*}) -> PGGStatVal
// {Statistict of the direct product of groups or product of polynomials.}
// return MakeValue(S, &+ChangeUniverse(mset_apply(vs, func<v | v`value>), Integers()));
// end intrinsic;
// intrinsic ProductStat(S :: PGGStat_HasRoot, vs :: {*PGGStatVal*}) -> PGGStatVal
// {"}
// return MakeValue(S, exists{v : v in MultisetToSet(vs) | v`value});
// end intrinsic;
// intrinsic ProductStat(S :: PGGStat_NumRoots, vs :: {*PGGStatVal*}) -> PGGStatVal
// {"}
// return MakeValue(S, &+ChangeUniverse(mset_apply(vs, func<v | v`value>), Integers()));
// end intrinsic;
// intrinsic ProductStat(S :: PGGStat_Tup, vs :: {*PGGStatVal*}) -> PGGStatVal
// {"}
// return MakeValue(S, <ProductStat(S`stats[i], mset_apply(vs, func<v | v`value[i]>)) : i in [1..#S`stats]>);
// end intrinsic;
// intrinsic ProductStat(S :: PGGStat_FactorDegrees, vs :: {*PGGStatVal*}) -> PGGStatVal
// {"}
// return MakeValue(S, &join mset_apply(vs, func<v | v`value>));
// end intrinsic;
// intrinsic ProductStat(S :: PGGStat_Factors, vs :: {*PGGStatVal*}) -> PGGStatVal
// {"}
// return MakeValue(S, &join mset_apply(vs, func<v | v`value>));
// end intrinsic;
// intrinsic ProductStat(S :: PGGStat_AutGroup, vs :: {*PGGStatVal*}) -> PGGStatVal
// {"}
// aut := DirectProduct([Rep(v`value) : v in vs]);
// return MakeValue(S, ConjugacyClasses(S, Degree(aut)) ! aut);
// end intrinsic;
// intrinsic ProductStat(S :: PGGStat_Stab, vs :: {*PGGStatVal*}) -> PGGStatVal
// {"}
// return MakeValue(S, ProductStat(S`stat, mset_apply(vs, func<v | v`value>)));
// end intrinsic;
// intrinsic ProductStat(S :: PGGStat_GaloisGroup, vs :: {*PGGStatVal*}) -> PGGStatVal
// {"}
// return MakeValue(S, DirectProduct([v`value : v in vs]));
// end intrinsic;
// intrinsic PartialLe(v1 :: PGGStatVal, v2 :: PGGStatVal) -> BoolElt
// {True if G1 is a subgroup the action of G2 on some of its orbits, and v1 and v2 are corresponding statistics.}
// require v1`stat eq v2`stat: "must be values of the same statistic";
// return PartialLe(v1`stat, v1, v2);
// end intrinsic;
// intrinsic PartialLe(S :: PGGStat, v1, v2) -> BoolElt
// {"}
// error "not implemented: PartialLe:", Type(S);
// end intrinsic;
// intrinsic PartialLe(S :: PGGStat_HasRoot, v1, v2) -> BoolElt
// {"}
// return true;
// end intrinsic;
// intrinsic PartialLe(S :: PGGStat_NumRoots, v1, v2) -> BoolElt
// {"}
// return true;
// end intrinsic;
// intrinsic PartialLe(S :: PGGStat_Degree, v1, v2) -> BoolElt
// {"}
// return v1`value le v2`value;
// end intrinsic;
// intrinsic PartialLe(S :: PGGStat_Tup, v1, v2) -> BoolElt
// {"}
// return forall{i : i in [1..#S`stats] | PartialLe(v1`value[i], v2`value[i])};
// end intrinsic;
// intrinsic PartialLe(S :: PGGStat_FactorDegrees, v1, v2) -> BoolElt
// {"}
// d1s := SetToSequence(MultisetToSet(v1`value));
// d2s := SetToSequence(MultisetToSet(v2`value));
// bs := all_binnings(
// [Multiplicity(v1`value, d1) : d1 in d1s],
// [Multiplicity(v2`value, d2) : d2 in d2s]:
// limit:=1,
// is_semivalid:=func<i,b | &+mset_apply(b,func<j | d1s[j]>) le d2s[i]>
// );
// return #bs gt 0;
// end intrinsic;
// intrinsic PartialLe(S :: PGGStat_Stab, v1, v2) -> BoolElt
// {"}
// return PartialLe(v1`value, v2`value);
// end intrinsic;
intrinsic PossibleIntermediateStatistics(S1 :: PGGStat, S2 :: PGGStat) -> []
{A sequence of statistics to try deducing to from S1, and to S2 from.}
return [];
end intrinsic;
intrinsic PossibleIntermediateStatistics(S1 :: PGGStat, S2 :: PGGStat_HasRoot) -> []
{"}
return [PGGStat_NumRoots_Make()];
end intrinsic;
intrinsic PossibleIntermediateStatistics(S1 :: PGGStat, S2 :: PGGStat_NumRoots) -> []
{"}
return [PGGStat_FactorDegrees_Make()];
end intrinsic;
intrinsic PossibleIntermediateStatistics(S1 :: PGGStat, S2 :: PGGStat_FactorDegrees) -> []
{"}
return [PGGStat_Factors_Make(:Stat:=PGGStat_Degree_Make())];
end intrinsic;
intrinsic PossibleIntermediateStatistics(S1 :: PGGStat, S2 :: PGGStat_Degree) -> []
{"}
return [PGGStat_FactorDegrees_Make()];
end intrinsic;
intrinsic Implies(S1 :: PGGStat, S2 :: PGGStat) -> BoolElt, .
{True if values of S2 can be deduced from values of S1. If so, also returns the corresponding map.}
if S1 eq S2 then
return true, func<v | v>;
end if;
for S in PossibleIntermediateStatistics(S1,S2) do
ok, m1 := Implies(S1, S);
if ok then
ok, m2 := Implies(S, S2);
if ok then
return true, func<v | m2(m1(v))>;
end if;
end if;
end for;
return false, _;
end intrinsic;
intrinsic Implies(S1 :: PGGStat_NumRoots, S2 :: PGGStat_HasRoot) -> BoolElt, .
{"}
return true, func<v | MakeValue(S2, v`value gt 0)>;
end intrinsic;
intrinsic Implies(S1 :: PGGStat_FactorDegrees, S2 :: PGGStat_NumRoots) -> BoolElt, .
{"}
return true, func<v | MakeValue(S2, Multiplicity(v`value, 1))>;
end intrinsic;
intrinsic Implies(S1 :: PGGStat_Factors, S2 :: PGGStat_FactorDegrees) -> BoolElt, .
{"}
ok, m := Implies(S1`stat, PGGStat_Degree_Make());
if ok then
return true, func<v | MakeValue(S2, mset_apply(v`value, func<w | m(w)`value>))>;
end if;
return false, _;
end intrinsic;
intrinsic Implies(S1 :: PGGStat_FactorDegrees, S2 :: PGGStat_Degree) -> BoolElt, .
{"}
return true, func<v | MakeValue(S2, &+v`value)>;
end intrinsic;
intrinsic Implies(S1 :: PGGStat_SubfieldDegrees, S2 :: PGGStat_Degree) -> BoolElt, .
{"}
return true, func<v | MakeValue(S2, &+[Z| x[1] : x in v`value])>;
end intrinsic;
intrinsic Implies(S1 :: PGGStat_GaloisGroup, S2 :: PGGStat_Degree) -> BoolElt, .
{"}
return true, func<v | MakeValue(S2, Degree(v`value))>;
end intrinsic;
intrinsic Implies(S1 :: PGGStat_FactorDegrees, S2 :: PGGStat_Factors) -> BoolElt, .
{"}
SD := PGGStat_Degree_Make();
ok, m := Implies(SD, S2`stat);
if ok then
return true, func<v | MakeValue(S2, mset_apply(v`value, func<d | m(MakeValue(SD,d))>))>;
end if;
return false, _;
end intrinsic;
intrinsic Implies(S1 :: PGGStat_Factors, S2 :: PGGStat_Factors) -> BoolElt, .
{"}
if S1 eq S2 then
return true, func<v | v>;
end if;
ok, m := Implies(S1`stat, S2`stat);
if ok then
return true, func<v | MakeValue(S2, mset_apply(v`value, m))>;
end if;
return false, _;
end intrinsic;
intrinsic Implies(S1 :: PGGStat_Tup, S2 :: PGGStat_Tup) -> BoolElt, .
{"}
if S1 eq S2 then
return true, func<v | v>;
end if;
ms := [];
for S in S2`stats do
ok, m := Implies(S1, S);
if ok then
Append(~ms, m);
else
return false, _;
end if;
end for;
return true, func<v | MakeValue(S2, <m(v) : m in ms>)>;
end intrinsic;
intrinsic Implies(S1 :: PGGStat, S2 :: PGGStat_Tup) -> BoolElt, .
{"}
ms := [];
for S in S2`stats do
ok, m := Implies(S1, S);
if ok then
Append(~ms, m);
else
return false, _;
end if;
end for;
return true, func<v | MakeValue(S2, <m(v) : m in ms>)>;
end intrinsic;
intrinsic Implies(S1 :: PGGStat_Tup, S2 :: PGGStat) -> BoolElt, .
{"}
for i in [1..#S1`stats] do
ok, m := Implies(S1`stats[i], S2);
if ok then
return true, func<v | m(v`value[i])>;
end if;