Skip to content

Commit

Permalink
Add ideal and subalgebra tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed Jul 20, 2023
1 parent 86ae0b9 commit c5615e9
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 6 deletions.
8 changes: 8 additions & 0 deletions experimental/LieAlgebras/src/LieAlgebraIdeal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ function normalizer(L::LieAlgebra, I::LieAlgebraIdeal)
return sub(L)
end

function normalizer(I::LieAlgebraIdeal)
return sub(base_lie_algebra(I))
end

@doc raw"""
centralizer(L::LieAlgebra, I::LieAlgebraIdeal) -> LieSubalgebra
Expand All @@ -215,6 +219,10 @@ function centralizer(L::LieAlgebra, I::LieAlgebraIdeal)
return centralizer(L, basis(I))
end

function centralizer(I::LieAlgebraIdeal)
return centralizer(base_lie_algebra(I), basis(I))
end

###############################################################################
#
# Conversion
Expand Down
13 changes: 8 additions & 5 deletions experimental/LieAlgebras/src/LieSubalgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -208,17 +208,16 @@ function normalizer(L::LieAlgebra, S::LieSubalgebra)
S
)
end
show(stdout, MIME"text/plain"(), mat)
println("")
sol_dim, sol = left_kernel(mat)
sol = sol[:, 1:dim(L)]
c_dim, c_basis = rref(sol)
println(c_dim)
show(stdout, MIME"text/plain"(), c_basis)
println("")
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
Expand All @@ -228,6 +227,10 @@ 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
Expand Down
4 changes: 3 additions & 1 deletion experimental/LieAlgebras/src/Util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ function coefficient_vector(
for i in 1:nr, j in 1:nc
rhs[(i - 1) * nc + j, 1] = M[i, j]
end
return transpose(solve(lgs, rhs))
fl, sol = can_solve_with_solution(lgs, rhs)
@assert fl
return transpose(sol)
end
41 changes: 41 additions & 0 deletions experimental/LieAlgebras/test/LieAlgebra-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,45 @@ include("LinearLieAlgebra-test.jl")
y = L(rand(-10:10, dim(L)))
@test L_to_U(x) * L_to_U(y) - L_to_U(y) * L_to_U(x) == L_to_U(x * y)
end

@testset "Hum72, Exercise 2.2" begin
@testset for n in 2:4, F in [QQ, GF(2)]
L = general_linear_lie_algebra(F, n)

derL = derived_algebra(L) # == sl_n

@test dim(derL) == dim(L) - 1
for b in basis(derL)
@test tr(matrix_repr(b)) == 0
end
end
end

@testset "Hum72, Exercise 2.3" begin
@testset for n in 2:4, F in [QQ, GF(2), GF(3)]
L = general_linear_lie_algebra(F, n)
cen = center(L) # == scalar matrices
@test dim(cen) == 1
b = matrix_repr(basis(cen, 1))
@test divexact(b, b[1, 1]) == identity_matrix(F, n)

L = special_linear_lie_algebra(F, n)
cen = center(L)
if is_divisible_by(n, characteristic(F))
@test dim(cen) == 1
b = matrix_repr(basis(cen, 1))
@test divexact(b, b[1, 1]) == identity_matrix(F, n)
else
@test dim(cen) == 0
end
end
end

@testset "Hum72, Exercise 2.6" begin
@testset for F in [QQ, GF(2), GF(3)]
L = special_linear_lie_algebra(F, 3)

@test_broken is_simple(L) == (characteristic(F) != 3)
end
end
end
60 changes: 60 additions & 0 deletions experimental/LieAlgebras/test/LieAlgebraIdeal-test.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
@testset "LieAlgebras.LieAlgebraIdeal" begin
@testset "Constructor and basic properties" begin
let
L = general_linear_lie_algebra(QQ, 3)
b = lie_algebra(
sub(
L, [basis(L, 1), basis(L, 2), basis(L, 3), basis(L, 5), basis(L, 6), basis(L, 9)]
),
)
n = ideal(b, [basis(b, 2), basis(b, 3), basis(b, 5)])

let L = b, I = n
@test I == ideal(L, basis(I))
@test base_lie_algebra(I) == L
@test length(gens(I)) == ngens(I)
@test length(basis(I)) == dim(I)
@test all(in(I), gens(I))
@test all(in(I), basis(I))
end

@test dim(b) == 6
@test dim(n) == 3
end

let # Example where ideal basis is only found after two steps
sc = zeros(QQ, 4, 4, 4)
sc[1, 2, 3] = 1
sc[2, 1, 3] = -1
sc[1, 3, 4] = 1
sc[3, 1, 4] = -1
L = lie_algebra(QQ, sc, ["a", "b", "c", "d"])
a, b, c, d = basis(L)

let I = ideal(L, b)
@test I == ideal(L, [b])
@test dim(I) == 3
@test ngens(I) == 1

@test I == ideal(L, basis(I))
@test base_lie_algebra(I) == L
@test length(gens(I)) == ngens(I)
@test length(basis(I)) == dim(I)
@test all(in(I), gens(I))
@test all(in(I), basis(I))
end

let I = ideal(L, [a + b + c + d])
@test dim(I) == 3
@test ngens(I) == 1

@test I == ideal(L, basis(I))
@test base_lie_algebra(I) == L
@test length(gens(I)) == ngens(I)
@test length(basis(I)) == dim(I)
@test all(in(I), gens(I))
@test all(in(I), basis(I))
end
end
end
end
38 changes: 38 additions & 0 deletions experimental/LieAlgebras/test/LieSubalgebra-test.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@testset "LieAlgebras.LieSubalgebra" begin
@testset "Constructor and basic properties" begin
let
L = general_linear_lie_algebra(QQ, 3)
b = sub(
L, [basis(L, 1), basis(L, 2), basis(L, 3), basis(L, 5), basis(L, 6), basis(L, 9)]
)

n = sub(L, [basis(b, 2), basis(b, 3), basis(b, 5)])

for S in [b, n]
@test L == base_lie_algebra(S)
@test length(gens(S)) == ngens(S)
@test length(basis(S)) == dim(S)
@test all(in(S), gens(S))
@test all(in(S), basis(S))
end

@test dim(b) == 6
@test dim(n) == 3
end
end

@testset "Hum72, Exercise 2.3" begin
@testset for n in 2:4, F in [QQ, GF(2)]
L = general_linear_lie_algebra(F, n)

b = sub(L, [basis(L, (i - 1) * n + j) for i in 1:n, j in 1:n if i <= j])
d = sub(L, [basis(L, (i - 1) * n + j) for i in 1:n, j in 1:n if i == j])
n = sub(L, [basis(L, (i - 1) * n + j) for i in 1:n, j in 1:n if i < j])

@test is_self_normalizing(b)
@test is_self_normalizing(d)
@test !is_self_normalizing(n)
@test normalizer(n) == b
end
end
end
2 changes: 2 additions & 0 deletions experimental/LieAlgebras/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ include("Combinatorics-test.jl")
include("iso_oscar_gap-test.jl")
include("iso_gap_oscar-test.jl")
include("LieAlgebra-test.jl")
include("LieSubalgebra-test.jl")
include("LieAlgebraIdeal-test.jl")
include("LieAlgebraModule-test.jl")

0 comments on commit c5615e9

Please sign in to comment.