-
Notifications
You must be signed in to change notification settings - Fork 0
/
Code.jl
2208 lines (1941 loc) · 65 KB
/
Code.jl
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
GG = GAP.Globals
GG.LoadPackage(GAP.julia_to_gap("repsn"))
using Markdown
### An extra macro for the input checks
macro req(args...)
@assert length(args) == 2
quote
if !($(esc(args[1])))
throw(ArgumentError($(esc(args[2]))))
end
end
end
##############################################################################
#
# Helpers
#
##############################################################################
### Extra converter
"""
A conversion to transform elements of cyclotomic fields from GAP to Oscar
"""
function _convert_gap_to_julia(w_gap,F::AnticNumberField,z::nf_elem,n::Int64)
L = GAP.gap_to_julia(GG.CoeffsCyc(w_gap,n))
w = sum([F(L[l]*z^(l-1)) for l=1:length(L) if L[l] !=0], init = F(0))
return w
end
### Lists operations
"""
Given a sorted list of integers, return the list of distinct integers in
the last, and a second list giving the number of occurence of each value.
"""
function content(L::Vector{Int64})
@assert issorted(L)
Lu = unique(L)
cont = Int64[]
for i in Lu
numb = count(j -> j == i, L)
push!(cont, numb)
end
return Lu, cont
end
content(a::Int64) = content([a])
"""
An internal to return at which index appears an element `f` in a basis `B`.
"""
function _index(B::Vector{T}, f::T) where T
@req f in B "f not in B"
return findfirst(b -> b == f, B)
end
"""
Return the list of elements in a list `A` which satisfies a function `f`.
"""
function keep(f, A)
lis = [i for i=1:length(A) if f(A[i])]
return A[lis]
end
"""
An internal that checks is all the elements of a list are distinct.
"""
function _distinct(L)
L2 = [L[1]]
for l in L
!(l in L2) ? (push!(L2,l)) : continue
end
return L2 == L
end
##############################################################################
#
# Combinatoric
#
##############################################################################
### Elevators
"""
An internal recursive function for the elev method
"""
function _rec(A::Vector{Vector{Int64}},L::Vector{Int64},k::Int64)
Ind_inter = typeof(A[1])[]
bool = false
for t in A
L_inter = Int64[L[t[l]] for l=1:length(t)]
if sum(L_inter) == k
push!(Ind_inter,t)
else
for l = (t[end]):(length(L))
if sum(L_inter) + L[l] <= k
U = deepcopy(t)
bool = true
push!(U,l)
push!(Ind_inter, U)
end
end
end
end
bool == false ? (return Ind_inter) : (return _rec(Ind_inter, L, k))
end
"""
elev(L::Vector{Int64}, k::Int64) -> Vector{Vector{Int64}}
Given a sorted list of integers `L` and an integer `k`, return all the set of
indices for which the corresponding elements in `L` sum up to `k`. Such sets of
indices are ordered increasingly (not strictly) and the output is ordered in
the lexicographic order from the left.
"""
function elev(L::Vector{Int64}, k::Int64)
@req issorted(L) "L has to be a sorted list of integers"
Ind = Vector{Int64}[[i] for i = 1:(length(L))]
return _rec(Ind,L,k)
end
### For exterior powers
"""
Use to construct all all tuples of `k` distinct among `1, ...,n` for exterior
powers.
"""
function _rec_perm(n::Int64,k::Int64)
if n==0 || k>n || k <= 0
return Int64[]
elseif k == 1
return [[i] for i=1:n]
elseif k == n
return [[i for i=1:n]]
else
L = Vector{Int64}[]
for j =k:n
list1 = _rec_perm(j-1,k-1)
for l in list1
push!(l,j)
push!(L,l)
end
end
return L
end
end
###############################################################
#
# Tool to construct all possible character of a certain degree
#
###############################################################
### Get list information
"""
Given a sorted list of integers `L` and an integer `d`, return the number of
distinct possible sums of elements in `L` to `d`, the type of this sums, and
the cumulative numbers of type of sums
"""
function _number_sums(L::Vector{Int64}, d::Int64)
Lu, numb = content(L)
El = elev(Lu, d)
sums = [Lu[el] for el in El]
len = 0
cumul = Int64[0]
sumsum = []
for sum in sums
if length(sum) == 1
for i in [i for i in 1:length(L) if L[i] == sum[1]]
len += 1
push!(cumul, len)
push!(sumsum, (i, sum))
end
else
it = 0
LL = copy(L)
while sum[1] in LL
j = _index(LL, sum[1])
LLu, numbLL = content(LL)
Lu2, numb2 = content(sum[2:end])
len += prod([binomial(numbLL[_index(LLu, Lu2[i])]+numb2[i]-1,numb2[i]) for i=1:length(Lu2)])
LL = LL[j+1:end]
it += j
push!(cumul, len)
push!(sumsum, (it, sum))
end
end
end
return len, cumul, sumsum
end
### "Elevations" for big lists
mutable struct ElevCtx
L::Vector{Int64}
d::Int64
length::Int64
cumul_length::Vector{Int64}
sums::Vector{Tuple{Int64, Vector{Int64}}}
function ElevCtx(L::Vector{Int64}, d::Int64)
z = new(L, d)
len, cumul, sumsum = _number_sums(L, d)
z.length = len
z.cumul_length = cumul
z.sums = sumsum
return z
end
end
len(EC::ElevCtx) = EC.length
cumulated_lengths(EC::ElevCtx) = EC.cumul_length
base_list(EC::ElevCtx) = EC.L
degree(EC::ElevCtx) = EC.d
possible_sums(EC::ElevCtx) = EC.sums
function _rec_get_index(EC2::ElevCtx, i::Int64, sumtype::Vector{Int64})
@assert 0 < i <= len(EC2)
cumul2 = cumulated_lengths(EC2)
sumsum2 = possible_sums(EC2)
j = findfirst(j -> cumul2[j+1] >= i > cumul2[j] && sumsum2[j][2] == sumtype, 1:length(cumul2)-1)
indexL2, sumtype2 = sumsum2[j]
if length(sumtype2) == 1
return [indexL2]
end
d = degree(EC2)
L2 = base_list(EC2)
el2 = [indexL2]
EC3 = ElevCtx(L2[indexL2:end], d-L2[indexL2])
i2 = -cumul2[j]
i2 += sum([cumul2[k+1]-cumul2[k] for k =1:j-1 if sumsum2[k][1] == indexL2])
suite = [indexL2 - 1 + i for i = _rec_get_index(EC3, i+i2, sumtype2[2:end])]
el2 = vcat(el2, suite)
return el2
end
function Base.getindex(EC::ElevCtx, i::Int64)
@assert 0 < i <= len(EC)
cumul = cumulated_lengths(EC)
j = findfirst(j -> cumul[j+1] >= i > cumul[j], 1:length(cumul)-1)
sumsum = possible_sums(EC)
indexL, sumtype = sumsum[j]
if length(sumtype) == 1
return [indexL]
end
d = degree(EC)
L = base_list(EC)
el = [indexL]
EC2 = ElevCtx(L[indexL:end], d-L[indexL])
i2 = -cumul[j]
i2 += sum([cumul[k+1]-cumul[k] for k =1:j-1 if sumsum[k][1] == indexL])
suite = [indexL - 1 + i for i = _rec_get_index(EC2, i+i2, sumtype[2:end])]
el = vcat(el, suite)
return el
end
Base.lastindex(EC::ElevCtx) = len(EC)
function Base.iterate(EC::ElevCtx, i::Int64 = 1)
if i > len(EC)
return nothing
end
return EC[i], i+1
end
##############################################################################
#
# Projective representations
#
##############################################################################
### Associated structures
@attributes mutable struct RepRing{S, T, U, V}
field::S
group::T
gens::U
ct::V
irr
function RepRing(E::T) where {T <: Oscar.GapObj}
e = GG.Exponent(E)
F, _ = cyclotomic_field(e)
ct = GG.CharacterTable(E)
Irr = GG.Irr(ct)
H = GG.GeneratorsOfGroup(E)
RR = new{typeof(F), T, typeof(H), typeof(ct)}(F, E, H, ct, Irr)
return RR
end
end
splitting_field(RR::RepRing) = RR.field
underlying_group(RR::RepRing) = RR.group
generators_of_group(RR::RepRing) = RR.gens
character_table(RR::RepRing) = RR.ct
irreducible_characters(RR::RepRing) = RR.irr
polynomial_algebra(RR::RepRing) = get_attribute(RR, :poly_ring)
@attributes mutable struct LinRep{S, T, U, V, W}
rep_ring::RepRing{S, T, U, V}
mats::Vector{MatElem}
char_gap::W
function LinRep(RR::RepRing{S,T,U, V}, MR::Vector{ <: MatElem}, CG::W) where {S, T, U, V, W}
z = new{S, T, U, V, W}()
z.rep_ring = RR
z.mats = MR
z.char_gap = CG
return z
end
end
representation_ring(LR::LinRep) = LR.rep_ring
matrix_representation(LR::LinRep) = LR.mats
char_gap(LR::LinRep) = LR.char_gap
dim(LR::LinRep) = LR.char_gap[1]
@attributes mutable struct ProjRep{S, T, U, V, W}
LR::LinRep{S, T, U, V, W}
G::T
function ProjRep(LR::LinRep{S, T, U, V, W}, G::T) where {S, T, U, V, W}
z = new{S, T, U, V, W}()
z.LR = LR
z.G = G
return z
end
end
lift(PR::ProjRep) = PR.LR
underlying_group(PR::ProjRep) = PR.G
representation_ring(PR::ProjRep) = representation_ring(PR.LR)
matrix_representation(PR::ProjRep) = matrix_representation(PR.LR)
char_gap(PR::ProjRep) = char_gap(PR.LR)
dim(PR::ProjRep) = dim(PR.LR)
function Base.show(io::IO, ::MIME"text/plain", RR::RepRing)
println(io, "Representation ring of")
println(io, "$(RR.group)")
println(io, "over")
print(io, "$(RR.field)")
end
function Base.show(io::IO, RR::RepRing)
print(io, "Representation ring of finite group over a field of characteristic 0")
end
function Base.show(io::IO, ::MIME"text/plain", LR::LinRep)
println(io, "Linear $(dim(LR))-dimensional representation of")
println(io, "$(LR.rep_ring.group)")
println(io, "over")
println(io, "$(LR.rep_ring.field)")
println(io, "with matrix representation")
print(io, "$(LR.mats)")
end
function Base.show(io::IO, LR::LinRep)
print(io, "Linear representation of finite group of dimension $(dim(LR))")
end
function Base.show(io::IO, ::MIME"text/plain", PR::ProjRep)
println(io, "Linear lift of a $(dim(PR))-dimensional projective representation of")
println(io, "$(PR.G)")
println(io, "over")
println(io, "$(PR.LR.rep_ring.field)")
println(io, "with matrix representation")
print(io, "$(PR.LR.mats)")
end
function Base.show(io::IO, PR::ProjRep)
print(io, "Linear lift of a projective representation of finite group of dimension $(dim(PR.LR))")
end
### Identification of matrix representations
"""
An internal function computing the quotient of a finite matrix group `G` by
its subgroup of complex multiple of the identity.
"""
function _quo_proj(G::GAP.GapObj)
e = GG.Exponent(G)
Elem = GG.Elements(GG.Centre(G))
mult_id = GAP.julia_to_gap([], recursive=true)
for elem in Elem
if GG.IsDiagonalMat(elem) && GG.Size(GG.Eigenvalues(GG.CyclotomicField(e),elem)) == 1
GG.Add(mult_id,elem)
end
end
return GG.FactorGroup(G,GG.Group(mult_id))
end
"""
An internal function computing the GAP matrix group associated to the matrix
form of a representation
"""
function _rep_to_gap_group(rep::Vector{T}) where T <: MatElem
rep_gap = GAP.julia_to_gap(rep, recursive = true)
return GG.Group(rep_gap)
end
"""
An internal function which returns, if it exists, the GAP id of the matrix group
generated by `rep` modulo the multiple of the identity
"""
function _id_group_rep(rep::Vector{T}) where T <: MatElem
G_gap = _rep_to_gap_group(rep)
if !GG.IsFinite(G_gap)
return "Possibly infinite group"
end
G_gap = _quo_proj(G_gap)
if !GG.IdGroupsAvailable(GG.Size(G_gap))
return "Group of order $(GG.Size(G_gap))"
else
return GG.IdGroup(G_gap)
end
end
"""
An internal functions checking whether the matrix form `rep` of a representation
defines a projectively faitful representation of `GG.SmallGroup(o,n)`.
"""
function _is_good_pfr(rep::Vector{T}, (o,n)::Tuple{Integer, Integer}) where T <: MatElem
G_gap = _rep_to_gap_group(rep)
if !GG.IsFinite(G_gap)
return false
end
G_gap = _quo_proj(G_gap)
GG.Size(G_gap) != o ? (return false) : (return GAP.gap_to_julia(GG.IdGroup(G_gap)) == [o,n])
end
### Projectively faithful representations
"""
An internal function which checks whether a small group `G_gap` admits
faitful projective representations of dimension `dim`. If yes, it returns the
necessary tools to create the projectively faithful representations of a Schur
cover associated to those faithful projective representations
"""
function _has_pfr(G_gap::GAP.GapObj, dim::Int64; setup = nothing)
f = GG.EpimorphismSchurCover(G_gap)
H = GG.Source(f)
n, p = ispower(GG.Size(H))
if isprime(p)
G_cover = GG.Image(GG.EpimorphismPGroup(H, p))
else
G_cover = GG.Image(GG.IsomorphismPermGroup(H))
end
RR = RepRing(G_cover)
ct = character_table(RR)
Irr = irreducible_characters(RR)
L = [irr[1] for irr in Irr]
ps = sortperm(L)
L, Irr = L[ps], Irr[ps]
RR.irr = Irr
L = [i for i in L if i<= dim]
lin_gap = [Irr[i] for i=1:length(L) if L[i] == 1]
set_attribute!(RR, :lin_gap, lin_gap)
set_attribute!(RR, :poly_ring, PolynomialRing(RR.field, "x" => 1:dim, cached = false)[1])
keep_index = Int64[]
sum_index = Vector{Int64}[]
char_gap = GAP.GapObj[]
if setup !== nothing
@assert setup isa Tuple{Int64, Int64}
d, t = setup
cds = Vector{Tuple{Int64, typeof(Irr[1])}}[]
end
local El::ElevCtx
El = ElevCtx(L, dim)
@info "Classify $(len(El)) many projective representations."
for l in El
chi = sum(Irr[l])
if any(lin -> lin*chi in char_gap, lin_gap)
continue
end
Facto = GG.FactorGroup(G_cover, GG.CenterOfCharacter(chi))
if !((GG.Size(Facto) == GG.Size(G_gap)) && (GG.IdGroup(Facto) == GG.IdGroup(G_gap)))
continue
end
if setup != nothing
chi_hom = GG.SymmetricParts(ct, GAP.julia_to_gap([chi], recursive=true), d)[1]
cd = _character_decomposition(ct, chi_hom)
filter!(pair -> pair[2][1] <= t, cd)
cd in cds ? continue : push!(cds, cd)
end
push!(char_gap, chi)
keep_index = union(keep_index, l)
push!(sum_index, l)
end
bool = length(keep_index) > 0
return bool, RR, keep_index, sum_index
end
"""
projectively_faithful_representations(o::Int64, n::Int64, dim::Int64)
-> Vector{Vector{MatElem{nf_elem}}, Vector{GAP.GapObj},
Vector{Vector{MatElem{nf_elem}}, Vector{GAP.GapObj}
Given a small group `G` of GAP index `[o,n]`, return representatives of all classes of
complex projectively faithful representations of a Schur cover `E` of `G` of dimension `dim`.
"""
function projectively_faithful_representations(o::Int64, n::Int64, dim::Int64; setup = nothing)
G_gap = GG.SmallGroup(o,n)
bool, RR, keep_index, sum_index = _has_pfr(G_gap, dim, setup = setup)
if bool == false
return ProjRep[]
end
@info "Construct and compare $(length(sum_index)) many projectively faithful representations."
F = splitting_field(RR)
e = get_attribute(F, :cyclo)
z = gen(F)
H_cover = generators_of_group(RR)
ct = character_table(RR)
Irr = irreducible_characters(RR)
G_cover = underlying_group(RR)
Rep = Vector{MatElem{nf_elem}}[]
lin_gap = get_attribute(RR, :lin_gap)
lin_oscar = Vector{MatElem{nf_elem}}[]
for lin in lin_gap
rep = GG.IrreducibleAffordingRepresentation(lin)
Mat_cover = [GG.Image(rep,h) for h in H_cover]
Mat = MatElem{nf_elem}[]
for u =1:(length(Mat_cover))
M_cover = Mat_cover[u]
k = length(M_cover)
M = [_convert_gap_to_julia(M_cover[i,j],F,z,Int(e)) for i=1:k, j =1:k]
push!(Mat, matrix(F,M))
end
Mat = [m for m in Mat]
push!(lin_oscar, Mat)
end
set_attribute!(RR, :lin_oscar, lin_oscar)
for index in keep_index
irr = Irr[index]
j = findfirst(j -> irr == lin_gap[j], 1:length(lin_gap))
if j === nothing
rep = GG.IrreducibleAffordingRepresentation(irr)
Mat_cover = [GG.Image(rep,h) for h in H_cover]
Mat = MatElem{nf_elem}[]
for u =1:(length(Mat_cover))
M_cover = Mat_cover[u]
k = length(M_cover)
M = [_convert_gap_to_julia(M_cover[i,j],F,z,Int(e)) for i=1:k, j =1:k]
push!(Mat, matrix(F,M))
end
Mat = [m for m in Mat]
else
Mat = lin_oscar[j]
end
push!(Rep, Mat)
end
pfr = ProjRep[]
for l in sum_index
chara = sum(Irr[l])
@assert chara[1] == dim
Mat = Rep[_index( keep_index, l[end])]
for i=length(l)-1:-1:1
Mat = [block_diagonal_matrix([Mat[j], Rep[_index(keep_index, l[i])][j]]) for j=1:length(Mat)]
end
#MG = matrix_group(Mat)
keep = true
for pr in pfr
Mat_inter = matrix_representation(pr)
G_inter = matrix_group(Mat_inter)
all(mm -> mm in G_inter, Mat) ? keep = false : nothing
end
if keep == true
lr = LinRep(RR, Mat, chara)
pr = ProjRep(lr, G_gap)
push!(pfr, pr)
end
end
return pfr
end
### Projective representations
"""
An internal function which checks whether a small group `G_gap` admits projective
representations of dimension `dim` with kernel of dimension at most `index_max`.
If yes, it returns the tools necessary to compute the linear representations
of a Schur cover corresponding to those projective representations
"""
function _has_pr(G_gap::GAP.GapObj, dim::Int64; index_max::IntExt = inf)
f = GG.EpimorphismSchurCover(G_gap)
H = GG.Source(f)
n, p = ispower(GG.Size(H))
if isprime(p)
G_cover = GG.Image(GG.EpimorphismPGroup(H, p))
else
G_cover = GG.Image(GG.IsomorphismPermGroup(H))
end
RR = RepRing(G_cover)
ct = character_table(RR)
Irr = irreducible_characters(RR)
Irr = keep(irr -> irr[1] <= dim, Irr)
L = [irr[1] for irr in Irr]
ps = sortperm(L)
L, Irr = L[ps], Irr[ps]
RR.irr = Irr
lin_gap = [Irr[i] for i=1:length(Irr) if Irr[i][1] == 1]
set_attribute!(RR, :lin_gap, lin_gap)
set_attribute!(RR, :poly_ring, PolynomialRing(RR.field, "x" => 1:dim, cached = false)[1])
keep_index = Int64[]
sum_index = Vector{Int64}[]
char_gap = GAP.GapObj[]
local El::ElevCtx
El = ElevCtx(L, dim)
@info "Classify $(len(El)) many projective representations."
for l in El
chi = GG.Character(G_cover, sum(Irr[l]))
@assert chi[1] == dim
keep = true
Facto = GG.FactorGroup(G_cover, GG.CenterOfCharacter(chi))
idx, r = divrem(GG.Size(G_gap), GG.Size(Facto))
if (r == 0 && idx <= index_max)
if idx == 1
if GG.IdGroup(Facto) != GG.IdGroup(G_gap)
keep = false
end
end
if any(lin -> lin*chi in char_gap, lin_gap)
keep = false
end
else
keep = false
end
if keep == true
push!(char_gap, chi)
keep_index = union(keep_index, l)
push!(sum_index, l)
end
end
bool = length(keep_index) > 0
return bool, RR, keep_index, sum_index
end
"""
Return projective representations of a group, given as linear representations
of a Schur cover, for which the kernel as maximal index `index_max` in the
group
"""
function projective_representations(o::Int64, n::Int64, dim::Int64; index_max::IntExt = inf)
@req (o >= index_max || index_max == inf) "index_max must be smaller than the order of the group"
index_max = min(o, index_max)
if (index_max == 1)
return projectively_faithful_representations(o, n, dim)
end
G_gap = GG.SmallGroup(o,n)
bool, RR, keep_index, sum_index = _has_pr(G_gap, dim, index_max = index_max)
if bool == false
return ProjRep[]
end
@info "Construct $(length(sum_index)) many projective representations."
F = splitting_field(RR)
e = get_attribute(F, :cyclo)
z = gen(F)
H_cover = generators_of_group(RR)
ct = character_table(RR)
Irr = irreducible_characters(RR)
G_cover = underlying_group(RR)
Rep = Vector{MatElem{nf_elem}}[]
lin_gap = get_attribute(RR, :lin_gap)
lin_oscar = Vector{MatElem{nf_elem}}[]
for lin in lin_gap
rep = GG.IrreducibleAffordingRepresentation(lin)
Mat_cover = [GG.Image(rep,h) for h in H_cover]
Mat = MatElem{nf_elem}[]
for u =1:(length(Mat_cover))
M_cover = Mat_cover[u]
k = length(M_cover)
M = [_convert_gap_to_julia(M_cover[i,j],F,z,Int(e)) for i=1:k, j =1:k]
push!(Mat, matrix(F,M))
end
Mat = [m for m in Mat]
push!(lin_oscar, Mat)
end
set_attribute!(RR, :lin_oscar, lin_oscar)
for index in keep_index
irr = Irr[index]
j = findfirst(j -> irr == lin_gap[j], 1:length(lin_gap))
if j === nothing
rep = GG.IrreducibleAffordingRepresentation(irr)
Mat_cover = [GG.Image(rep,h) for h in H_cover]
Mat = MatElem{nf_elem}[]
for u =1:(length(Mat_cover))
M_cover = Mat_cover[u]
k = length(M_cover)
M = [_convert_gap_to_julia(M_cover[i,j],F,z,Int(e)) for i=1:k, j =1:k]
push!(Mat, matrix(F,M))
end
Mat = [m for m in Mat]
else
Mat = lin_oscar[j]
end
push!(Rep, Mat)
end
pfr = ProjRep[]
for l in sum_index
chara = sum(Irr[l])
@assert chara[1] == dim
Mat = Rep[_index( keep_index, l[end])]
for i=length(l)-1:-1:1
Mat = [block_diagonal_matrix([Mat[j], Rep[_index(keep_index, l[i])][j]]) for j=1:length(Mat)]
end
bool = true
for pr in pfr
Mat_inter = matrix_representation(pr)
G_inter = matrix_group(Mat_inter)
it2 = count(mat -> mat in G_inter, Mat)
it2 == length(Mat) ? bool = false : nothing
end
if bool == true
lr = LinRep(RR, Mat, chara)
pr = ProjRep(lr, G_gap)
push!(pfr, pr)
end
end
return pfr
end
##############################################################################
#
# Polynomial algebra tools
#
##############################################################################
### Basis for homogeneous components
"""
homog_basis(R::MPolyRing{nf_elem}, d::Int64}) -> Vector{MPolyElem{nf_elem}}
Given a multivariate polynomial ring `R` with the standard grading, return a
basis of the `d`-homogeneous part of `R`, i.e. all the monomials of homogeneous
degree `d`. The output is ordered in the lexicographic order from the left for the indices
of the variables of `R` involved.
"""
function homog_basis(R::T,d::Int64) where T <: MPolyRing
n = nvars(R)
L = Int64[1 for i =1:n]
E = elev(L,d)
G = gens(R)
B = typeof(G[1])[prod(G[e]) for e in E]
return B
end
### Functions for conversion between abstract homogeneous polynomials and their coordinates
### to the chosen bases
"""
An internal to transform a set of polynomials whose coordinates in a basis
of the corresponding polynomial algebra `R` are the columns of the given matrix `M`.
"""
function _mat_to_poly(M::MatElem{T}, R::MPolyRing{T}) where T <: RingElem
@assert nrows(M) == nvars(R)
G = gens(R)
return typeof(G[1])[(change_base_ring(R,transpose(M)[i,:])*matrix(G))[1] for i=1:(size(M)[2])]
end
"""
An internal to change a homogeneous polynomials into a vector whose entries are the
coefficients of `P` in the canonical basis of the corresponding homogeneous component
"""
function _homo_poly_in_coord(P::T) where T
R = parent(P)
F = base_ring(R)
d = total_degree(P)
B = homog_basis(R,d)
v = zeros(F,length(B), 1)
Coll = collect(terms(P))
for c in Coll
v[_index(B, collect(monomials(c))[1])] = collect(coeffs(c))[1]
end
return matrix(v)
end
"""
An internal to change an homogeneous polynomial of `R` of degree `d` given in
coordinates `w` into its polynomial form.
"""
function _coord_in_homo_poly(w::MatElem{T}, R::MPolyRing, d::Int64) where T <: RingElem
B = homog_basis(R,d)
@assert length(B) == size(w)[1]
return sum([w[:,1][i]*B[i] for i=1:(size(w)[1])])
end
"""
An internal to transform an homogeneous ideal into a matrix whose columns are the coordinates
of homogenoues generators of the same degree of `I` in an appropriate basis
"""
function _homo_ideal_in_coord(I::T) where T <:MPolyIdeal
g = gens(I)
R = base_ring(I)
F = base_ring(R)
d = total_degree(g[1])
@req all(gg -> sum(degrees(collect(terms(gg))[1])) == d, g) "The generators of `I` must be of the same homogeneous degree"
B = homog_basis(R,d)
v = zeros(F,length(B),length(g))
for i=1:(length(g))
Coll = collect(terms(g[i]))
vf = zeros(F, length(B), 1)
for c in Coll
vf[_index(B, collect(monomials(c))[1])] = collect(coeffs(c))[1]
end
v[:,i] = vf
end
return (v,B)
end
##############################################################################
#
# About tensors of homogeneous polynomials
#
##############################################################################
### Basis of exterior power
"""
basis`_`exterior`_`power(B::Vector{T}, k::Int64) where T -> Vector{Vector{T}}
Given a basis `B` of a vector space `V`, return a basis of the `t`-exterior power of
`V` as a set of lists. Each list is ordered in strictly increasing order of the
indices of the corresponding elements in `B`. The output is ordered in the lexicographic
order from the right in the indices of the corresponding elements in `B`
"""
function basis_exterior_power(B::Vector{T}, t::Int64) where T
l = length(B)
L = _rec_perm(l,t)
return Vector{T}[B[lis] for lis in L]
end
### Operations on pure tensors
"""
An internal to check if two pure tensors define the same element up to
reordering.
"""
function _same_base(v::Vector{T}, w::Vector{T}) where T
@assert length(v) == length(w)
l = count(vv -> vv in w, v)
return l == length(v)
end
"""
An internal that, given two elements representing the same pure tensors, return
the sign of the permutation of components from one to another.
"""
function _div(v::Vector{T}, w::Vector{T}) where T
@assert _same_base(v,w)
return sign(perm([findfirst(vv -> vv == ww, v) for ww in w]))
end
"""
An internal to check whether or not a pure tensor is a basis tensor. If yes, it
returns the given basis tensor and the sign of the permutation from one to another.
"""
function _in_basis(v::Vector{T}, basis::Vector{Vector{T}}) where T
@assert length(v) == length(basis[1])
i = findfirst(w -> _same_base(v,w),basis)
i == nothing ? (return false) : (return basis[i], _div(v,basis[i]))
end
"""
An internal that given an element `w` of the `t`-exterior power of a vector space
expressed by its coordinates in a basis `basis` of this exterior power, returns it in the
form of a set of pairs consisting of the coefficients and the corresponding element of
the basis (given as a matrix as in `_base_to_columns`) read from the coordinates `w`.
"""
function _change_basis(w, basis::Vector{Vector{T}}) where T
@assert length(w) == length(basis)
gene = [(w[i],basis[i]) for i =1:length(w) if w[i] != parent(w[i])(0)]
return gene
end
function _standard_basis(F, n)
v = zero_matrix(F,n,1)
std_bas = typeof(v)[]
for j=1:n
vv =deepcopy(v)
vv[j,1] = one(F)
push!(std_bas, vv)
end
return std_bas
end
function _decompose_in_standard_basis(v)
std_bas = _standard_basis(base_ring(v), nrows(v))
return std_bas, [[v[i], std_bas[i]] for i=1:nrows(v)]
end
function _wedge_product(V::Vector)
if length(V) == 1
v = V[1]
_, dec = _decompose_in_standard_basis(v)
w = [(l[1], [l[2]]) for l in dec]
return w
end
v = popfirst!(V)
wp = _wedge_product(copy(V))
std_bas, dec = _decompose_in_standard_basis(v)
bas = basis_exterior_power(std_bas, length(V)+1)
coeffs = zeros(parent(dec[1][1]), length(bas))
for l in dec
for w in wp
if l[2] in w[2]
continue
end
w_co = copy(w[2])
lw_co = pushfirst!(w_co, l[2])
ba, mult = _in_basis(lw_co, bas)
coeffs[_index(bas, ba)] += mult*w[1]*l[1]
end
end
return _change_basis(coeffs, bas)
end
function _shuffle_equation(R::MPolyRing, L::PolyRing{nf_elem}, M::MatElem, t::Int64)
F = base_ring(M)
@assert base_ring(L) === F
y = gen(L)
T = identity_matrix(F, nrows(M))
Z = map_entries(L, T) + y*map_entries(L, M)
Q = zero_matrix(L, binomial(nrows(M), t), binomial(ncols(M), t))
std_bas = _standard_basis(F, nrows(M))
bas = basis_exterior_power(std_bas, t)
r = _rec_perm(nrows(M), t)
for i in 1:length(r)
l = r[i]
V = [Z[:,j] for j in l]
wp = _wedge_product(V)
for w in wp
k = _index(bas, [map_entries(p -> evaluate(p,0), ww) for ww in w[2]])
Q[k,i] = w[1]
end
end
Q -= identity_matrix(L, nrows(Q))
I = ideal(R, [R(0)])
x = gens(R)
for j=1:t
gene = typeof(x[1])[]
for k=1:ncols(Q)
my = Q[:,k]
m = map_entries(p -> divexact(p, y), my)
v = map_entries(p -> evaluate(p, 0), m)
Q[:,k] -= y*map_entries(L, v)
if !iszero(v)
push!(gene, sum([v[l]*x[l] for l=1:length(x)]))
end
end
J = radical(ideal(R,gene))
I = radical(I+J)
end
return I
end
### wedge product of polynomials
"""
wedge_product(F::Vector{T}) where T <: MPolyElem
-> Vector{Tuple{nf_elem}, Vector{MPolyElem}}
Given a list of homogeneous polynomials `F` of the same polynomial algebra and of the same
total degree, return their wedge product as an abstract tensor, seen as a list of tuples
of coefficients and the respective elements of the basis of the exterior power.
"""
function wedge_product(F::Vector{T}) where T <: MPolyElem
if length(F) == 1
f = F[1]
R = parent(f)
d = total_degree(f)
B = homog_basis(R,d)
basis = basis_exterior_power(B, 1)
list_mon, list_coeff = collect(monomials(f)), collect(Oscar.coefficients(f))
part= [(list_coeff[i], [list_mon[i]]) for i=1:length(list_mon)]
return part
end
f = popfirst!(F)
wp = wedge_product(copy(F))
R = parent(f)