-
Notifications
You must be signed in to change notification settings - Fork 113
/
LieSubalgebra.jl
310 lines (261 loc) · 9.02 KB
/
LieSubalgebra.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
@attributes mutable struct LieSubalgebra{C<:FieldElem,LieT<:LieAlgebraElem{C}}
base_lie_algebra::LieAlgebra{C}
gens::Vector{LieT}
basis_elems::Vector{LieT}
basis_matrix::MatElem{C}
function LieSubalgebra{C,LieT}(
L::LieAlgebra{C}, gens::Vector{LieT}; is_basis::Bool=false
) where {C<:FieldElem,LieT<:LieAlgebraElem{C}}
@req all(g -> parent(g) === L, gens) "Parent mismatch."
L::parent_type(LieT)
if is_basis
basis_elems = gens
basis_matrix = if length(gens) == 0
matrix(coefficient_ring(L), 0, dim(L), C[])
else
matrix(coefficient_ring(L), [coefficients(g) for g in gens])
end
return new{C,LieT}(L, gens, basis_elems, basis_matrix)
else
basis_matrix = matrix(coefficient_ring(L), 0, dim(L), C[])
gens = unique(g for g in gens if !iszero(g))
left = copy(gens)
while !isempty(left)
g = pop!(left)
can_solve(basis_matrix, _matrix(g); side=:left) && continue
for i in 1:nrows(basis_matrix)
push!(left, g * L(basis_matrix[i, :]))
end
basis_matrix = vcat(basis_matrix, _matrix(g))
rank = rref!(basis_matrix)
basis_matrix = basis_matrix[1:rank, :]
end
basis_elems = [L(basis_matrix[i, :]) for i in 1:nrows(basis_matrix)]
return new{C,LieT}(L, gens, basis_elems, basis_matrix)
end
end
function LieSubalgebra{C,LieT}(
L::LieAlgebra{C}, gens::Vector; kwargs...
) where {C<:FieldElem,LieT<:LieAlgebraElem{C}}
return LieSubalgebra{C,LieT}(L, Vector{LieT}(map(L, gens)); kwargs...)
end
end
###############################################################################
#
# Basic manipulation
#
###############################################################################
base_lie_algebra(S::LieSubalgebra{C,LieT}) where {C<:FieldElem,LieT<:LieAlgebraElem{C}} =
S.base_lie_algebra::parent_type(LieT)
function gens(S::LieSubalgebra)
return S.gens
end
function gen(S::LieSubalgebra, i::Int)
return S.gens[i]
end
function number_of_generators(S::LieSubalgebra)
return length(gens(S))
end
function basis_matrix(S::LieSubalgebra{C,LieT}) where {C<:FieldElem,LieT<:LieAlgebraElem{C}}
return S.basis_matrix::dense_matrix_type(C)
end
@doc raw"""
basis(S::LieSubalgebra{C}) -> Vector{LieAlgebraElem{C}}
Return a basis of the Lie subalgebra `S`.
"""
function basis(S::LieSubalgebra)
return S.basis_elems
end
@doc raw"""
basis(S::LieSubalgebra{C}, i::Int) -> LieAlgebraElem{C}
Return the `i`-th basis element of the Lie subalgebra `S`.
"""
function basis(S::LieSubalgebra, i::Int)
return S.basis_elems[i]
end
@doc raw"""
dim(S::LieSubalgebra) -> Int
Return the dimension of the Lie subalgebra `S`.
"""
dim(S::LieSubalgebra) = length(basis(S))
###############################################################################
#
# String I/O
#
###############################################################################
function Base.show(io::IO, mime::MIME"text/plain", S::LieSubalgebra)
@show_name(io, S)
@show_special(io, mime, S)
io = pretty(io)
println(io, LowercaseOff(), "Lie subalgebra")
println(io, Indent(), "of dimension $(dim(S))", Dedent())
if dim(S) != ngens(S)
println(io, Indent(), "with $(ItemQuantity(ngens(S), "generator"))", Dedent())
end
print(io, "of ")
print(io, Lowercase(), base_lie_algebra(S))
end
function Base.show(io::IO, S::LieSubalgebra)
@show_name(io, S)
@show_special(io, S)
io = pretty(io)
if is_terse(io)
print(io, LowercaseOff(), "Lie subalgebra")
else
print(io, LowercaseOff(), "Lie subalgebra of dimension $(dim(S)) of ", Lowercase())
print(terse(io), base_lie_algebra(S))
end
end
###############################################################################
#
# Comparisons
#
###############################################################################
function Base.issubset(
S1::LieSubalgebra{C,LieT}, S2::LieSubalgebra{C,LieT}
) where {C<:FieldElem,LieT<:LieAlgebraElem{C}}
@req base_lie_algebra(S1) === base_lie_algebra(S2) "Incompatible Lie algebras."
return all(in(S2), gens(S1))
end
function Base.:(==)(
S1::LieSubalgebra{C,LieT}, S2::LieSubalgebra{C,LieT}
) where {C<:FieldElem,LieT<:LieAlgebraElem{C}}
base_lie_algebra(S1) === base_lie_algebra(S2) || return false
gens(S1) == gens(S2) && return true
return issubset(S1, S2) && issubset(S2, S1)
end
function Base.hash(S::LieSubalgebra, h::UInt)
b = 0x712b12e671184d1a % UInt
h = hash(base_lie_algebra(S), h)
h = hash(rref(basis_matrix(S)), h)
return xor(h, b)
end
###############################################################################
#
# Subalgebra membership
#
###############################################################################
@doc raw"""
in(x::LieAlgebraElem, S::LieSubalgebra) -> Bool
Return `true` if `x` is in the Lie subalgebra `S`, `false` otherwise.
"""
function Base.in(x::LieAlgebraElem, S::LieSubalgebra)
return can_solve(basis_matrix(S), _matrix(x); side=:left)
end
###############################################################################
#
# Constructions
#
###############################################################################
@doc raw"""
bracket(S1::LieSubalgebra, S2::LieSubalgebra) -> LieAlgebraIdeal
Return $[S_1, S_2]$.
"""
function bracket(
S1::LieSubalgebra{C,LieT}, S2::LieSubalgebra{C,LieT}
) where {C<:FieldElem,LieT<:LieAlgebraElem{C}}
@req base_lie_algebra(S1) === base_lie_algebra(S2) "Incompatible Lie algebras."
return ideal(base_lie_algebra(S1), [x * y for x in gens(S1) for y in gens(S2)])
end
function bracket(
L::LieAlgebra{C}, S::LieSubalgebra{C,LieT}
) where {C<:FieldElem,LieT<:LieAlgebraElem{C}}
@req L === base_lie_algebra(S) "Incompatible Lie algebras."
return bracket(ideal(L), S)
end
###############################################################################
#
# Important ideals and subalgebras
#
###############################################################################
@doc raw"""
normalizer(L::LieAlgebra, S::LieSubalgebra) -> LieSubalgebra
Return the normalizer of `S` in `L`, i.e. $\{x \in L \mid [x, S] \subseteq S\}$.
"""
function normalizer(L::LieAlgebra, S::LieSubalgebra)
@req base_lie_algebra(S) === L "Incompatible Lie algebras."
mat = zero_matrix(coefficient_ring(L), dim(L) + dim(S)^2, dim(L) * dim(S))
for (i, bi) in enumerate(basis(L))
for (j, sj) in enumerate(basis(S))
mat[i, ((j - 1) * dim(L) + 1):(j * dim(L))] = _matrix(bracket(bi, sj))
end
end
for i in 1:dim(S)
mat[(dim(L) + (i - 1) * dim(S) + 1):(dim(L) + i * dim(S)), ((i - 1) * dim(L) + 1):(i * dim(L))] = basis_matrix(
S
)
end
sol = kernel(mat; side=:left)
sol_dim = nrows(sol)
sol = sol[:, 1:dim(L)]
c_dim, c_basis = rref(sol)
return sub(L, [L(c_basis[i, :]) for i in 1:c_dim]; is_basis=true)
end
function normalizer(S::LieSubalgebra)
return normalizer(base_lie_algebra(S), S)
end
@doc raw"""
centralizer(L::LieAlgebra, S::LieSubalgebra) -> LieSubalgebra
Return the centralizer of `S` in `L`, i.e. $\{x \in L \mid [x, S] = 0\}$.
"""
function centralizer(L::LieAlgebra, S::LieSubalgebra)
return centralizer(L, basis(S))
end
function centralizer(S::LieSubalgebra)
return centralizer(base_lie_algebra(S), basis(S))
end
###############################################################################
#
# Properties
#
###############################################################################
@doc raw"""
is_self_normalizing(S::LieSubalgebra) -> Bool
Return `true` if `S` is self-normalizing, i.e. if its normalizer is `S`.
"""
function is_self_normalizing(S::LieSubalgebra)
return normalizer(base_lie_algebra(S), S) == S
end
###############################################################################
#
# Conversion
#
###############################################################################
@doc raw"""
lie_algebra(S::LieSubalgebra) -> LieAlgebra
Return `S` as a Lie algebra `LS`, together with an embedding `LS -> L`,
where `L` is the Lie algebra where `S` lives in.
"""
function lie_algebra(S::LieSubalgebra)
LS = lie_algebra(basis(S))
L = base_lie_algebra(S)
emb = hom(LS, L, basis(S))
return LS, emb
end
###############################################################################
#
# Constructor
#
###############################################################################
@doc raw"""
sub(L::LieAlgebra, gens::Vector{LieAlgebraElem}; is_basis::Bool=false) -> LieSubalgebra
Return the smallest Lie subalgebra of `L` containing `gens`.
If `is_basis` is `true`, then `gens` is assumed to be a basis of the subalgebra.
"""
function sub(L::LieAlgebra, gens::Vector; is_basis::Bool=false)
return LieSubalgebra{elem_type(coefficient_ring(L)),elem_type(L)}(L, gens; is_basis)
end
@doc raw"""
sub(L::LieAlgebra, gen::LieAlgebraElem) -> LieSubalgebra
Return the smallest Lie subalgebra of `L` containing `gen`.
"""
function sub(L::LieAlgebra{C}, gen::LieAlgebraElem{C}) where {C<:FieldElem}
return sub(L, [gen])
end
@doc raw"""
sub(L::LieAlgebra) -> LieSubalgebra
Return `L` as a Lie subalgebra of itself.
"""
function sub(L::LieAlgebra)
return sub(L, basis(L); is_basis=true)
end