-
Notifications
You must be signed in to change notification settings - Fork 113
/
LieAlgebraHom.jl
348 lines (289 loc) · 10.5 KB
/
LieAlgebraHom.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
@attributes mutable struct LieAlgebraHom{T1<:LieAlgebra,T2<:LieAlgebra} <:
Map{T1,T2,Hecke.HeckeMap,LieAlgebraHom}
header::MapHeader{T1,T2}
matrix::MatElem
inverse_isomorphism::LieAlgebraHom{T2,T1}
function LieAlgebraHom(
L1::LieAlgebra, L2::LieAlgebra, imgs::Vector{<:LieAlgebraElem}; check::Bool=true
)
@req coefficient_ring(L1) === coefficient_ring(L2) "Coefficient rings must be the same" # for now at least
@req all(x -> parent(x) === L2, imgs) "Images must lie in the codomain"
@req length(imgs) == dim(L1) "Number of images must match dimension of domain"
mat = zero_matrix(coefficient_ring(L2), dim(L1), dim(L2))
for (i, img) in enumerate(imgs)
mat[i, :] = _matrix(img)
end
return LieAlgebraHom(L1, L2, mat; check)
end
function LieAlgebraHom(L1::LieAlgebra, L2::LieAlgebra, mat::MatElem; check::Bool=true)
@req coefficient_ring(L1) === coefficient_ring(L2) "Coefficient rings must be the same" # for now at least
@req size(mat) == (dim(L1), dim(L2)) "Matrix size must match dimensions of domain and codomain"
h = new{typeof(L1),typeof(L2)}()
h.matrix = mat::dense_matrix_type(coefficient_ring(L2))
h.header = MapHeader(L1, L2)
if check
@req is_welldefined(h) "Not a homomorphism"
end
return h
end
end
###############################################################################
#
# Basic properties
#
###############################################################################
@doc raw"""
matrix(h::LieAlgebraHom) -> MatElem
Return the transformation matrix of `h` w.r.t. the bases of the domain and codomain.
Note: The matrix operates on the coefficient vectors from the right.
"""
function matrix(h::LieAlgebraHom{<:LieAlgebra,<:LieAlgebra{C2}}) where {C2<:FieldElem}
return (h.matrix)::dense_matrix_type(C2)
end
@doc raw"""
is_welldefined(h::LieAlgebraHom) -> Bool
Return `true` if `h` is a well-defined homomorphism of Lie algebras.
This function is used internally when calling `hom` with `check=true`.
"""
function is_welldefined(h::LieAlgebraHom)
L1 = domain(h)
for x1 in basis(L1), x2 in basis(L1)
h(x1) * h(x2) == h(x1 * x2) || return false
end
return true
end
###############################################################################
#
# String I/O
#
###############################################################################
function Base.show(io::IO, mime::MIME"text/plain", h::LieAlgebraHom)
@show_name(io, h)
@show_special(io, mime, h)
io = pretty(io)
println(io, LowercaseOff(), "Lie algebra morphism")
print(io, Indent())
println(io, "from ", Lowercase(), domain(h))
print(io, "to ", Lowercase(), codomain(h))
print(io, Dedent())
end
function Base.show(io::IO, h::LieAlgebraHom)
@show_name(io, h)
@show_special(io, h)
io = pretty(io)
if is_terse(io)
print(io, LowercaseOff(), "Lie algebra morphism")
else
print(io, LowercaseOff(), "Lie algebra morphism: ")
print(io, Lowercase(), domain(h), " -> ", Lowercase(), codomain(h))
end
end
###############################################################################
#
# Comparison
#
###############################################################################
function Base.:(==)(h1::LieAlgebraHom, h2::LieAlgebraHom)
return domain(h1) === domain(h2) &&
codomain(h1) === codomain(h2) &&
matrix(h1) == matrix(h2)
end
function Base.hash(f::LieAlgebraHom, h::UInt)
b = 0xc023adc432e006be % UInt
h = hash(objectid(domain(f)), h)
h = hash(objectid(codomain(f)), h)
h = hash(matrix(f), h)
return xor(h, b)
end
###############################################################################
#
# Image and kernel
#
###############################################################################
@doc raw"""
image(h::LieAlgebraHom, x::LieAlgebraElem) -> LieAlgebraElem
Return the image of `x` under `h`.
"""
function image(h::LieAlgebraHom, x::LieAlgebraElem)
@req parent(x) === domain(h) "Domain mismatch"
return codomain(h)(_matrix(x) * matrix(h))
end
@doc raw"""
image(h::LieAlgebraHom) -> LieSubalgebra
Return the image of `h` as a Lie subalgebra of the codomain.
"""
function image(h::LieAlgebraHom)
return sub(codomain(h), [image(h, x) for x in basis(domain(h))])
end
@doc raw"""
image(h::LieAlgebraHom, I::LieAlgebraIdeal) -> LieSubalgebra
Return the image of `I` under `h` as a Lie subalgebra of the codomain.
"""
function image(h::LieAlgebraHom, I::LieAlgebraIdeal)
@req base_lie_algebra(I) === domain(h) "Domain mismatch"
return sub(codomain(h), [image(h, x) for x in basis(I)])
end
@doc raw"""
image(h::LieAlgebraHom, S::LieSubalgebra) -> LieSubalgebra
Return the image of `S` under `h` as a Lie subalgebra of the codomain.
"""
function image(h::LieAlgebraHom, S::LieSubalgebra)
@req base_lie_algebra(S) === domain(h) "Domain mismatch"
return sub(codomain(h), [image(h, x) for x in basis(S)])
end
@doc raw"""
kernel(h::LieAlgebraHom) -> LieAlgebraIdeal
Return the kernel of `h` as an ideal of the domain.
"""
function kernel(h::LieAlgebraHom)
ker_b = kernel(matrix(h); side=:left)
ker_dim = nrows(ker_b)
return ideal(domain(h), [domain(h)(ker_b[i, :]) for i in 1:ker_dim])
end
###############################################################################
#
# Map operations
#
###############################################################################
@doc raw"""
compose(f::LieAlgebraHom, g::LieAlgebraHom) -> LieAlgebraHom
Return the composition of `f` and `g`, i.e. the homomorphism `h` such that
`h(x) = g(f(x))` for all `x` in the domain of `f`.
The codomain of `f` must be identical to the domain of `g`.
"""
function compose(
f::LieAlgebraHom{T1,T2}, g::LieAlgebraHom{T2,T3}
) where {T1<:LieAlgebra,T2<:LieAlgebra,T3<:LieAlgebra}
@req codomain(f) === domain(g) "Composition: Maps are not compatible"
h = LieAlgebraHom(domain(f), codomain(g), matrix(f) * matrix(g); check=false)
if isdefined(f, :inverse_isomorphism) && isdefined(g, :inverse_isomorphism)
h.inverse_isomorphism = LieAlgebraHom(
codomain(g),
domain(f),
matrix(g.inverse_isomorphism) * matrix(f.inverse_isomorphism);
check=false,
)
h.inverse_isomorphism.inverse_isomorphism = h
end
return h
end
@doc raw"""
inv(h::LieAlgebraHom) -> LieAlgebraHom
Return the inverse of `h`.
Requires `h` to be an isomorphism.
"""
function inv(h::LieAlgebraHom)
@req is_isomorphism(h) "Homomorphism must be invertible"
return h.inverse_isomorphism
end
@doc raw"""
is_isomorphism(h::LieAlgebraHom) -> Bool
Return `true` if `h` is an isomorphism.
This function tries to invert the transformation matrix of `h` and caches the result.
The inverse isomorphism can be cheaply accessed via `inv(h)` after calling this function.
"""
@attr Bool function is_isomorphism(h::LieAlgebraHom)
isdefined(h, :inverse_isomorphism) && return true
fl, invmat = is_invertible_with_inverse(matrix(h))
fl || return false
h.inverse_isomorphism = LieAlgebraHom(codomain(h), domain(h), invmat; check=false)
h.inverse_isomorphism.inverse_isomorphism = h
return true
end
###############################################################################
#
# Constructor
#
###############################################################################
@doc raw"""
hom(L1::LieAlgebra, L2::LieAlgebra, imgs::Vector{<:LieAlgebraElem}; check::Bool=true) -> LieAlgebraHom
Construct the homomorphism from `L1` to `L2` by sending the `i`-th basis element of `L1`
to `imgs[i]` and extending linearly.
All elements of `imgs` must lie in `L2`.
By setting `check=false`, the linear map is not checked to be compatible with the Lie bracket.
# Examples
```jldoctest
julia> L1 = special_linear_lie_algebra(QQ, 2);
julia> L2 = special_linear_lie_algebra(QQ, 3);
julia> h = hom(L1, L2, [basis(L2, 1), basis(L2, 4), basis(L2, 7)]) # embed sl_2 into sl_3
Lie algebra morphism
from special linear Lie algebra of degree 2 over QQ
to special linear Lie algebra of degree 3 over QQ
julia> [(x, h(x)) for x in basis(L1)]
3-element Vector{Tuple{LinearLieAlgebraElem{QQFieldElem}, LinearLieAlgebraElem{QQFieldElem}}}:
(e_1_2, e_1_2)
(f_1_2, f_1_2)
(h_1, h_1)
```
"""
function hom(
L1::LieAlgebra{C}, L2::LieAlgebra{C}, imgs::Vector{<:LieAlgebraElem{C}}; check::Bool=true
) where {C<:FieldElem}
return LieAlgebraHom(L1, L2, imgs; check)
end
@doc raw"""
hom(L1::LieAlgebra, L2::LieAlgebra, mat::MatElem; check::Bool=true) -> LieAlgebraHom
Construct the homomorphism from `L1` to `L2` by acting with the matrix `mat`
from the right on the coefficient vector w.r.t. the basis of `L1`.
`mat` must be a matrix of size `dim(L1) \times dim(L2)` over `coefficient_ring(L2)`.
By setting `check=false`, the linear map is not checked to be compatible with the Lie bracket.
# Examples
```jldoctest
julia> L1 = special_linear_lie_algebra(QQ, 2);
julia> L2 = general_linear_lie_algebra(QQ, 2);
julia> h = hom(L1, L2, matrix(QQ, [0 1 0 0; 0 0 1 0; 1 0 0 -1]))
Lie algebra morphism
from special linear Lie algebra of degree 2 over QQ
to general linear Lie algebra of degree 2 over QQ
julia> [(x, h(x)) for x in basis(L1)]
3-element Vector{Tuple{LinearLieAlgebraElem{QQFieldElem}, LinearLieAlgebraElem{QQFieldElem}}}:
(e_1_2, x_1_2)
(f_1_2, x_2_1)
(h_1, x_1_1 - x_2_2)
```
"""
function hom(
L1::LieAlgebra{C}, L2::LieAlgebra{C}, mat::MatElem{C}; check::Bool=true
) where {C<:FieldElem}
return LieAlgebraHom(L1, L2, mat; check)
end
@doc raw"""
identity_map(L::LieAlgebra) -> LieAlgebraHom
Construct the identity map on `L`.
# Examples
```jldoctest
julia> L = special_linear_lie_algebra(QQ, 3)
Special linear Lie algebra of degree 3
of dimension 8
over rational field
julia> identity_map(L)
Lie algebra morphism
from special linear Lie algebra of degree 3 over QQ
to special linear Lie algebra of degree 3 over QQ
```
"""
function identity_map(L::LieAlgebra)
return hom(L, L, basis(L); check=false)
end
@doc raw"""
zero_map(L1::LieAlgebra, L2::LieAlgebra) -> LieAlgebraHom
zero_map(L::LieAlgebra) -> LieAlgebraHom
Construct the zero map from `L1` to `L2` or from `L` to `L`.
# Examples
```jldoctest
julia> L = special_linear_lie_algebra(QQ, 3)
Special linear Lie algebra of degree 3
of dimension 8
over rational field
julia> zero_map(L)
Lie algebra morphism
from special linear Lie algebra of degree 3 over QQ
to special linear Lie algebra of degree 3 over QQ
```
"""
function zero_map(L1::LieAlgebra{C}, L2::LieAlgebra{C}) where {C<:FieldElem}
return hom(L1, L2, zero_matrix(coefficient_ring(L2), dim(L1), dim(L2)); check=false)
end
function zero_map(L::LieAlgebra)
return zero_map(L, L)
end