Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add isomorphism(::Type{PermGroup}, ::WeylGroup) for some cases #4264

Merged
merged 7 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions experimental/LieAlgebras/src/LieAlgebras.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ import ..Oscar:
ngens,
order,
parent_type,
permutation_group,
rank,
root,
roots,
Expand Down
53 changes: 53 additions & 0 deletions experimental/LieAlgebras/src/WeylGroup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,59 @@
return MapFromFunc(W, G, iso, isoinv)
end

function permutation_group(W::WeylGroup; set_properties::Bool=true)
return codomain(isomorphism(PermGroup, W; set_properties))
end

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)")

Check warning on line 487 in experimental/LieAlgebras/src/WeylGroup.jl

View check run for this annotation

Codecov / codecov/patch

experimental/LieAlgebras/src/WeylGroup.jl#L487

Added line #L487 was not covered by tests
end
if !issorted(ordering)
error("Not implemented (yet)")

Check warning on line 490 in experimental/LieAlgebras/src/WeylGroup.jl

View check run for this annotation

Codecov / codecov/patch

experimental/LieAlgebras/src/WeylGroup.jl#L490

Added line #L490 was not covered by tests
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 (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
else
error("Not implemented (yet)")

Check warning on line 520 in experimental/LieAlgebras/src/WeylGroup.jl

View check run for this annotation

Codecov / codecov/patch

experimental/LieAlgebras/src/WeylGroup.jl#L520

Added line #L520 was not covered by tests
end

if set_properties
set_order(G, order(W))
end

return MapFromFunc(W, G, iso, isoinv)
end

###############################################################################
# ReducedExpressionIterator

Expand Down
47 changes: 47 additions & 0 deletions experimental/LieAlgebras/test/WeylGroup-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))),
Expand Down Expand Up @@ -111,9 +112,55 @@ 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
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))
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
end
end
Expand Down
Loading