-
Notifications
You must be signed in to change notification settings - Fork 113
/
types.jl
699 lines (548 loc) · 20.4 KB
/
types.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
@doc raw"""
GAPGroup <: AbstractAlgebra.Group
Each object of the abstract type `GAPGroup` stores a group object from
the GAP system,
and thus can delegate questions about this object to GAP.
For expert usage, you can extract the underlying GAP object via `GapObj`,
i.e., if `G` is a `GAPGroup`, then `GapObj(G)` is the `GapObj` underlying `G`.
Concrete subtypes of `GAPGroup` are `PermGroup`, `FPGroup`, `SubFPGroup`,
`PcGroup`, `SubPcGroup`, and `MatrixGroup`.
"""
abstract type GAPGroup <: AbstractAlgebra.Group end
## `GapGroup` to GAP group
GAP.julia_to_gap(obj::GAPGroup) = obj.X
@doc raw"""
GAPGroupElem <: AbstractAlgebra.GroupElem
Each object of the abstract type `GAPGroupElem` stores a group element
object from the GAP system,
and thus can delegate questions about this object to GAP.
For expert usage, you can extract the underlying GAP object via `GapObj`,
i.e., if `g` is a `GAPGroupElem`, then `GapObj(g)` is the `GapObj` underlying `g`.
"""
abstract type GAPGroupElem{T<:GAPGroup} <: AbstractAlgebra.GroupElem end
## `GapGroupElem` to GAP group element
GAP.julia_to_gap(obj::GAPGroupElem) = obj.X
@doc raw"""
BasicGAPGroupElem{T<:GAPGroup} <: GAPGroupElem{T}
The type `BasicGAPGroupElem` gathers all types of group elements
described *only* by an underlying GAP object.
If $x$ is an element of the group `G` of type `T`,
then the type of $x$ is `BasicGAPGroupElem{T}`.
"""
struct BasicGAPGroupElem{T<:GAPGroup} <: GAPGroupElem{T}
parent::T
X::GapObj
end
function Base.deepcopy_internal(x::BasicGAPGroupElem, dict::IdDict)
X = Base.deepcopy_internal(GapObj(x), dict)
return BasicGAPGroupElem(x.parent, X)
end
Base.hash(x::GAPGroup, h::UInt) = h # FIXME
Base.hash(x::GAPGroupElem, h::UInt) = h # FIXME
"""
PermGroup
Groups of permutations.
Every group of this type is a subgroup of Sym(n) for some n.
# Examples
- `symmetric_group(n::Int)`: the symmetric group Sym(n)
- `alternating_group(n::Int)`: the alternating group Alt(n)
- subgroups of Sym(n)
- `dihedral_group(PermGroup, n::Int)`:
the dihedral group of order `n` as a group of permutations.
Same holds replacing `dihedral_group` by `quaternion_group`
If `G` is a permutation group and `x` is a permutation,
`G(x)` returns a permutation `x` with parent `G`;
an exception is thrown if `x` does not embed into `G`.
```jldoctest
julia> G=symmetric_group(5)
Sym(5)
julia> x=cperm([1,2,3])
(1,2,3)
julia> parent(x)
Sym(3)
julia> y=G(x)
(1,2,3)
julia> parent(y)
Sym(5)
```
If `G` is a permutation group and `x` is a vector of integers,
`G(x)` returns a [`PermGroupElem`](@ref) with parent `G`;
an exception is thrown if the element does not embed into `G`.
# Examples
```jldoctest
julia> G = symmetric_group(6)
Sym(6)
julia> x = G([2,4,6,1,3,5])
(1,2,4)(3,6,5)
julia> parent(x)
Sym(6)
```
"""
@attributes mutable struct PermGroup <: GAPGroup
X::GapObj
deg::Int64 # G < Sym(deg)
function PermGroup(G::GapObj)
@assert GAPWrap.IsPermGroup(G)
n = GAPWrap.LargestMovedPoint(G)::Int
if n == 0
# We support only positive degrees.
# (`symmetric_group(0)` yields an error,
# and `symmetric_group(1)` yields a GAP group with `n == 0`.)
n = 1
end
z = new(G, n)
return z
end
function PermGroup(G::GapObj, deg::Int)
@assert GAPWrap.IsPermGroup(G) && deg > 0 && deg >= GAPWrap.LargestMovedPoint(G)::Int
z = new(G, deg)
return z
end
end
permutation_group(G::GapObj) = PermGroup(G)
permutation_group(G::GapObj, deg::Int) = PermGroup(G, deg)
"""
PermGroupElem
Element of a group of permutations.
It is displayed as product of disjoint cycles.
# Assumptions:
- for `x`,`y` in Sym(n), the product `xy` is read from left to right;
- for `x` in Sym(n) and `i` in {1,...,n}, `i^x` and `x(i)` return the image of `i` under the action of `x`.
"""
const PermGroupElem = BasicGAPGroupElem{PermGroup}
"""
PcGroup
Polycyclic group, a group that is defined by a finite presentation
of a special kind, a so-called polycyclic presentation.
Contrary to arbitrary finitely presented groups
(see [Finitely presented groups](@ref)),
this presentation allows for efficient computations with the group elements.
For a group `G` of type `PcGroup`, the elements in `gens(G)` satisfy the
relators of the underlying presentation.
Functions that compute subgroups of `G` return groups of type `SubPcGroup`.
# Examples
- `cyclic_group(n::Int)`: cyclic group of order `n`
- `abelian_group(PcGroup, v::Vector{Int})`:
direct product of cyclic groups of the orders
`v[1]`, `v[2]`, ..., `v[length(v)]`
"""
@attributes mutable struct PcGroup <: GAPGroup
X::GapObj
as_sub_pc_group::GAPGroup # we cannot prescribe `SubPcGroup`
function PcGroup(G::GapObj)
# The constructor is not allowed to replace the given GAP group.
# (The function `pc_group` may do this.)
@assert _is_full_pc_group(G)
return new(G)
end
end
function pc_group(G::GapObj)
_is_full_pc_group(G) && return PcGroup(G)
# Switch to a full pcp or pc group.
if GAPWrap.IsPcpGroup(G)
return PcGroup(GAP.Globals.PcpGroupByPcp(GAP.Globals.Pcp(G)::GapObj)::GapObj)
elseif GAPWrap.IsPcGroup(G)
return PcGroup(GAP.Globals.PcGroupWithPcgs(GAP.Globals.Pcgs(G)::GapObj)::GapObj)
end
throw(ArgumentError("G must be in IsPcGroup or IsPcpGroup"))
end
# Return `true` if the generators of `G` fit to those of its pc presentation.
function _is_full_pc_group(G::GapObj)
GAPWrap.IsPcpGroup(G) || GAPWrap.IsPcGroup(G) || return false
return GAP.Globals.GroupGeneratorsDefinePresentation(G)::Bool
end
#T the code for PcpGroups is too expensive!
function as_sub_pc_group(G::PcGroup)
if !isdefined(G, :as_sub_pc_group)
G.as_sub_pc_group = sub_pc_group(G)
end
return G.as_sub_pc_group::SubPcGroup
end
"""
PcGroupElem
Element of a polycyclic group.
The generators of a polycyclic group are displayed as `f1`, `f2`, `f3`, etc.,
and every element of a polycyclic group is displayed as product of the
generators.
# Examples
```jldoctest
julia> G = abelian_group(PcGroup, [2, 3]);
julia> G[1], G[2]
(f1, f2)
julia> G[2]*G[1]
f1*f2
```
Note that this does not define Julia variables named `f1`, `f2`, etc.!
To get the generators of the group `G`, use `gens(G)`;
for convenience they can also be accessed as `G[1]`, `G[2]`,
as shown in Section [Elements of groups](@ref elements_of_groups).
"""
const PcGroupElem = BasicGAPGroupElem{PcGroup}
"""
SubPcGroup
Subgroup of a polycyclic group,
a group that is defined by generators that are elements of a group `G`
of type [`PcGroup`](@ref).
The arithmetic operations with elements are thus performed using the
polycyclic presentation of `G`.
Operations for computing subgroups of a group of type `PcGroup` or
`SubPcGroup`, such as `derived_subgroup` and `sylow_subgroup`,
return groups of type `SubPcGroup`.
"""
@attributes mutable struct SubPcGroup <: GAPGroup
X::GapObj
full_group::PcGroup
#T better create an embedding!
function SubPcGroup(G::GapObj)
@assert GAPWrap.IsPcGroup(G) || GAPWrap.IsPcpGroup(G)
if GAPWrap.IsPcGroup(G)
full = GAPWrap.GroupOfPcgs(GAPWrap.FamilyPcgs(G))
else
full = GAPWrap.PcpGroupByCollectorNC(GAPWrap.Collector(G))
end
z = new(G, PcGroup(full))
return z
end
end
sub_pc_group(G::GapObj) = SubPcGroup(G)
"""
SubPcGroupElem
Element of a subgroup of a polycyclic group.
The elements are displayed in the same way as the elements of full
polycyclic groups, see [`PcGroupElem`](@ref).
# Examples
```jldoctest
julia> G = abelian_group(SubPcGroup, [4, 2]);
julia> G[1], G[2]
(f1, f3)
julia> G[2]*G[1]
f1*f3
```
"""
const SubPcGroupElem = BasicGAPGroupElem{SubPcGroup}
"""
FPGroup
Finitely presented group.
Such groups can be constructed a factors of free groups,
see [`free_group`](@ref).
For a group `G` of type `FPGroup`, the elements in `gens(G)` satisfy the
relators of the underlying presentation.
Functions that compute subgroups of `G` return groups of type `SubFPGroup`.
"""
@attributes mutable struct FPGroup <: GAPGroup
X::GapObj
as_sub_fp_group::GAPGroup # we cannot prescribe `SubFPGroup`
function FPGroup(G::GapObj)
# Accept only full f.p. groups.
@assert GAPWrap.IsFpGroup(G)
return new(G)
end
end
function fp_group(G::GapObj)
_is_full_fp_group(G) && return FPGroup(G)
# Switch to a full fp group.
@req GAPWrap.IsSubgroupFpGroup(G) "G must be in IsSubgroupFpGroup"
f = GAP.Globals.IsomorphismFpGroup(G)::GapObj
return FPGroup(GAPWrap.Range(f))
end
# Return `true` if the generators of `G` fit
# to those of its underlying presentation.
_is_full_fp_group(G::GapObj) = GAPWrap.IsFpGroup(G)
function as_sub_fp_group(G::FPGroup)
if !isdefined(G, :as_sub_fp_group)
G.as_sub_fp_group = sub_fp_group(G)
end
return G.as_sub_fp_group::SubFPGroup
end
"""
FPGroupElem
Element of a finitely presented group.
The generators of a finitely presented group are displayed as
`f1`, `f2`, `f3`, etc.,
and every element of a finitely presented group is displayed as product of the
generators.
"""
const FPGroupElem = BasicGAPGroupElem{FPGroup}
"""
SubFPGroup
Subgroup of a finitely presented group,
a group that is defined by generators that are elements of a group `G`
of type [`FPGroup`](@ref).
Operations for computing subgroups of a group of type `FPGroup` or
`SubFPGroup`, such as `derived_subgroup` and `sylow_subgroup`,
return groups of type `SubFPGroup`.
Note that functions such as [`relators`](@ref) do not make sense for proper
subgroups of a finitely presented group.
"""
@attributes mutable struct SubFPGroup <: GAPGroup
X::GapObj
full_group::FPGroup
#T better create an embedding!
function SubFPGroup(G::GapObj)
@assert GAPWrap.IsSubgroupFpGroup(G)
full = GAP.getbangproperty(GAPWrap.FamilyObj(G), :wholeGroup)::GapObj
z = new(G, FPGroup(full))
return z
end
end
sub_fp_group(G::GapObj) = SubFPGroup(G)
"""
SubFPGroupElem
Element of a subgroup of a finitely presented group.
The elements are displayed in the same way as the elements of full
finitely presented groups, see [`FPGroupElem`](@ref).
"""
const SubFPGroupElem = BasicGAPGroupElem{SubFPGroup}
abstract type AbstractMatrixGroupElem <: GAPGroupElem{GAPGroup} end
# NOTE: always defined are deg, ring and at least one between { X, gens, descr }
"""
MatrixGroup{RE<:RingElem, T<:MatElem{RE}} <: GAPGroup
Type of groups `G` of `n x n` matrices over the ring `R`, where `n = degree(G)` and `R = base_ring(G)`.
"""
@attributes mutable struct MatrixGroup{RE<:RingElem, T<:MatElem{RE}} <: GAPGroup
deg::Int
ring::Ring
X::GapObj
gens::Vector{<:AbstractMatrixGroupElem}
descr::Symbol # e.g. GL, SL, symbols for isometry groups
ring_iso::MapFromFunc # Isomorphism from the Oscar base ring to the GAP base ring
function MatrixGroup{RE,T}(F::Ring, m::Int) where {RE,T}
G = new{RE, T}()
G.deg = m
G.ring = F
return G
end
end
# NOTE: at least one of the fields :elm and :X must always defined, but not necessarily both of them.
"""
MatrixGroupElem{RE<:RingElem, T<:MatElem{RE}} <: AbstractMatrixGroupElem
Elements of a group of type `MatrixGroup{RE<:RingElem, T<:MatElem{RE}}`
"""
mutable struct MatrixGroupElem{RE<:RingElem, T<:MatElem{RE}} <: AbstractMatrixGroupElem
parent::MatrixGroup{RE, T}
elm::T # Oscar matrix
X::GapObj # GAP matrix. If x isa MatrixGroupElem, then x.X = map_entries(x.parent.ring_iso, x.elm)
# full constructor
MatrixGroupElem{RE,T}(G::MatrixGroup{RE,T}, x::T, x_gap::GapObj) where {RE, T} = new{RE,T}(G, x, x_gap)
# constructor which leaves `X` undefined
MatrixGroupElem{RE,T}(G::MatrixGroup{RE,T}, x::T) where {RE, T} = new{RE,T}(G, x)
# constructor which leaves `elm` undefined
function MatrixGroupElem{RE,T}(G::MatrixGroup{RE,T}, x_gap::GapObj) where {RE, T}
z = new{RE,T}(G)
z.X = x_gap
return z
end
end
################################################################################
#
# Construct an Oscar group wrapping the GAP group `obj`
# *and* compatible with a given Oscar group `G`.
sub_type(T::Type) = T
sub_type(::Type{PcGroup}) = SubPcGroup
sub_type(::Type{FPGroup}) = SubFPGroup
sub_type(G::GAPGroup) = sub_type(typeof(G))
# `_oscar_subgroup(obj, G)` is used to create the subgroup of `G`
# that is described by the GAP group `obj`;
# default: ignore `G`
function _oscar_subgroup(obj::GapObj, G::GAPGroup)
S = sub_type(G)(obj)
@assert GAP.Globals.FamilyObj(GapObj(S)) === GAP.Globals.FamilyObj(GapObj(G))
return S
end
#T better rename to _oscar_subgroup?
# `PermGroup`: set the degree of `G`
function _oscar_subgroup(obj::GapObj, G::PermGroup)
n = GAPWrap.LargestMovedPoint(obj)
N = degree(G)
n <= N || error("requested degree ($N) is smaller than the largest moved point ($n)")
return permutation_group(obj, N)
end
# `MatrixGroup`: set dimension and ring of `G`
function _oscar_subgroup(obj::GapObj, G::MatrixGroup)
d = GAP.Globals.DimensionOfMatrixGroup(obj)
d == G.deg || error("requested dimension of matrices ($(G.deg)) does not match the given matrix dimension ($d)")
R = G.ring
iso = _ring_iso(G)
GAPWrap.IsSubset(codomain(iso), GAP.Globals.FieldOfMatrixGroup(obj)) || error("matrix entries are not in the requested ring ($(codomain(iso)))")
M = matrix_group(R, d)
M.X = obj
M.ring = R
M.ring_iso = iso
return M
end
################################################################################
abstract type GSet{T} end
################################################################################
#
# Conjugacy Classes
#
################################################################################
"""
GroupConjClass{T, S}
It can be either the conjugacy class of an element or of a subgroup of type `S`
in a group `G` of type `T`.
"""
abstract type GroupConjClass{T, S} <: GSet{T} end
################################################################################
#
# Group Homomorphism
#
################################################################################
abstract type GAPMap <: SetMap end
struct GAPGroupHomomorphism{S<: GAPGroup, T<: GAPGroup} <: Map{S,T,GAPMap,GAPGroupHomomorphism{S,T}}
domain::S
codomain::T
map::GapObj
function GAPGroupHomomorphism(G::S, H::T, mp::GapObj) where {S<: GAPGroup, T<: GAPGroup}
return new{S, T}(G, H, mp)
end
end
GapObj(f::GAPGroupHomomorphism) = f.map
"""
AutomorphismGroup{T} <: GAPGroup
Group of automorphisms over a group of type `T`. It can be defined via the function `automorphism_group`
"""
@attributes mutable struct AutomorphismGroup{T} <: GAPGroup
X::GapObj
G::T
function AutomorphismGroup{T}(G::GapObj, H::T) where T
@assert GAPWrap.IsGroupOfAutomorphisms(G)
z = new{T}(G, H)
return z
end
end
function AutomorphismGroup(G::GapObj, H::T) where T
return AutomorphismGroup{T}(G, H)
end
(aut::AutomorphismGroup{T} where T)(x::GapObj) = group_element(aut,x)
const AutomorphismGroupElem{T} = BasicGAPGroupElem{AutomorphismGroup{T}} where T
function Base.show(io::IO, AGE::AutomorphismGroupElem{FinGenAbGroup})
print(io, "Automorphism of ", FinGenAbGroup, " with matrix representation ", matrix(AGE))
end
################################################################################
#
# Composite Groups
#
################################################################################
"""
DirectProductGroup
Either direct product of two or more groups of any type, or subgroup of a direct product of groups.
"""
@attributes mutable struct DirectProductGroup <: GAPGroup
X::GapObj
L::Vector{<:GAPGroup} # list of groups
Xfull::GapObj # direct product of the GAP groups of L
isfull::Bool # true if G is direct product of the groups of L, false if it is a proper subgroup
function DirectProductGroup(X::GapObj, L::Vector{<:GAPGroup}, Xfull::GapObj, isfull::Bool)
return new(X, L, Xfull, isfull)
end
end
"""
SemidirectProductGroup{S,T}
Semidirect product of two groups of type `S` and `T` respectively, or
subgroup of a semidirect product of groups.
"""
@attributes mutable struct SemidirectProductGroup{S<:GAPGroup, T<:GAPGroup} <: GAPGroup
X::GapObj
N::S # normal subgroup
H::T # group acting on N
f::GAPGroupHomomorphism{T,AutomorphismGroup{S}} # action of H on N
Xfull::GapObj # full semidirect product: X is a subgroup of Xfull.
isfull::Bool # true if X==Xfull
function SemidirectProductGroup{S, T}(X::GapObj, N::S, H::T, f::GAPGroupHomomorphism{T,AutomorphismGroup{S}}, Xfull::GapObj, isfull::Bool) where {S<:GAPGroup, T<:GAPGroup}
return new{S, T}(X, N, H, f, Xfull, isfull)
end
end
"""
WreathProductGroup
Wreath product of a group `G` and a group of permutations `H`, or a generic
group `H` together with the homomorphism `a` from `H` to a permutation
group.
"""
@attributes mutable struct WreathProductGroup <: GAPGroup
X::GapObj
G::GAPGroup
H::GAPGroup
a::GAPGroupHomomorphism # morphism from H to the permutation group
Xfull::GapObj # if H does not move all the points, this is the wreath product of (G, Sym(degree(H))
isfull::Bool # true if Xfull == X
function WreathProductGroup(X::GapObj, G::GAPGroup, H::GAPGroup, a::GAPGroupHomomorphism, Xfull::GapObj, isfull::Bool)
return new(X, G, H, a, Xfull, isfull)
end
end
"""
elem_type(::Type{T}) where T <: GAPGroup
elem_type(::T) where T <: GAPGroup
`elem_type` maps (the type of) a group to the type of its elements.
For now, a group of type `T` has elements of type `BasicGAPGroupElem{T}`.
So we provide it mostly for consistency with other parts of OSCAR.
In the future, a more elaborate setup for group element types
might also be needed.
"""
elem_type(::Type{T}) where T <: GAPGroup = BasicGAPGroupElem{T}
Base.eltype(::Type{T}) where T <: GAPGroup = BasicGAPGroupElem{T}
# `parent_type` is defined and documented in AbstractAlgebra.
parent_type(::Type{BasicGAPGroupElem{T}}) where T <: GAPGroup = T
#
# The array _gap_group_types contains pairs (X,Y) where
# X is a GAP filter such as IsPermGroup, and Y is a corresponding
# Julia type such as `PermGroup`.
#
const _gap_group_types = Tuple{GapObj, Type}[]
# `_oscar_group(G)` wraps the GAP group `G` into a suitable Oscar group `OG`,
# such that `GapObj(OG)` is equal to `G`.
# The function is not allowed to create an independent new GAP group object;
# this would be fatal at least for pc groups and fp groups.
function _oscar_group(G::GapObj)
for pair in _gap_group_types
if pair[1](G)
if pair[2] == MatrixGroup
#T HACK: We need more information in the case of matrix groups.
#T (Usually we should not need to guess the Oscar side of a GAP group.)
deg = GAP.Globals.DimensionOfMatrixGroup(G)
iso = iso_gap_oscar(GAP.Globals.FieldOfMatrixGroup(G))
ring = codomain(iso)
matgrp = matrix_group(ring, deg)
matgrp.ring_iso = inv(iso)
matgrp.X = G
return matgrp
elseif pair[2] == AutomorphismGroup
actdom_gap = GAP.Globals.AutomorphismDomain(G)
actdom_oscar = _oscar_group(actdom_gap)
return AutomorphismGroup(G, actdom_oscar)
elseif pair[2] === PcGroup && !_is_full_pc_group(G)
# We have to switch to the appropriate subgroup type
# if and only if `G` is not the full group.
return SubPcGroup(G)
elseif pair[2] === FPGroup && !_is_full_fp_group(G)
# We have to switch to the appropriate subgroup type
# if and only if `G` is not the full group.
return SubFPGroup(G)
else
return pair[2](G)
end
end
end
error("Not a known type of group")
end
# Check the compatibility of two groups in the sense that an element in the
# first group can be multiplied with an element in the second.
#T To which group does the product belong?
#T In which functions is this used?
# The group *types* can be different.
# The underlying GAP groups must belong to the same family.
function _check_compatible(G1::GAPGroup, G2::GAPGroup; error::Bool = true)
GAPWrap.FamilyObj(G1.X) === GAPWrap.FamilyObj(G2.X) && return true
error && throw(ArgumentError("G1 and G2 are not compatible"))
return false
end
# Any two permutation groups are compatible.
_check_compatible(G1::PermGroup, G2::PermGroup; error::Bool = true) = true
# The groups must have the same dimension and the same base ring.
function _check_compatible(G1::MatrixGroup, G2::MatrixGroup; error::Bool = true)
base_ring(G1) == base_ring(G2) && degree(G1) == degree(G2) && return true
error && throw(ArgumentError("G1 and G2 must have same base_ring and degree"))
return false
end
#TODO FinGenAbGroup: How do they behave?
# And does this question arise, since embeddings are used throughout?