-
Notifications
You must be signed in to change notification settings - Fork 140
/
Copy pathabelian_aut.jl
499 lines (427 loc) · 18.3 KB
/
abelian_aut.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
const AutGrpAbTor = Union{AutomorphismGroup{FinGenAbGroup},AutomorphismGroup{TorQuadModule}}
const AutGrpAbTorElem = Union{AutomorphismGroupElem{FinGenAbGroup},AutomorphismGroupElem{TorQuadModule}}
const AbTorElem = Union{FinGenAbGroupElem,TorQuadModuleElem}
# function _isomorphic_gap_group(A::FinGenAbGroup; T=PcGroup)
function _isomorphic_gap_group(A::FinGenAbGroup; T=SubPcGroup)
iso = isomorphism(T, A)
iso2 = inv(iso)
return codomain(iso), iso, iso2
end
@doc raw"""
automorphism_group(G::FinGenAbGroup) -> AutomorphismGroup{FinGenAbGroup}
Return the automorphism group of `G`.
"""
function automorphism_group(G::FinGenAbGroup)
Ggap, to_gap, to_oscar = _isomorphic_gap_group(G)
AutGAP = GAPWrap.AutomorphismGroup(Ggap.X)
aut = AutomorphismGroup(AutGAP, G)
set_attribute!(aut, :to_gap => to_gap, :to_oscar => to_oscar)
return aut
end
function apply_automorphism(f::AutGrpAbTorElem, x::AbTorElem, check::Bool=true)
aut = parent(f)
if check
@assert parent(x) == aut.G "Not in the domain of f!"
end
to_gap = get_attribute(aut, :to_gap)
to_oscar = get_attribute(aut, :to_oscar)
xgap = to_gap(x)
A = parent(f)
domGap = parent(xgap)
imgap = typeof(xgap)(domGap, GAPWrap.Image(f.X,xgap.X))
return to_oscar(imgap)::typeof(x)
end
(f::AutGrpAbTorElem)(x::AbTorElem) = apply_automorphism(f, x, true)
Base.:^(x::AbTorElem,f::AutGrpAbTorElem) = apply_automorphism(f, x, true)
# the _as_subgroup function needs a redefinition
# to pass on the to_gap and to_oscar attributes to the subgroup
function _as_subgroup(aut::AutomorphismGroup{S}, subgrp::GapObj) where S <: Union{TorQuadModule,FinGenAbGroup}
function img(x::AutomorphismGroupElem{S})
return group_element(aut, x.X)
end
to_gap = get_attribute(aut, :to_gap)
to_oscar = get_attribute(aut, :to_oscar)
subgrp1 = AutomorphismGroup{S}(subgrp, aut.G)
set_attribute!(subgrp1, :to_gap => to_gap, :to_oscar => to_oscar)
return subgrp1, hom(subgrp1, aut, img)
end
@doc raw"""
hom(f::AutomorphismGroupElem{FinGenAbGroup}) -> FinGenAbGroupHom
Return the element `f` of type `FinGenAbGroupHom`.
"""
function hom(f::AutGrpAbTorElem)
A = domain(f)
imgs = elem_type(A)[f(a) for a in gens(A)]
return hom(A, A, imgs)
end
function (aut::AutGrpAbTor)(f::Union{FinGenAbGroupHom,TorQuadModuleMap};check::Bool=true)
!check || (domain(f) === codomain(f) === domain(aut) && is_bijective(f)) || error("Map does not define an automorphism of the abelian group.")
to_gap = get_attribute(aut, :to_gap)
to_oscar = get_attribute(aut, :to_oscar)
Agap = domain(to_oscar)
AA = Agap.X
function img_gap(x)
a = to_oscar(group_element(Agap,x))
b = to_gap(f(a))
return b.X
end
gene = GAPWrap.GeneratorsOfGroup(AA)
img = GAP.Obj([img_gap(a) for a in gene])
fgap = GAP.Globals.GroupHomomorphismByImagesNC(AA,AA,img)
!check || fgap in aut.X || error("Map does not define an element of the group")
return aut(fgap)
end
function (aut::AutGrpAbTor)(M::ZZMatrix; check::Bool=true)
!check || defines_automorphism(domain(aut),M) || error("Matrix does not define an automorphism of the abelian group.")
return aut(hom(domain(aut),domain(aut),M); check=check)
end
function (aut::AutGrpAbTor)(g::MatrixGroupElem{QQFieldElem, QQMatrix}; check::Bool=true)
L = relations(domain(aut))
if check
B = basis_matrix(L)
@assert can_solve(B, B*matrix(g),side=:left)
end
T = domain(aut)
g = hom(T, T, elem_type(T)[T(lift(t)*matrix(g)) for t in gens(T)])
return aut(g, check = false)
end
@doc raw"""
matrix(f::AutomorphismGroupElem{FinGenAbGroup}) -> ZZMatrix
Return the underlying matrix of `f` as a module homomorphism.
"""
matrix(f::AutomorphismGroupElem{FinGenAbGroup}) = matrix(hom(f))
@doc raw"""
defines_automorphism(G::FinGenAbGroup, M::ZZMatrix) -> Bool
If `M` defines an endomorphism of `G`, return `true` if `M` defines an automorphism of `G`, else `false`.
"""
defines_automorphism(G::FinGenAbGroup, M::ZZMatrix) = is_bijective(hom(G,G,M))
################################################################################
#
# Special functions for orthogonal groups of torsion quadratic modules
#
################################################################################
"""
_orthogonal_group(T::TorQuadModule, gensOT::Vector{ZZMatrix}) -> AutomorphismGroup{TorQuadModule}
Return the subgroup of the orthogonal group of `G` generated by `gensOT`.
"""
function _orthogonal_group(T::TorQuadModule, gensOT::Vector{ZZMatrix}; check::Bool=true)
A = abelian_group(T)
As, AstoA = snf(A)
Ggap, to_gap, to_oscar = _isomorphic_gap_group(As)
function toAs(x)
return AstoA\A(x)
end
function toT(x)
return T(AstoA(x))
end
T_to_As = Hecke.map_from_func(toAs, T, As)
As_to_T = Hecke.map_from_func(toT, As, T)
to_oscar = compose(to_oscar, As_to_T)
to_gap = compose(T_to_As, to_gap)
AutGAP = GAPWrap.AutomorphismGroup(Ggap.X)
ambient = AutomorphismGroup(AutGAP, T)
set_attribute!(ambient, :to_gap => to_gap, :to_oscar => to_oscar)
gens_aut = GapObj([ambient(g, check=check).X for g in gensOT]) # performs the checks
if check
# expensive for large groups
subgrp_gap =GAP.Globals.Subgroup(ambient.X, gens_aut)
else
subgrp_gap =GAP.Globals.SubgroupNC(ambient.X, gens_aut)
end
aut = AutomorphismGroup(subgrp_gap, T)
set_attribute!(aut, :to_gap => to_gap, :to_oscar => to_oscar)
return aut
end
function Base.show(io::IO, aut::AutomorphismGroup{TorQuadModule})
T = domain(aut)
io = pretty(io)
n = ngens(aut)
print(IOContext(io, :compact => true), "Group of isometries of ", Lowercase(), T, " with ", ItemQuantity(n, "generator"))
end
@doc raw"""
matrix(f::AutomorphismGroupElem{TorQuadModule}) -> ZZMatrix
Return a matrix inducing `f`.
"""
matrix(f::AutomorphismGroupElem{TorQuadModule}) = matrix(hom(f))
@doc raw"""
defines_automorphism(G::TorQuadModule, M::ZZMatrix) -> Bool
If `M` defines an endomorphism of `G`, return `true` if `M` defines an automorphism of `G`, else `false`.
"""
function defines_automorphism(G::TorQuadModule, M::ZZMatrix)
g = hom(G, G, M)
if !is_bijective(g)
return false
end
# check that the form is preserved
B = gens(G)
n = length(B)
for i in 1:n
if Hecke.quadratic_product(B[i]) != Hecke.quadratic_product(g(B[i]))
return false
end
for j in 1:i-1
if B[i]*B[j] != g(B[i])*g(B[j])
return false
end
end
end
return true
end
function Base.show(io::IO, ::MIME"text/plain", f::AutomorphismGroupElem{T}) where T<:TorQuadModule
D = domain(parent(f))
io = pretty(io)
println(IOContext(io, :compact => true), "Isometry of ", Lowercase(), D, " defined by")
print(io, Indent(), matrix(f), Dedent())
end
function Base.show(io::IO, f::AutomorphismGroupElem{T}) where T<:TorQuadModule
print(io, matrix(f))
end
@doc raw"""
orthogonal_group(T::TorQuadModule) -> AutomorphismGroup{TorQuadModule}
Return the full orthogonal group of this torsion quadratic module.
"""
@attr AutomorphismGroup{TorQuadModule} function orthogonal_group(T::TorQuadModule)
if is_trivial(abelian_group(T))
return _orthogonal_group(T, ZZMatrix[identity_matrix(ZZ, ngens(T))], check = false)
elseif is_semi_regular(T)
# if T is semi-regular, it is isometric to its normal form for which
# we know how to compute the isometries.
N, i = normal_form(T)
j = inv(i)
gensOT = _compute_gens(N)
gensOT = TorQuadModuleMap[hom(N, N, g) for g in gensOT]
gensOT = ZZMatrix[compose(compose(i,g),j).map_ab.map for g in gensOT]
unique!(gensOT)
length(gensOT) > 1 ? filter!(m -> !isone(m), gensOT) : nothing
elseif iszero(gram_matrix_quadratic(T))
# in that case, we don't have any conditions regarding the
# quadratic form, so we have all automorphisms coming
# from the underlying abelian group
gensOT = [matrix(g) for g in gens(automorphism_group(abelian_group(T)))]
else
# if T is not semi-regular, we distinghuish the cases whether or not
# it splits its radical quadratic
i = radical_quadratic(T)[2]
gensOT = has_complement(i)[1] ? _compute_gens_split_degenerate(T) : _compute_gens_non_split_degenerate(T)
end
return _orthogonal_group(T, gensOT, check=false)
end
@doc raw"""
embedding_orthogonal_group(i::TorQuadModuleMap) -> GAPGroupHomomorphism
Given an embedding $i\colon A \to D$ between two torsion quadratic modules,
such that `A` admits a complement `B` in $D \cong A \oplus B$ to which it is
orthogonal, return the embedding $O(A) \to O(D)$ obtained by extending the
isometries of `A` by the identity on `B`.
"""
function embedding_orthogonal_group(i::TorQuadModuleMap)
@req is_injective(i) "i must be injective"
ok, j = has_complement(i)
@req ok "The domain of i must have a complement in the codomain"
@req all(v -> i(v[1])*j(v[2]) == 0, Hecke.cartesian_product_iterator([gens(domain(i)), gens(domain(j))], inplace=true)) "The domain of i and its complement must be in orthogonal direct sum"
A = domain(i)
B = domain(j)
D = codomain(i)
OD = orthogonal_group(D)
OA = orthogonal_group(A)
# D = A+B
gene = data.(union(i.(gens(A)), j.(gens(B))))
geneOAinOD = elem_type(OD)[]
for f in gens(OA)
imgf = data.(union(i.(f.(gens(A))), j.(gens(B))))
fab = hom(abelian_group(D), abelian_group(D), gene, imgf)
fD = OD(hom(D, D, fab.map))
push!(geneOAinOD, fD)
end
OAtoOD = hom(OA, OD, geneOAinOD, check = false)
return OAtoOD::GAPGroupHomomorphism{AutomorphismGroup{TorQuadModule}, AutomorphismGroup{TorQuadModule}}
end
###############################################################################
#
# Action on injections
#
###############################################################################
@doc raw"""
is_invariant(f::TorQuadModuleMap, i::TorQuadModuleMap) -> Bool
Given an abelian group morphism $i\colon S \to T$ form a torsion quadratic module
`S` to a torsion quadratic module `T`, and an abelian group endomorphism `f`
of `T`, return whether `f` preserves the image of `i` in `T`, i.e. whether
$f(i(s)) \in i(S)$ for all $s \in S$.
"""
function is_invariant(f::TorQuadModuleMap, i::TorQuadModuleMap)
@req domain(f) === codomain(f) === codomain(i) "f must be an endomorphism of the target of i"
U = domain(i)
for a in gens(U)
b = f(i(a))
has_preimage_with_preimage(i, b)[1] || return false
end
return true
end
@doc raw"""
is_invariant(f::AutomorphismGroupElem{TorQuadModule}, i::TorQuadModuleMap)
-> Bool
Given an abelian group morphism $i\colon S \to T$ from a torsion quadratic module
`S` to a torsion quadratic module `T`, and an automorphism `f` of `T`, return
whether `f` preserves the image of `i` in `T`, i.e. whether
$f(i(s)) \in i(S)$ for all $s \in S$.
"""
function is_invariant(f::AutomorphismGroupElem{TorQuadModule}, i::TorQuadModuleMap)
@req domain(parent(f)) === codomain(i) "f must be an automorphism of the target of i"
return is_invariant(hom(f), i)
end
@doc raw"""
is_invariant(G::AutomorphismGroup{TorQuadModule}, i::TorQuadModuleMap)
-> Bool
Given an abelian group morphism $i\colon S \to T$ from a torsion quadratic module
`S` to a torsion quadratic module `T`, and a group `G` of automorphisms of `T`,
return whether the image of `i` in `T` is preserved by every element in
`G`, i.e. whether $f(i(s)) \in i(S)$ for all $s \in S$ and all $f \in G$
"""
function is_invariant(G::AutomorphismGroup{TorQuadModule}, i::TorQuadModuleMap)
@req domain(G) === codomain(i) "G must consist of automorphisms of the target of i"
return all(f -> is_invariant(f, i), gens(G))
end
@doc raw"""
restrict_endomorphism(f::TorQuadModule, i::TorQuadModuleMap)
-> TorQuadModuleMap
Given an abelian group embedding $i\colon S \to T$ of a torsion quadratic
module `S` in a torsion quadratic module `T`, and an abelian group endomorphism
of `T`, return the restriction of `f` to `S`.
If `S` is not invariant under the action of `f`, then an error is thrown.
"""
function restrict_endomorphism(f::TorQuadModuleMap, i::TorQuadModuleMap; check::Bool = true)
@req !check || is_injective(i) "i must be an injection"
@req domain(f) === codomain(f) === codomain(i) "f must be an endomorphism of the target of i"
imgs = TorQuadModuleElem[]
U = domain(i)
for a in gens(U)
b = f(i(a))
ok, c = has_preimage_with_preimage(i, b)
@req ok "The domain of i is not invariant under the action of f"
push!(imgs, c)
end
return hom(U, U, imgs)
end
@doc raw"""
restrict_automorphism(f::AutomorphismGroupElem{TorQuadModule},
i::TorQuadModuleMap) -> TorQuadModuleMap
Given an abelian group embedding $i\colon S \to T$ of a torsion quadratic
module `S` in a torsion quadratic module `T`, and an automorphism `f` of `T`,
return the restriction of `f` to `S`.
If `S` is not invariant under the action of `f`, then an error is thrown.
"""
function restrict_automorphism(f::AutomorphismGroupElem{TorQuadModule}, i::TorQuadModuleMap; check::Bool = true)
@req !check || is_injective(i) "i must be an injection"
@req domain(parent(f)) === codomain(i) "f must be an automorphism of the target of i"
return restrict_endomorphism(hom(f), i, check = false)
end
@doc raw"""
restrict_automorphism_group(G::AutomorphismGroup{TorQuadModule},
i::TorQuadModuleMap; check::Bool = true)
-> AutomorphismGroup{TorQuadModule},
GAPGroupHomomorphism
Given an embedding $i\colon S \to T$ of a torsion quadratic module `S` in a
torsion quadratic module `T`, and a group `G` of automorphisms of `T`, return
the group of automorphisms `H` of `S` generated by the restrictions of the
elements in `G` to `S`, together with the restriction map $G \to H$.
If `S` is not invariant under the action of `G`, then an error is thrown.
By default, the function checks whether `i` is injective and whether `i`
is a torsion quadratic module morphism. One can disable these checks
by setting `check = false`.
"""
function restrict_automorphism_group(G::AutomorphismGroup{TorQuadModule}, i::TorQuadModuleMap; check::Bool = true)
if check
@req is_injective(i) "i must be an injection"
@req modulus_bilinear_form(domain(i)) == modulus_bilinear_form(codomain(i)) "The bilinear forms of the domain and the codomain of i must take values in the same torsion module"
@req modulus_quadratic_form(domain(i)) == modulus_quadratic_form(codomain(i)) "The quadratic forms of the domain and the codomain of i must take values in the same torsion module"
@req all(a -> all(b -> a*b == i(a)*i(b), gens(domain(i))), gens(domain(i))) "i must preserve bilinear products"
@req all(a -> Hecke.quadratic_product(a) == Hecke.quadratic_product(i(a)), gens(domain(i))) "i must preserve quadratic products"
end
@req domain(G) === codomain(i) "G must consist of automorphisms of the target of i"
restr = ZZMatrix[]
for f in gens(G)
g = try restrict_automorphism(f, i, check = false)
catch e throw(ArgumentError("The domain of i is not invariant under the action of G"))
end
push!(restr, g.map_ab.map)
end
H = _orthogonal_group(domain(i), unique(restr), check = check)
res = hom(G, H, gens(G), H.(restr), check = check)
return H, res
end
###############################################################################
#
# Action on submodules
#
###############################################################################
@doc raw"""
is_conjugate_with_data(O::AutomorphismGroup{TorQuadModule},
i::TorQuadModuleMap,
j::TorQuadModuleMap)
-> Bool, AutomorphismGroupElem{TorQuadModule}
Return whether the images of `i` and `j` in the domain of `O` lies in the same
orbit of `O` under its action on subgroups.
If yes, return `(true, g)` where `g` is an element of `O` mapping the image of `i`
to the image of `j`.
Otherwise return `(false, nothing)`.
# Examples
```jldoctest
julia> T = torsion_quadratic_module(matrix(QQ, 2, 2, [2//3 0; 0 2//5]))
Finite quadratic module
over integer ring
Abelian group: Z/15
Bilinear value module: Q/Z
Quadratic value module: Q/2Z
Gram matrix quadratic form:
[4//15]
julia> OT = orthogonal_group(T)
Group of isometries of finite quadratic module: Z/15 -> Q/2Z with 2 generators
julia> T3inT = primary_part(T, 3)[2]
Map
from finite quadratic module: Z/3 -> Q/2Z
to finite quadratic module: Z/15 -> Q/2Z
julia> T5inT = primary_part(T, 5)[2]
Map
from finite quadratic module: Z/5 -> Q/2Z
to finite quadratic module: Z/15 -> Q/2Z
julia> is_conjugate_with_data(OT, T3inT, T5inT)
(false, [1])
```
"""
function is_conjugate_with_data(O::AutomorphismGroup{TorQuadModule},
i::TorQuadModuleMap,
j::TorQuadModuleMap)
@req domain(O) === codomain(i) === codomain(j) "Wrong parents"
to_gap = get_attribute(O, :to_gap)
Agap = codomain(to_gap)
Hgap, _ = sub(Agap, elem_type(Agap)[to_gap(i(a)) for a in gens(domain(i))])
G = GSetByElements(O, on_subgroups, typeof(Hgap)[Hgap])
Kgap, _ = sub(Agap, elem_type(Agap)[to_gap(j(a)) for a in gens(domain(j))])
return is_conjugate_with_data(G, Hgap, Kgap)
end
@doc raw"""
stabilizer(O::AutomorphismGroup{TorQuadModule}, i::TorQuadModuleMap)
-> AutomorphismGroup{TorQuadModule},
GAPGroupHomomorphism
Return the stabilizer of the image of `i` under the action of `O` on the subgroups
of the codomain of `i`.
# Examples
```jldoctest
julia> T = torsion_quadratic_module(matrix(QQ, 2, 2, [2//3 0; 0 2//5]));
julia> OT = orthogonal_group(T)
Group of isometries of finite quadratic module: Z/15 -> Q/2Z with 2 generators
julia> T3inT = primary_part(T, 3)[2]
Map
from finite quadratic module: Z/3 -> Q/2Z
to finite quadratic module: Z/15 -> Q/2Z
julia> S, _ = stabilizer(OT, T3inT)
(Group of isometries of finite quadratic module: Z/15 -> Q/2Z with 2 generators, Hom: group of isometries of finite quadratic module with 2 generators -> group of isometries of finite quadratic module with 2 generators)
julia> order(S)
4
```
"""
function stabilizer(O::AutomorphismGroup{TorQuadModule}, i::TorQuadModuleMap)
to_gap = get_attribute(O, :to_gap)
Agap = codomain(to_gap)
Hgap, _ = sub(Agap, elem_type(Agap)[to_gap(i(a)) for a in gens(domain(i))])
return stabilizer(O, Hgap.X, on_subgroups)
end