From e6d36c4420f4b4fbad017849398b98b0153255ac Mon Sep 17 00:00:00 2001 From: Antony Della Vecchia Date: Thu, 31 Oct 2024 14:25:37 +0100 Subject: [PATCH 1/7] Changes from algebraic shifting PR --- experimental/LieAlgebras/src/LieAlgebras.jl | 2 ++ experimental/LieAlgebras/src/WeylGroup.jl | 37 +++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/experimental/LieAlgebras/src/LieAlgebras.jl b/experimental/LieAlgebras/src/LieAlgebras.jl index d6cd094e36c6..8c537db721bc 100644 --- a/experimental/LieAlgebras/src/LieAlgebras.jl +++ b/experimental/LieAlgebras/src/LieAlgebras.jl @@ -74,6 +74,8 @@ import ..Oscar: ngens, order, parent_type, + perm, + permutation_matrix, rank, root, roots, diff --git a/experimental/LieAlgebras/src/WeylGroup.jl b/experimental/LieAlgebras/src/WeylGroup.jl index 821fe43e161e..34bd7c577bef 100644 --- a/experimental/LieAlgebras/src/WeylGroup.jl +++ b/experimental/LieAlgebras/src/WeylGroup.jl @@ -680,3 +680,40 @@ function Base.iterate(iter::WeylOrbitIterator, state::WeylIteratorNoCopyState) (wt, _), state = it return deepcopy(wt), state end + +################################################################################ +# converting to permutations + +function isomorphism(::Type{PermGroup}, W::WeylGroup) + coxeter_type, n = root_system_type(root_system(W))[1] + @req coxeter_type == :A "Weyl group is not the symmetric group" + G = symmetric_group(n + 1) + + iso = function (w::WeylGroupElem) + reduce(*, [cperm(G, [i, i + 1]) for i in word(w)]; init=cperm(G)) + end + + isoinv = function (g::PermGroupElem) + word = UInt8[] + for cycle in cycles(p) + transpositions = [ + sort([c, cycle[i + 1]]) for (i, c) in enumerate(cycle) if i < length(cycle)] + for t in transpositions + word = reduce( + vcat, + [ + [i for i in t[1]:(t[2] - 1)], + [i for i in reverse(t[1]:(t[2] - 2))], + word], + ) + end + end + return W(word) + end + + return MapFromFunc(W, G, iso, isoinv) +end + +function permutation_matrix(R::Ring, w::WeylGroupElem) + permutation_matrix(R, isomorphism(PermGroup, parent(w))(w)) +end From 4e6af38888810f0023584e690ad792f91fd70ba3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Thu, 31 Oct 2024 14:30:12 +0100 Subject: [PATCH 2/7] Remove `permutation_matrix` --- experimental/LieAlgebras/src/LieAlgebras.jl | 2 -- experimental/LieAlgebras/src/WeylGroup.jl | 4 ---- 2 files changed, 6 deletions(-) diff --git a/experimental/LieAlgebras/src/LieAlgebras.jl b/experimental/LieAlgebras/src/LieAlgebras.jl index 8c537db721bc..d6cd094e36c6 100644 --- a/experimental/LieAlgebras/src/LieAlgebras.jl +++ b/experimental/LieAlgebras/src/LieAlgebras.jl @@ -74,8 +74,6 @@ import ..Oscar: ngens, order, parent_type, - perm, - permutation_matrix, rank, root, roots, diff --git a/experimental/LieAlgebras/src/WeylGroup.jl b/experimental/LieAlgebras/src/WeylGroup.jl index 34bd7c577bef..5bf71a1456b3 100644 --- a/experimental/LieAlgebras/src/WeylGroup.jl +++ b/experimental/LieAlgebras/src/WeylGroup.jl @@ -713,7 +713,3 @@ function isomorphism(::Type{PermGroup}, W::WeylGroup) return MapFromFunc(W, G, iso, isoinv) end - -function permutation_matrix(R::Ring, w::WeylGroupElem) - permutation_matrix(R, isomorphism(PermGroup, parent(w))(w)) -end From 74996d32236f9a5d9668046761e475fa065caa6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Thu, 31 Oct 2024 15:00:55 +0100 Subject: [PATCH 3/7] Move function up --- experimental/LieAlgebras/src/WeylGroup.jl | 64 +++++++++++------------ 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/experimental/LieAlgebras/src/WeylGroup.jl b/experimental/LieAlgebras/src/WeylGroup.jl index 5bf71a1456b3..cf6f826e05a5 100644 --- a/experimental/LieAlgebras/src/WeylGroup.jl +++ b/experimental/LieAlgebras/src/WeylGroup.jl @@ -474,6 +474,37 @@ function isomorphism(::Type{FPGroup}, W::WeylGroup; set_properties::Bool=true) return MapFromFunc(W, G, iso, isoinv) end +function isomorphism(::Type{PermGroup}, W::WeylGroup) + coxeter_type, n = root_system_type(root_system(W))[1] + @req coxeter_type == :A "Weyl group is not the symmetric group" + G = symmetric_group(n + 1) + + iso = function (w::WeylGroupElem) + reduce(*, [cperm(G, [i, i + 1]) for i in word(w)]; init=cperm(G)) + end + + isoinv = function (g::PermGroupElem) + word = UInt8[] + for cycle in cycles(p) + transpositions = [ + sort([c, cycle[i + 1]]) for (i, c) in enumerate(cycle) if i < length(cycle)] + for t in transpositions + word = reduce( + vcat, + [ + [i for i in t[1]:(t[2] - 1)], + [i for i in reverse(t[1]:(t[2] - 2))], + word], + ) + end + end + return W(word) + end + + return MapFromFunc(W, G, iso, isoinv) +end + + ############################################################################### # ReducedExpressionIterator @@ -680,36 +711,3 @@ function Base.iterate(iter::WeylOrbitIterator, state::WeylIteratorNoCopyState) (wt, _), state = it return deepcopy(wt), state end - -################################################################################ -# converting to permutations - -function isomorphism(::Type{PermGroup}, W::WeylGroup) - coxeter_type, n = root_system_type(root_system(W))[1] - @req coxeter_type == :A "Weyl group is not the symmetric group" - G = symmetric_group(n + 1) - - iso = function (w::WeylGroupElem) - reduce(*, [cperm(G, [i, i + 1]) for i in word(w)]; init=cperm(G)) - end - - isoinv = function (g::PermGroupElem) - word = UInt8[] - for cycle in cycles(p) - transpositions = [ - sort([c, cycle[i + 1]]) for (i, c) in enumerate(cycle) if i < length(cycle)] - for t in transpositions - word = reduce( - vcat, - [ - [i for i in t[1]:(t[2] - 1)], - [i for i in reverse(t[1]:(t[2] - 2))], - word], - ) - end - end - return W(word) - end - - return MapFromFunc(W, G, iso, isoinv) -end From 3daa5ed2d71cd9b83e31c43ab3ff998c2467b1ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Thu, 31 Oct 2024 15:02:05 +0100 Subject: [PATCH 4/7] Make iso more consistent with `FPGroup` iso --- experimental/LieAlgebras/src/LieAlgebras.jl | 1 + experimental/LieAlgebras/src/WeylGroup.jl | 64 ++++++++++++++------- 2 files changed, 44 insertions(+), 21 deletions(-) diff --git a/experimental/LieAlgebras/src/LieAlgebras.jl b/experimental/LieAlgebras/src/LieAlgebras.jl index d6cd094e36c6..e866dfbd8e64 100644 --- a/experimental/LieAlgebras/src/LieAlgebras.jl +++ b/experimental/LieAlgebras/src/LieAlgebras.jl @@ -74,6 +74,7 @@ import ..Oscar: ngens, order, parent_type, + permutation_group, rank, root, roots, diff --git a/experimental/LieAlgebras/src/WeylGroup.jl b/experimental/LieAlgebras/src/WeylGroup.jl index cf6f826e05a5..e4d0fd98e021 100644 --- a/experimental/LieAlgebras/src/WeylGroup.jl +++ b/experimental/LieAlgebras/src/WeylGroup.jl @@ -474,37 +474,59 @@ function isomorphism(::Type{FPGroup}, W::WeylGroup; set_properties::Bool=true) return MapFromFunc(W, G, iso, isoinv) end -function isomorphism(::Type{PermGroup}, W::WeylGroup) - coxeter_type, n = root_system_type(root_system(W))[1] - @req coxeter_type == :A "Weyl group is not the symmetric group" - G = symmetric_group(n + 1) +function permutation_group(W::WeylGroup; set_properties::Bool=true) + return codomain(isomorphism(PermGroup, W; set_properties)) +end - iso = function (w::WeylGroupElem) - reduce(*, [cperm(G, [i, i + 1]) for i in word(w)]; init=cperm(G)) +function isomorphism(::Type{PermGroup}, W::WeylGroup; set_properties::Bool=true) + @req is_finite(W) "Weyl group is not finite" + R = root_system(W) + type, ordering = root_system_type_with_ordering(R) + + if length(type) != 1 + error("Not implemented (yet)") + end + if !issorted(ordering) + error("Not implemented (yet)") end + coxeter_type, n = only(type) + if coxeter_type == :A + G = symmetric_group(n + 1) + + iso = function (w::WeylGroupElem) + reduce(*, [cperm(G, [i, i + 1]) for i in word(w)]; init=cperm(G)) + end - isoinv = function (g::PermGroupElem) - word = UInt8[] - for cycle in cycles(p) - transpositions = [ - sort([c, cycle[i + 1]]) for (i, c) in enumerate(cycle) if i < length(cycle)] - for t in transpositions - word = reduce( - vcat, - [ - [i for i in t[1]:(t[2] - 1)], - [i for i in reverse(t[1]:(t[2] - 2))], - word], - ) + isoinv = function (p::PermGroupElem) + word = UInt8[] + for cycle in cycles(p) + transpositions = [ + sort([c, cycle[i + 1]]) for (i, c) in enumerate(cycle) if i < length(cycle) + ] + for t in transpositions + word = reduce( + vcat, + [ + [i for i in t[1]:(t[2] - 1)], + [i for i in reverse(t[1]:(t[2] - 2))], + word, + ], + ) + end end + return W(word) end - return W(word) + else + error("Not implemented (yet)") + end + + if set_properties + set_order(G, order(W)) end return MapFromFunc(W, G, iso, isoinv) end - ############################################################################### # ReducedExpressionIterator From 22d9148db28b6ec67fa86ff4d392c49269e90078 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Thu, 31 Oct 2024 15:02:13 +0100 Subject: [PATCH 5/7] Add some tests --- .../LieAlgebras/test/WeylGroup-test.jl | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/experimental/LieAlgebras/test/WeylGroup-test.jl b/experimental/LieAlgebras/test/WeylGroup-test.jl index 76178206bce4..013b70883333 100644 --- a/experimental/LieAlgebras/test/WeylGroup-test.jl +++ b/experimental/LieAlgebras/test/WeylGroup-test.jl @@ -52,6 +52,7 @@ include( @testset "WeylGroup Group conformace test for $(Wname)" for (Wname, W) in [ ("A1", weyl_group(:A, 1)), + ("A5", weyl_group(:A, 5)), ("B4", weyl_group(root_system(:B, 4))), ("D5", weyl_group(cartan_matrix(:D, 5))), ("F4+G2", weyl_group((:F, 4), (:G, 2))), @@ -118,6 +119,41 @@ include( end end end + + if has_root_system_type(root_system(W)) + type, ordering = root_system_type_with_ordering(root_system(W)) + if length(type) == 1 && issorted(ordering) && only(type)[1] == :A # only implemented for A_n (yet) + @testset "isomorphism(PermGroup, ::WeylGroup; set_properties=$set_properties)" for set_properties in + [ + false, true + ] + G = permutation_group(W; set_properties) + if (is_finite(W) && ngens(W) < 6) || set_properties #= for sane runtime =# + @test is_finite(G) == is_finite(W) + is_finite(W) && @test order(G) == order(W) + end + + iso = isomorphism(PermGroup, W; set_properties) + @test W == domain(iso) + G = codomain(iso) + if (is_finite(W) && ngens(W) < 6) || set_properties #= for sane runtime =# + @test is_finite(G) == is_finite(W) + is_finite(W) && @test order(G) == order(W) + if ngens(W) < 10 #= for sane runtime =# + for _ in 1:5 + if is_finite(W) # remove once rand(W) is implemented for infinite groups + w = rand(W) + @test w == inv(iso)(iso(w)) + end + g = rand_pseudo(G) + @test g == iso(inv(iso)(g)) + end + end + end + end + end + end + end @testset "<(x::WeylGroupElem, y::WeylGroupElem)" begin From c6d520be20ff2cc8e9730336b1bdc9effa55e564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Fri, 1 Nov 2024 12:24:43 +0100 Subject: [PATCH 6/7] Formatting --- experimental/LieAlgebras/test/WeylGroup-test.jl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/experimental/LieAlgebras/test/WeylGroup-test.jl b/experimental/LieAlgebras/test/WeylGroup-test.jl index 013b70883333..a87701a79580 100644 --- a/experimental/LieAlgebras/test/WeylGroup-test.jl +++ b/experimental/LieAlgebras/test/WeylGroup-test.jl @@ -124,9 +124,9 @@ include( type, ordering = root_system_type_with_ordering(root_system(W)) if length(type) == 1 && issorted(ordering) && only(type)[1] == :A # only implemented for A_n (yet) @testset "isomorphism(PermGroup, ::WeylGroup; set_properties=$set_properties)" for set_properties in - [ - false, true - ] + [ + false, true + ] G = permutation_group(W; set_properties) if (is_finite(W) && ngens(W) < 6) || set_properties #= for sane runtime =# @test is_finite(G) == is_finite(W) @@ -153,7 +153,6 @@ include( end end end - end @testset "<(x::WeylGroupElem, y::WeylGroupElem)" begin From 2286d2368332faf13a47040f46d30437bc5fee1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Fri, 1 Nov 2024 12:32:13 +0100 Subject: [PATCH 7/7] Better iso test --- experimental/LieAlgebras/test/WeylGroup-test.jl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/experimental/LieAlgebras/test/WeylGroup-test.jl b/experimental/LieAlgebras/test/WeylGroup-test.jl index a87701a79580..e78ad3d73ad5 100644 --- a/experimental/LieAlgebras/test/WeylGroup-test.jl +++ b/experimental/LieAlgebras/test/WeylGroup-test.jl @@ -112,9 +112,15 @@ include( if is_finite(W) # remove once rand(W) is implemented for infinite groups w = rand(W) @test w == inv(iso)(iso(w)) + v = rand(W) + @test iso(v * w) == iso(v) * iso(w) + @test v * w == inv(iso)(iso(v) * iso(w)) end g = rand_pseudo(G) @test g == iso(inv(iso)(g)) + h = rand_pseudo(G) + @test inv(iso)(h * g) == inv(iso)(h) * inv(iso)(g) + @test h * g == iso(inv(iso)(h) * inv(iso)(g)) end end end @@ -144,9 +150,15 @@ include( if is_finite(W) # remove once rand(W) is implemented for infinite groups w = rand(W) @test w == inv(iso)(iso(w)) + v = rand(W) + @test iso(v * w) == iso(v) * iso(w) + @test v * w == inv(iso)(iso(v) * iso(w)) end g = rand_pseudo(G) @test g == iso(inv(iso)(g)) + h = rand_pseudo(G) + @test inv(iso)(h * g) == inv(iso)(h) * inv(iso)(g) + @test h * g == iso(inv(iso)(h) * inv(iso)(g)) end end end