-
Notifications
You must be signed in to change notification settings - Fork 113
/
secondary_invariants.jl
514 lines (436 loc) · 17.7 KB
/
secondary_invariants.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
function add_invariant!(
C::SecondaryInvarsCache{T}, f::T, isirred::Bool, exps::Vector{Int}
) where {T}
push!(C.invars, f)
push!(C.is_irreducible, isirred)
if isirred
for exp in C.sec_in_irred
push!(exp, 0)
end
end
push!(C.sec_in_irred, exps)
return nothing
end
################################################################################
#
# Modular case
#
################################################################################
# DK15, Algorithm 3.7.5
function secondary_invariants_modular(RG::FinGroupInvarRing)
Rgraded = polynomial_ring(RG)
# We have to compute a lot with these polynomials and the grading only
# gets in the way (one cannot ask for total_degree and even if one could
# the answer would be a FinGenAbGroupElem where it could be an Int)
R = forget_grading(Rgraded)
K = coefficient_ring(R)
p_invars = elem_type(R)[forget_grading(f) for f in primary_invariants(RG)]
s_invars = elem_type(R)[one(R)]
s_invars_cache = SecondaryInvarsCache{elem_type(Rgraded)}()
add_invariant!(s_invars_cache, one(Rgraded), false, Int[])
# The maximal degree in which we have to look for secondary invariants by [Sym11].
maxdeg = sum(total_degree(f) - 1 for f in p_invars)
# Store the secondary invariants sorted by their total degree.
# We only store the indices in s_invars_cache.invars.
s_invars_sorted = Vector{Vector{Int}}(undef, maxdeg)
for d in 1:maxdeg
s_invars_sorted[d] = Int[]
end
# Store the indices of the irreducible secondary invariants in
# s_invars_cache.invars .
is_invars = Vector{Int}()
C = PowerProductCache(R, p_invars)
for d in 1:maxdeg
Md = generators_for_given_degree!(C, s_invars, d, false)[1]
# We have to find invariants of degree d which are not in the linear span of Md.
# We could call iterate_basis(RG, d) and reduce any element by the basis matrix
# of Md, but we can do a little bit better.
# Build the basis matrix of Md compatible with Bd
# We need to reverse the columns of this matrix, see below.
Bd = iterate_basis_linear_algebra(RG, d)
ncB1 = length(Bd.monomials_collected) + 1
mons_to_cols = Dict{Vector{Int},Int}(
first(AbstractAlgebra.exponent_vectors(forget_grading(Bd.monomials_collected[i]))) =>
ncB1 - i for i in 1:length(Bd.monomials_collected)
)
B = BasisOfPolynomials(R, Md, mons_to_cols)
# Do a slight detour and first try to build invariants as products of ones
# of smaller degree. This is no speed-up (it's in fact more work), but this
# way we have a set of irreducible secondary invariants of a much smaller
# cardinality.
# Use Kin07, Lemma 2: We do not need to build all power products of lower
# degree secondary invariants, but only products of the form i*s, where
# i is an irreducible secondary invariant of degree < d and s a secondary
# invariant of degree d - deg(i).
products = Set{elem_type(R)}()
for i in 1:length(is_invars)
f = forget_grading(s_invars_cache.invars[is_invars[i]])
@assert total_degree(f) < d
dd = d - total_degree(f)
for j in s_invars_sorted[dd]
g = forget_grading(s_invars_cache.invars[j])
lp = length(products)
fg = f * g
push!(products, fg)
if lp == length(products)
# We already constructed this product from other factors.
continue
end
if add_to_basis!(B, fg)
# fg is a product of monic polynomials, so monic itself
exp = copy(s_invars_cache.sec_in_irred[j])
exp[i] += 1
add_invariant!(s_invars_cache, Rgraded(fg), false, exp)
push!(s_invars_sorted[total_degree(fg)], length(s_invars_cache.invars))
push!(s_invars, fg)
end
end
end
# Now look for "new" invariants in this degree (the irreducible ones)
B = B.M
N = Bd.kernel
# Now find all columns of N which are not in the span of B.
# (The rows of B must span a subspace of the columns of N.)
# B is in upper-right reduced row echelon form, N in upper-right reduced
# column echelon form and column i of B corresponds to row nrows(N) - i + 1
# of N in terms of basis elements since we reversed the columns of B.
# We iterate N from the bottom right corner and B from the top left.
c = ncols(N)
b = 1
for r in nrows(N):-1:1
if c < 1
break
end
if iszero(N[r, c])
continue
end
# N[r, c] is a pivot of N
if b <= nrows(B)
k = searchsortedfirst(B.rows[b].pos, ncB1 - r)
if k <= length(B.rows[b].pos) && B.rows[b].pos[k] == ncB1 - r
# B has also has a pivot at the corresponding position, so we can skip
# this column of N.
c -= 1
b += 1
continue
end
end
f = R()
for j in 1:nrows(N)
if iszero(N[j, c])
continue
end
f += N[j, c] * forget_grading(Bd.monomials_collected[j])
end
# Cancelling the leading coefficient is not mathematically necessary and
# should be done with the ordering that is used for the printing
f = inv(AbstractAlgebra.leading_coefficient(f)) * f
push!(s_invars, f)
add_invariant!(
s_invars_cache, Rgraded(f), true, push!(zeros(Int, length(is_invars)), 1)
)
push!(s_invars_sorted[total_degree(f)], length(s_invars_cache.invars))
push!(is_invars, length(s_invars_cache.invars))
c -= 1
end
end
return s_invars_cache
end
################################################################################
#
# Non modular case
#
################################################################################
# DK15, Algorithm 3.7.2 and Kin07, Section 4 "Improved new algorithm"
function secondary_invariants_nonmodular(RG::FinGroupInvarRing)
@assert !is_modular(RG)
Rext = polynomial_ring(RG)
Rgraded = _internal_polynomial_ring(RG)
R = forget_grading(Rgraded)
p_invars = [_cast_in_internal_poly_ring(RG, f) for f in primary_invariants(RG)]
I = ideal_of_primary_invariants(RG)
LI = leading_ideal(I; ordering=default_ordering(base_ring(I)))
gensLI = [_cast_in_internal_poly_ring(RG, f) for f in gens(LI)]
h = reduce_hilbert_series_by_primary_degrees(RG)
K = coefficient_ring(R)
s_invars_cache = SecondaryInvarsCache{elem_type(Rgraded)}()
add_invariant!(s_invars_cache, one(Rgraded), false, Int[])
# Store the secondary invariants sorted by their total degree.
# We only store the indices in s_invars_cache.invars.
s_invars_sorted = Vector{Vector{Int}}(undef, degree(h))
for d in 1:degree(h)
s_invars_sorted[d] = Int[]
end
# Store the indices of the irreducible secondary invariants in
# s_invars_cache.invars .
is_invars = Vector{Int}()
# The Groebner basis should already be cached
gbI = [
forget_grading(_cast_in_internal_poly_ring(RG, f)) for
f in groebner_basis(I; ordering=degrevlex(Rext))
]
for d in 1:degree(h)
k = coeff(h, d) # number of invariants we need in degree d
if iszero(k)
continue
end
invars_found = 0
gb = copy(gbI)
# Try to build as many invariants as possible as power products of lower
# degree ones.
# Use Kin07, Lemma 2: We do not need to build all power products of lower
# degree secondary invariants, but only products of the form i*s, where
# i is an irreducible secondary invariant of degree < d and s a secondary
# invariant of degree d - deg(i).
products = Set{elem_type(R)}()
for i in 1:length(is_invars)
f = forget_grading(s_invars_cache.invars[is_invars[i]])
@assert total_degree(f) < d
dd = d - total_degree(f)
for j in s_invars_sorted[dd]
g = forget_grading(s_invars_cache.invars[j])
lp = length(products)
fg = f * g
push!(products, fg)
if lp == length(products)
# We already constructed this product from other factors.
continue
end
# DK15 propose to check containment via linear algebra; this approach
# from Kin07 using d-truncated Groebner bases appears to be faster.
_, r = divrem(fg, gb) # via degrevlex
if !is_zero(r)
# fg is a product of monic polynomials, so monic itself
exp = copy(s_invars_cache.sec_in_irred[j])
exp[i] += 1
add_invariant!(s_invars_cache, Rgraded(fg), false, exp)
invars_found += 1
push!(s_invars_sorted[total_degree(fg)], length(s_invars_cache.invars))
push!(gb, r)
invars_found == k && break
end
end
invars_found == k && break
end
invars_found == k && continue
# We have to find more invariants of this degree not coming from power products
# of smaller degree ones.
mons = monomials_of_degree(Rgraded, d)
for m in mons
# Can exclude some monomials, see DK15, Remark 3.7.3 (b)
skip = false
for g in gensLI
if mod(forget_grading(m), forget_grading(g)) == 0
skip = true
break
end
end
skip && continue
f = forget_grading(
_cast_in_internal_poly_ring(
RG, reynolds_operator(RG, _cast_in_external_poly_ring(RG, m))
),
)
if iszero(f)
continue
end
_, r = divrem(f, gb) # via degrevlex
if !is_zero(r)
f = inv(AbstractAlgebra.leading_coefficient(f)) * f
add_invariant!(
s_invars_cache, Rgraded(f), true, push!(zeros(Int, length(is_invars)), 1)
)
push!(s_invars_sorted[total_degree(f)], length(s_invars_cache.invars))
push!(is_invars, length(s_invars_cache.invars))
push!(gb, r)
invars_found += 1
invars_found == k && break
end
end
end
if Rext !== Rgraded
ext_cache = SecondaryInvarsCache{elem_type(Rext)}()
ext = [_cast_in_external_poly_ring(RG, f) for f in s_invars_cache.invars]
# Cancelling the leading coefficient is not mathematically necessary and
# should be done with the ordering that is used for the printing
ext_cache.invars = [inv(AbstractAlgebra.leading_coefficient(f)) * f for f in ext]
ext_cache.is_irreducible = s_invars_cache.is_irreducible
ext_cache.sec_in_irred = s_invars_cache.sec_in_irred
s_invars_cache = ext_cache
end
return s_invars_cache
end
################################################################################
#
# User functions
#
################################################################################
function _secondary_invariants(IR::FinGroupInvarRing)
if isdefined(IR, :secondary)
return nothing
end
if is_modular(IR)
IR.secondary = secondary_invariants_modular(IR)
else
IR.secondary = secondary_invariants_nonmodular(IR)
end
return nothing
end
@doc raw"""
secondary_invariants(IR::FinGroupInvarRing)
Return a system of secondary invariants for `IR` as a `Vector` sorted by
increasing degree. The result is cached, so calling this function again
with argument `IR` will be fast and give the same result.
Note that the secondary invariants are defined with respect to the currently
cached system of primary invariants for `IR` (if no system of primary invariants
for `IR` is cached, such a system is computed and cached first).
# Implemented Algorithms
For the non-modular case, the function relies on Algorithm 3.7.2 in [DK15](@cite),
enhanced by ideas from [Kin07](@cite). In the modular case, Algorithm 3.7.5 in
[DK15](@cite) is used.
# Examples
```jldoctest
julia> K, a = cyclotomic_field(3, "a");
julia> M1 = matrix(K, [0 0 1; 1 0 0; 0 1 0]);
julia> M2 = matrix(K, [1 0 0; 0 a 0; 0 0 -a-1]);
julia> G = matrix_group(M1, M2);
julia> IR = invariant_ring(G);
julia> secondary_invariants(IR)
2-element Vector{MPolyDecRingElem{AbsSimpleNumFieldElem, AbstractAlgebra.Generic.MPoly{AbsSimpleNumFieldElem}}}:
1
x[1]^3*x[2]^6 + x[1]^6*x[3]^3 + x[2]^3*x[3]^6
```
"""
function secondary_invariants(IR::FinGroupInvarRing)
_secondary_invariants(IR)
return copy(IR.secondary.invars)
end
@doc raw"""
irreducible_secondary_invariants(IR::FinGroupInvarRing)
Return a system of irreducible secondary invariants for `IR` as a `Vector` sorted
by increasing degree. The result is cached, so calling this function again will
be fast and give the same result.
Here, a secondary invariant is called irreducible, if it cannot be written as a
polynomial expression in the primary invariants and the other secondary
invariants.
Note that the secondary invariants and hence the irreducible secondary invariants
are defined with respect to the currently cached system of primary invariants for
`IR` (if no system of primary invariants for `IR` is cached, such a system is
computed and cached first).
# Examples
```jldoctest
julia> M = matrix(QQ, [0 -1 0 0 0; 1 -1 0 0 0; 0 0 0 0 1; 0 0 1 0 0; 0 0 0 1 0]);
julia> G = matrix_group(M);
julia> IR = invariant_ring(G);
julia> secondary_invariants(IR)
12-element Vector{MPolyDecRingElem{QQFieldElem, QQMPolyRingElem}}:
1
x[1]*x[3] - x[2]*x[3] + x[2]*x[4] - x[1]*x[5]
x[3]^2 + x[4]^2 + x[5]^2
x[1]^3 - 3*x[1]*x[2]^2 + x[2]^3
x[1]^2*x[3] - x[1]*x[2]*x[3] - x[1]*x[2]*x[4] + x[2]^2*x[4] + x[1]*x[2]*x[5]
x[1]*x[3]^2 - x[2]*x[3]^2 + x[2]*x[4]^2 - x[1]*x[5]^2
x[1]^2*x[3] + x[1]^2*x[4] - 2*x[1]*x[2]*x[4] + x[2]^2*x[4] + x[2]^2*x[5]
x[1]*x[3]*x[4] - x[2]*x[3]*x[4] - x[1]*x[3]*x[5] + x[2]*x[4]*x[5]
x[3]*x[4]^2 + x[3]^2*x[5] + x[4]*x[5]^2
x[1]*x[3]^3 - x[2]*x[3]^3 + x[2]*x[3]^2*x[4] + x[1]*x[3]*x[4]^2 - x[2]*x[3]*x[4]^2 + x[2]*x[4]^3 - x[1]*x[3]^2*x[5] - x[1]*x[4]^2*x[5] + x[1]*x[3]*x[5]^2 - x[2]*x[3]*x[5]^2 + x[2]*x[4]*x[5]^2 - x[1]*x[5]^3
x[3]^4 + 2*x[3]^2*x[4]^2 + x[4]^4 + 2*x[3]^2*x[5]^2 + 2*x[4]^2*x[5]^2 + x[5]^4
x[1]*x[3]^5 - x[2]*x[3]^5 + x[2]*x[3]^4*x[4] + 2*x[1]*x[3]^3*x[4]^2 - 2*x[2]*x[3]^3*x[4]^2 + 2*x[2]*x[3]^2*x[4]^3 + x[1]*x[3]*x[4]^4 - x[2]*x[3]*x[4]^4 + x[2]*x[4]^5 - x[1]*x[3]^4*x[5] - 2*x[1]*x[3]^2*x[4]^2*x[5] - x[1]*x[4]^4*x[5] + 2*x[1]*x[3]^3*x[5]^2 - 2*x[2]*x[3]^3*x[5]^2 + 2*x[2]*x[3]^2*x[4]*x[5]^2 + 2*x[1]*x[3]*x[4]^2*x[5]^2 - 2*x[2]*x[3]*x[4]^2*x[5]^2 + 2*x[2]*x[4]^3*x[5]^2 - 2*x[1]*x[3]^2*x[5]^3 - 2*x[1]*x[4]^2*x[5]^3 + x[1]*x[3]*x[5]^4 - x[2]*x[3]*x[5]^4 + x[2]*x[4]*x[5]^4 - x[1]*x[5]^5
julia> irreducible_secondary_invariants(IR)
8-element Vector{MPolyDecRingElem{QQFieldElem, QQMPolyRingElem}}:
x[1]*x[3] - x[2]*x[3] + x[2]*x[4] - x[1]*x[5]
x[3]^2 + x[4]^2 + x[5]^2
x[1]^3 - 3*x[1]*x[2]^2 + x[2]^3
x[1]^2*x[3] - x[1]*x[2]*x[3] - x[1]*x[2]*x[4] + x[2]^2*x[4] + x[1]*x[2]*x[5]
x[1]*x[3]^2 - x[2]*x[3]^2 + x[2]*x[4]^2 - x[1]*x[5]^2
x[1]^2*x[3] + x[1]^2*x[4] - 2*x[1]*x[2]*x[4] + x[2]^2*x[4] + x[2]^2*x[5]
x[1]*x[3]*x[4] - x[2]*x[3]*x[4] - x[1]*x[3]*x[5] + x[2]*x[4]*x[5]
x[3]*x[4]^2 + x[3]^2*x[5] + x[4]*x[5]^2
```
"""
function irreducible_secondary_invariants(IR::FinGroupInvarRing)
_secondary_invariants(IR)
is_invars = elem_type(polynomial_ring(IR))[]
for i in 1:length(IR.secondary.invars)
IR.secondary.is_irreducible[i] ? push!(is_invars, IR.secondary.invars[i]) : nothing
end
return is_invars
end
################################################################################
#
# Semi-invariants / relative invariants
#
################################################################################
# Gat96, Algorithm 3.16 and DK15, Algorithm 3.7.2
@doc raw"""
semi_invariants(IR::FinGroupInvarRing, chi::GAPGroupClassFunction)
relative_invariants(IR::FinGroupInvarRing, chi::GAPGroupClassFunction)
Given an irreducible character `chi` of the underlying group, return a system of
semi-invariants (or relative invariants) with respect to `chi`.
By this, we mean a set of free generators of the isotypic component of the of the
polynomial ring with respect to `chi` as a module over the algebra generated
by primary invariants for `IR`.
See also [Gat96](@cite) and [Sta79](@cite).
!!! note
If `coefficient_ring(IR)` does not contain all character values of `chi`, an error is raised.
This function is so far only implemented in the case of characteristic zero.
# Examples
```jldoctest
julia> S2 = symmetric_group(2);
julia> RS2 = invariant_ring(S2);
julia> F = abelian_closure(QQ)[1];
julia> chi = Oscar.class_function(S2, [ F(sign(representative(c))) for c in conjugacy_classes(S2) ])
class_function(character table of S2, QQAbElem{AbsSimpleNumFieldElem}[1, -1])
julia> semi_invariants(RS2, chi)
1-element Vector{MPolyDecRingElem{QQFieldElem, QQMPolyRingElem}}:
x[1] - x[2]
```
"""
function semi_invariants(RG::FinGroupInvarRing, chi::GAPGroupClassFunction)
@assert is_zero(characteristic(coefficient_ring(RG)))
@assert is_irreducible(chi)
p_invars = primary_invariants(RG)
I = ideal_of_primary_invariants(RG)
LI = leading_ideal(I; ordering=default_ordering(base_ring(I)))
h = reduce_hilbert_series_by_primary_degrees(RG, chi)
Rgraded = polynomial_ring(RG)
R = forget_grading(Rgraded)
B = BasisOfPolynomials(R, elem_type(R)[])
semi_invars = elem_type(Rgraded)[]
rey_op = reynolds_operator(RG, chi)
for d in 0:degree(h)
k = coeff(h, d) # number of invariants we need in degree d
if iszero(k)
continue
end
invars_found = 0
mons = monomials_of_degree(Rgraded, d)
for m in mons
# Can exclude some monomials, see DK15, Remark 3.7.3 (b)
skip = false
for g in gens(LI)
if mod(forget_grading(m), forget_grading(g)) == 0
skip = true
break
end
end
skip && continue
f = forget_grading(rey_op(m))
if iszero(f)
continue
end
nf = forget_grading(normal_form(f, I))
if add_to_basis!(B, nf)
# Cancelling the leading coefficient is not mathematically necessary and
# should be done with the ordering that is used for the printing
f = inv(AbstractAlgebra.leading_coefficient(f)) * f
push!(semi_invars, Rgraded(f))
invars_found += 1
invars_found == k && break
end
end
end
return semi_invars
end
relative_invariants(RG::FinGroupInvarRing, chi::GAPGroupClassFunction) =
semi_invariants(RG, chi)