diff --git a/experimental/LieAlgebras/src/LieAlgebraHom.jl b/experimental/LieAlgebras/src/LieAlgebraHom.jl index f4d6d8055211..cbd78e90e3a3 100644 --- a/experimental/LieAlgebras/src/LieAlgebraHom.jl +++ b/experimental/LieAlgebras/src/LieAlgebraHom.jl @@ -26,9 +26,7 @@ h.matrix = mat::dense_matrix_type(coefficient_ring(L2)) h.header = MapHeader(L1, L2) if check - for x1 in basis(L1), x2 in basis(L1) - @req h(x1) * h(x2) == h(x1 * x2) "Not a homomorphism" - end + @req is_welldefined(h) "Not a homomorphism" end return h end @@ -51,6 +49,20 @@ function matrix(h::LieAlgebraHom{<:LieAlgebra,<:LieAlgebra{C2}}) where {C2<:Ring 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 diff --git a/experimental/LieAlgebras/test/LieAlgebraHom-test.jl b/experimental/LieAlgebras/test/LieAlgebraHom-test.jl index afba2f992782..e9abcf4343df 100644 --- a/experimental/LieAlgebras/test/LieAlgebraHom-test.jl +++ b/experimental/LieAlgebras/test/LieAlgebraHom-test.jl @@ -7,11 +7,7 @@ @test domain(h) == L1 @test codomain(h) == L2 @test matrix(h) == matrix(QQ, [0 1 0 0; 0 0 1 0; 1 0 0 -1]) - for x1 in basis(L1) - for x2 in basis(L1) - @test h(x1 * x2) == h(x1) * h(x2) - end - end + @test is_welldefined(h) end @testset "Image and kernel" begin @@ -45,6 +41,7 @@ @test domain(h) == L1 @test codomain(h) == L1 @test matrix(h) == identity_matrix(QQ, dim(L1)) + @test is_welldefined(h) for x in basis(L1) @test h(x) == x end @@ -55,6 +52,7 @@ @test domain(h) == L1 @test codomain(h) == L2 @test matrix(h) == zero_matrix(QQ, dim(L1), dim(L2)) + @test is_welldefined(h) for x in basis(L1) @test h(x) == zero(L2) end diff --git a/experimental/LieAlgebras/test/LieAlgebraModuleHom-test.jl b/experimental/LieAlgebras/test/LieAlgebraModuleHom-test.jl index 1b1588f2cc22..d9a8cf97e132 100644 --- a/experimental/LieAlgebras/test/LieAlgebraModuleHom-test.jl +++ b/experimental/LieAlgebras/test/LieAlgebraModuleHom-test.jl @@ -33,6 +33,35 @@ @test image(h, v6) == h(v6) == v3 end + @testset "Identity and zero map" begin + L = special_linear_lie_algebra(QQ, 3) + stdV = standard_module(L) + V1 = symmetric_power(stdV, 3) + V2 = exterior_power(stdV, 2) + + h = identity_map(V1) + @test domain(h) == V1 + @test codomain(h) == V1 + @test matrix(h) == identity_matrix(QQ, dim(V1)) + @test is_welldefined(h) + for v in basis(V1) + @test h(v) == v + end + # @test image(h) == ... + # @test kernel(h) == ... + + h = zero_map(V1, V2) + @test domain(h) == V1 + @test codomain(h) == V2 + @test matrix(h) == zero_matrix(QQ, dim(V1), dim(V2)) + @test is_welldefined(h) + for v in basis(V1) + @test h(v) == zero(V2) + end + # @test image(h) == ... + # @test kernel(h) == ... + end + @testset "Composition" begin L = special_orthogonal_lie_algebra(QQ, 3) V1 = standard_module(L)