Skip to content

Commit

Permalink
let right_cosets return a G-set (oscar-system#3223)
Browse files Browse the repository at this point in the history
* let `right_cosets` return a G-set

- add `GSetByRightTransversal`
- change `right_cosets` to return a `GSetByRightTransversal` object
- change `show` methods for `GSetByElements` and `GroupCoset`

* address comments

* adjust `show` values
  • Loading branch information
ThomasBreuer authored and HechtiDerLachs committed Jan 26, 2024
1 parent 1bf341c commit 7654e59
Show file tree
Hide file tree
Showing 5 changed files with 279 additions and 71 deletions.
12 changes: 6 additions & 6 deletions docs/src/DeveloperDocumentation/printing_details.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,18 +187,18 @@ struct A{T}
end
function Base.show(io::IO, a::A)
io = AbstractAlgebra.pretty(io)
io = pretty(io)
println(io, "Something of type A")
print(io, AbstractAlgebra.Indent(), "over ", AbstractAlgebra.Lowercase(), a.x)
print(io, AbstractAlgebra.Dedent()) # don't forget to undo the indentation!
print(io, Indent(), "over ", Lowercase(), a.x)
print(io, Dedent()) # don't forget to undo the indentation!
end
struct B
end
function Base.show(io::IO, b::B)
io = AbstractAlgebra.pretty(io)
print(io, AbstractAlgebra.LowercaseOff(), "Hilbert thing")
io = pretty(io)
print(io, LowercaseOff(), "Hilbert thing")
end
```

Expand Down Expand Up @@ -233,7 +233,7 @@ julia> struct C{T}
julia> function Base.show(io::IO, c::C{T}) where T
x = c.x
n = length(x)
print(io, "Something with ", AbstractAlgebra.ItemQuantity(n, "element"), " of type $T")
print(io, "Something with ", ItemQuantity(n, "element"), " of type $T")
end
```

Expand Down
102 changes: 66 additions & 36 deletions src/Groups/cosets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,27 @@ function ==(x::GroupCoset, y::GroupCoset)
return x.X == y.X && x.side == y.side
end

function Base.show(io::IO, ::MIME"text/plain", x::GroupCoset)
side = x.side === :left ? "Left" : "Right"
io = pretty(io)
println(io, "$side coset of ", Lowercase(), x.H)
print(io, Indent())
println(io, "with representative ", x.repr)
print(io, "in ", Lowercase(), x.G)
print(io, Dedent())
end

function Base.show(io::IO, x::GroupCoset)
side = x.side === :left ? "Left" : "Right"
if get(io, :supercompact, false)
print(io, "$side coset of a group")
else
print(io, "$side coset of ")
io = pretty(io)
print(IOContext(io, :supercompact => true), Lowercase(), x.H, " with representative ", x.repr)
end
end


"""
right_coset(H::Group, g::GAPGroupElem)
Expand All @@ -43,6 +64,11 @@ julia> g = perm(G,[3,4,1,5,2])
julia> H = symmetric_group(3)
Sym(3)
julia> right_coset(H, g)
Right coset of Sym(3)
with representative (1,3)(2,4,5)
in Sym(5)
```
"""
function right_coset(H::GAPGroup, g::GAPGroupElem)
Expand All @@ -68,8 +94,10 @@ julia> g = perm([3,4,1,5,2])
julia> H = symmetric_group(3)
Sym(3)
julia> gH = left_coset(H,g)
Left coset (1,3)(2,4,5) * Sym( [ 1 .. 3 ] )
julia> gH = left_coset(H, g)
Left coset of Sym(3)
with representative (1,3)(2,4,5)
in Sym(5)
```
"""
function left_coset(H::GAPGroup, g::GAPGroupElem)
Expand All @@ -78,16 +106,6 @@ function left_coset(H::GAPGroup, g::GAPGroupElem)
return _group_coset(parent(g), H, g, :left, GAP.Globals.RightCoset(GAP.Globals.ConjugateSubgroup(H.X,GAP.Globals.Inverse(g.X)),g.X))
end

function show(io::IO, x::GroupCoset)
a = String(GAPWrap.StringViewObj(x.H.X))
b = String(GAPWrap.StringViewObj(x.repr.X))
if x.side == :right
print(io, "Right coset $a * $b")
else
print(io, "Left coset $b * $a")
end
return nothing
end

"""
is_left(c::GroupCoset)
Expand Down Expand Up @@ -146,7 +164,9 @@ julia> H = symmetric_group(3)
Sym(3)
julia> gH = left_coset(H,g)
Left coset (1,3)(2,4,5) * Sym( [ 1 .. 3 ] )
Left coset of Sym(3)
with representative (1,3)(2,4,5)
in Sym(5)
julia> acting_domain(gH)
Sym(3)
Expand All @@ -170,8 +190,10 @@ julia> g = perm(G,[3,4,1,5,2])
julia> H = symmetric_group(3)
Sym(3)
julia> gH = left_coset(H,g)
Left coset (1,3)(2,4,5) * Sym( [ 1 .. 3 ] )
julia> gH = left_coset(H, g)
Left coset of Sym(3)
with representative (1,3)(2,4,5)
in Sym(5)
julia> representative(gH)
(1,3)(2,4,5)
Expand All @@ -197,17 +219,21 @@ Sym(4)
julia> g = perm(G,[3,4,1,5,2])
(1,3)(2,4,5)
julia> gH = left_coset(H,g)
Left coset (1,3)(2,4,5) * Sym( [ 1 .. 4 ] )
julia> gH = left_coset(H, g)
Left coset of Sym(4)
with representative (1,3)(2,4,5)
in Sym(5)
julia> is_bicoset(gH)
false
julia> f = perm(G,[2,1,4,3,5])
(1,2)(3,4)
julia> fH = left_coset(H,f)
Left coset (1,2)(3,4) * Sym( [ 1 .. 4 ] )
julia> fH = left_coset(H, f)
Left coset of Sym(4)
with representative (1,2)(3,4)
in Sym(5)
julia> is_bicoset(fH)
true
Expand All @@ -218,7 +244,7 @@ is_bicoset(C::GroupCoset) = GAPWrap.IsBiCoset(C.X)
"""
right_cosets(G::T, H::T; check::Bool=true) where T<: GAPGroup
Return the vector of the right cosets of `H` in `G`.
Return the G-set that describes the right cosets of `H` in `G`.
If `check == false`, do not check whether `H` is a subgroup of `G`.
Expand All @@ -230,17 +256,21 @@ Sym(4)
julia> H = symmetric_group(3)
Sym(3)
julia> right_cosets(G,H)
julia> rc = right_cosets(G, H)
Right cosets of
Sym(3) in
Sym(4)
julia> collect(rc)
4-element Vector{GroupCoset{PermGroup, PermGroupElem}}:
Right coset Sym( [ 1 .. 3 ] ) * ()
Right coset Sym( [ 1 .. 3 ] ) * (1,4)
Right coset Sym( [ 1 .. 3 ] ) * (1,4,2)
Right coset Sym( [ 1 .. 3 ] ) * (1,4,3)
Right coset of Sym(3) with representative ()
Right coset of Sym(3) with representative (1,4)
Right coset of Sym(3) with representative (1,4,2)
Right coset of Sym(3) with representative (1,4,3)
```
"""
function right_cosets(G::T, H::T; check::Bool=true) where T<: GAPGroup
t = right_transversal(G, H, check = check)
return [right_coset(H, x) for x in t]
return GSetByRightTransversal(G, H, check = check)
end

"""
Expand All @@ -258,12 +288,12 @@ Sym(4)
julia> H = symmetric_group(3)
Sym(3)
julia> left_cosets(G,H)
julia> left_cosets(G, H)
4-element Vector{GroupCoset{PermGroup, PermGroupElem}}:
Left coset () * Sym( [ 1 .. 3 ] )
Left coset (1,4) * Sym( [ 1 .. 3 ] )
Left coset (1,2,4) * Sym( [ 1 .. 3 ] )
Left coset (1,3,4) * Sym( [ 1 .. 3 ] )
Left coset of Sym(3) with representative ()
Left coset of Sym(3) with representative (1,4)
Left coset of Sym(3) with representative (1,2,4)
Left coset of Sym(3) with representative (1,3,4)
```
"""
function left_cosets(G::T, H::T; check::Bool=true) where T<: GAPGroup
Expand All @@ -286,10 +316,10 @@ end
function Base.show(io::IO, ::MIME"text/plain", x::SubgroupTransversal)
side = x.side === :left ? "Left" : "Right"
println(io, "$side transversal of length $(length(x)) of")
io = AbstractAlgebra.pretty(io)
io = pretty(io)
print(io, Indent())
println(io, x.H, " in")
print(io, x.G)
println(io, Lowercase(), x.H, " in")
print(io, Lowercase(), x.G)
print(io, Dedent())
end

Expand All @@ -300,7 +330,7 @@ function Base.show(io::IO, x::SubgroupTransversal)
else
print(io, "$side transversal of ")
io = pretty(io)
print(IOContext(io, :supercompact => true), x.H, " in ", x.G)
print(IOContext(io, :supercompact => true), Lowercase(), x.H, " in ", Lowercase(), x.G)
end
end

Expand Down
Loading

0 comments on commit 7654e59

Please sign in to comment.