Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
92 changes: 92 additions & 0 deletions src/Groups/pcgroup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -923,3 +923,95 @@ function collector(::Type{T}, G::PcGroup) where T <: IntegerUnion
end

collector(G::PcGroup) = collector(ZZRingElem, G)

# GAP wrappers for group encoding / decoding

"""
code_pcgroup(G::PcGroup)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some doubts about the function names now: in OSCAR convention we don't normally denote the input type. So by that logic, this function should just be called code.

The reverse function pcgroup_code could then either be called just pc_group (it'd be different from other methods for that in that it would take two ZZRingElem as argument); or have a speaking name, such as pcgroup_from_code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I ref to #5456 (comment) and #5456 (comment), at least Thomas and I agree with you


Return the code representing the polycyclic group `G`, using the same
encoding as GAP's `CodePcGroup` and Magma's `SmallGroupEncoding`.

# Examples
```jldoctest
julia> G = pc_group(small_group(12, 2))
Pc group of order 12

julia> code = code_pcgroup(G)
266

julia> H = pcgroup_code(code, order(G))
Pc group of order 12

julia> code_pcgroup(G) == code_pcgroup(H)
true
```
"""
function code_pcgroup(G::PcGroup)
return GAP.Globals.CodePcGroup(GapObj(G))
end

"""
pcgroup_code(code)

Given a code (either a single integer or an integer vector), return the polycyclic group it encodes.
The accepted codes and resulting groups match those of GAP's PcGroupCode and Magma's SmallGroupDecoding.

# Examples
```jldoctest
julia> G = pc_group(small_group(12, 2))
Pc group of order 12

julia> code = code_pcgroup(G)
266

julia> H1 = pcgroup_code(code, order(G))
Pc group of order 12

julia> H2 = pcgroup_code(code, G)
Pc group of order 12

julia> code_pcgroup(G) == code_pcgroup(H1)
true

julia> code_pcgroup(G) == code_pcgroup(H2)
true

julia> vec_code = code_pcgroup(G)
266

julia> vec_code = vec(code_pcgroup(G))
1-element Vector{Int64}:
266

julia> H3 = pcgroup_code(vec_code, order(G))
Pc group of order 12

julia> code_pcgroup(H3) == code_pcgroup(G)
true
```
"""
# 1. Integer code + PcGroup
function pcgroup_code(code::Int64, G::PcGroup)
pcgroup_code(code, Int64(order(G)))
end

# 2. Integer code + integer size
function pcgroup_code(code::Int64, size::Integer)
PcGroup(GAP.Globals.PcGroupCode(code, Int64(size)))
end

# 3. Vector code + integer size
function pcgroup_code(code::Vector{<:Integer}, size::Integer)
PcGroup(GAP.Globals.PcGroupCode(code, Int64(size)))
end

# 4. Integer code + generic size (convert to Int64)
function pcgroup_code(code::Int64, size)
pcgroup_code(code, Int64(size))
end

# 5. Vector code + PcGroup
function pcgroup_code(code::Vector{<:Integer}, G::PcGroup)
pcgroup_code(code, Int64(order(G)))
end
2 changes: 2 additions & 0 deletions src/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ export cobases
export cochain_complex
export cocircuits
export cocycle_matroid
export code_pcgroup
export codim
export codomain
export codomain_covering
Expand Down Expand Up @@ -1409,6 +1410,7 @@ export partitions
export patches
export pbw_algebra
export pc_group
export pcgroup_code
export pcore
export pentagonal_hexecontahedron
export pentagonal_icositetrahedron
Expand Down
24 changes: 24 additions & 0 deletions test/Groups/pcgroup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,27 @@ end
@test is_bijective(f)
end
end

@testset "pcgroup code and reconstruction" begin
# Define the groups
groups = [
cyclic_group(6),
cyclic_group(12),
dihedral_group(10),
small_group(PcGroup, 12, 2)
]

for G in groups
# Get the code from the group
code = code_pcgroup(G)

# Decode the code depending on its type
H = isa(code, Int) ? pcgroup_code(code, G) : pcgroup_code(code)

# Test that the original and reconstructed groups are isomorphic
@test is_isomorphic(G, H)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the return value H of pcgroup_code only guaranteed to be isomorphic with the group G from which the code was computed, or is H in fact guaranteed to have the same polycyclic presentation as G?

In the latter case, we could check that hom(G, H, gens(H)) does not throw an error, which is both stronger and cheaper.
If we document this stronger property then this property can be mentioned as a reason why code_pcgroup is not defined for groups of type SubPcGroup: The generators list of a SubPcGroup is in general not a polycyclic generating sequence, and GAP's CodePcGroup is defined w.r.t. such a sequence for its input.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the same polycyclic presentation -- so, good point! well, we also should then add order(G) == order(H) to make sure we don't get a proper quotient.

And also good point about SubPcGroup.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although.. GAP does support this on subgroups of pc groups, it delegates to CodePcgs( Pcgs( G ) ) -- so from that vantage point, it would be good to also support it. The hom test would still work though, wouldn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the clarification, I'll update my tests according to all the suggestions made. I will also document the restricted support for now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general not.

julia> g = small_group(24, 12);

julia> s, _ = pcore(g, 2)
(Sub-pc group of order 4, Hom: s -> g)

julia> gens(s)
3-element Vector{SubPcGroupElem}:
 f3
 f4
 f3*f4

julia> GAP.Globals.Pcgs(GapObj(s))
GAP: Pcgs([ f3, f4 ])

The code for s will be computed w.r.t. the pcgs of s, and the PcGroup created from the code will have a pcgs as its gens value.
Then hom will be asked to map the 3-element gens(s) to the 2-element gens value of the new group.

I think supporting code_pcgroup for SubPcGroups would be asking for trouble.
It is safer to request explicitly switching from a given SubPcGroup to a PcGroup before creating the code, because this is then the group whose presentation will correspond to that of the group created from the code.

(The GAP documentation of CodePcGroup and PcGroupCode should also be made more precise.)


# Test that encoding the reconstructed group gives the same code
@test code_pcgroup(H) == code
end
end
Loading