From c5615e9d6dd07631e2aa3cab826b226727c783c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Fri, 14 Jul 2023 12:39:18 +0200 Subject: [PATCH] Add ideal and subalgebra tests --- .../LieAlgebras/src/LieAlgebraIdeal.jl | 8 +++ experimental/LieAlgebras/src/LieSubalgebra.jl | 13 ++-- experimental/LieAlgebras/src/Util.jl | 4 +- .../LieAlgebras/test/LieAlgebra-test.jl | 41 +++++++++++++ .../LieAlgebras/test/LieAlgebraIdeal-test.jl | 60 +++++++++++++++++++ .../LieAlgebras/test/LieSubalgebra-test.jl | 38 ++++++++++++ experimental/LieAlgebras/test/runtests.jl | 2 + 7 files changed, 160 insertions(+), 6 deletions(-) create mode 100644 experimental/LieAlgebras/test/LieAlgebraIdeal-test.jl create mode 100644 experimental/LieAlgebras/test/LieSubalgebra-test.jl diff --git a/experimental/LieAlgebras/src/LieAlgebraIdeal.jl b/experimental/LieAlgebras/src/LieAlgebraIdeal.jl index b0771d8861e9..dbb974a525b7 100644 --- a/experimental/LieAlgebras/src/LieAlgebraIdeal.jl +++ b/experimental/LieAlgebras/src/LieAlgebraIdeal.jl @@ -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 @@ -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 diff --git a/experimental/LieAlgebras/src/LieSubalgebra.jl b/experimental/LieAlgebras/src/LieSubalgebra.jl index de071df84ba4..373deed88641 100644 --- a/experimental/LieAlgebras/src/LieSubalgebra.jl +++ b/experimental/LieAlgebras/src/LieSubalgebra.jl @@ -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 @@ -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 diff --git a/experimental/LieAlgebras/src/Util.jl b/experimental/LieAlgebras/src/Util.jl index 80c00fc103c4..a542de2b0e21 100644 --- a/experimental/LieAlgebras/src/Util.jl +++ b/experimental/LieAlgebras/src/Util.jl @@ -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 diff --git a/experimental/LieAlgebras/test/LieAlgebra-test.jl b/experimental/LieAlgebras/test/LieAlgebra-test.jl index d24462ac2f9b..b7ade51292ad 100644 --- a/experimental/LieAlgebras/test/LieAlgebra-test.jl +++ b/experimental/LieAlgebras/test/LieAlgebra-test.jl @@ -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 diff --git a/experimental/LieAlgebras/test/LieAlgebraIdeal-test.jl b/experimental/LieAlgebras/test/LieAlgebraIdeal-test.jl new file mode 100644 index 000000000000..b7df10cd19ae --- /dev/null +++ b/experimental/LieAlgebras/test/LieAlgebraIdeal-test.jl @@ -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 diff --git a/experimental/LieAlgebras/test/LieSubalgebra-test.jl b/experimental/LieAlgebras/test/LieSubalgebra-test.jl new file mode 100644 index 000000000000..c915514a954f --- /dev/null +++ b/experimental/LieAlgebras/test/LieSubalgebra-test.jl @@ -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 diff --git a/experimental/LieAlgebras/test/runtests.jl b/experimental/LieAlgebras/test/runtests.jl index 71a185078ef2..4b4ef3fa64ee 100644 --- a/experimental/LieAlgebras/test/runtests.jl +++ b/experimental/LieAlgebras/test/runtests.jl @@ -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")