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 letters function for PcGroupElem #4202

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

jamesnohilly
Copy link

@jamesnohilly jamesnohilly commented Oct 14, 2024

As a starting point for this PR, I've borrowed the syllable functions for PcGroup from PR #4108 to use as a reference for planned work.

Planned work for this PR:

  • New function letters for (Sub)PcGroupElem.
  • A check in _exponent_vector for whether the input is really "canonical".
  • Test cases in test/Groups/pcgroups.jl for the new functions.
  • Add doc strings for new functions.

Suggestions from @fingolfin

Moved from the mjrodgers-OW_GModules branch.
Copy link

codecov bot commented Oct 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.60%. Comparing base (da7acb0) to head (1b80584).
Report is 50 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #4202    +/-   ##
========================================
  Coverage   84.59%   84.60%            
========================================
  Files         631      640     +9     
  Lines       84899    85140   +241     
========================================
+ Hits        71824    72032   +208     
- Misses      13075    13108    +33     
Files with missing lines Coverage Δ
src/Groups/pcgroup.jl 75.34% <100.00%> (+4.61%) ⬆️

... and 57 files with indirect coverage changes

@fingolfin
Copy link
Member

Thanks @jamesnohilly to clarify: what you posted in the description is not (yet) what you did, but a description of the work programme, right? Also, should mention that the code here was taken from PR #4108 by @fieker and is only the starting point.

@jamesnohilly
Copy link
Author

Yes, that's correct! I've now updated the description to make it clearer and also included a note that the code originates from PR #4108 as the starting point.

Copy link
Member

@lgoettgens lgoettgens left a comment

Choose a reason for hiding this comment

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

some comments. Maybe more directed towards @fingolfin and @ThomasBreuer instead of @jamesnohilly

src/Groups/pcgroup.jl Outdated Show resolved Hide resolved
src/Groups/pcgroup.jl Outdated Show resolved Hide resolved
src/Groups/pcgroup.jl Outdated Show resolved Hide resolved
src/Groups/pcgroup.jl Show resolved Hide resolved
test/Groups/pcgroup.jl Outdated Show resolved Hide resolved
@fingolfin
Copy link
Member

@jamesnohilly tests are still failing. are on onto that, or do you need assistance?

@jamesnohilly jamesnohilly marked this pull request as ready for review October 31, 2024 12:09
test/Groups/pcgroup.jl Outdated Show resolved Hide resolved
src/Groups/pcgroup.jl Outdated Show resolved Hide resolved
src/Groups/pcgroup.jl Outdated Show resolved Hide resolved
julia> gg = pc_group(c)
Pc group of order 6

julia> letters(gg[1]^5*gg[2]^-4)
Copy link
Member

Choose a reason for hiding this comment

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

This example is not quite obvious for a reader. Better to show the intermediate result, that should make the connection to the output of letters "obvious" :-)

Suggested change
julia> letters(gg[1]^5*gg[2]^-4)
julia> x = gg[1]^5*gg[2]^-4
f1*f2^2
julia> letters(x)

Copy link
Author

Choose a reason for hiding this comment

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

Good idea! I have updated the example in both syllables and letters to make this output clearer.

julia> gg = pc_group(c)
Pc group of order 6

julia> syllables(gg[1]^5*gg[2]^-4)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
julia> syllables(gg[1]^5*gg[2]^-4)
julia> x = gg[1]^5*gg[2]^-4
f1*f2^2
julia> syllables(x)

Comment on lines 375 to 381
julia> c = collector(2, Int);

julia> Oscar.set_relative_orders!(c, [2, 3])

julia> Oscar.set_conjugate!(c, 2, 1, [2 => 2])

julia> gg = pc_group(c)
Copy link
Member

Choose a reason for hiding this comment

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

The interface for construction collectors is quite advanced and currently not even fully documented, so using it for an example is maybe not optimal. I suggest to use the small groups library to get a suitable example group instead, i.e. here we can just do this:

Suggested change
julia> c = collector(2, Int);
julia> Oscar.set_relative_orders!(c, [2, 3])
julia> Oscar.set_conjugate!(c, 2, 1, [2 => 2])
julia> gg = pc_group(c)
julia> gg = small_group(6,1)

and then I think the rest of the example stays unchanged.

Same remark applies below.

Copy link
Author

Choose a reason for hiding this comment

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

Perfect, no worries! I have now updated the examples with this replacement.

end

# Convert syllables in canonical form into group element
#Thomas
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#Thomas

syllables(g::Union{PcGroupElem, SubPcGroupElem})

Return the syllables of `g` as a list of pairs of integers, each entry corresponding to
a group generator and its exponent.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe also mention and/or demonstrate in the example how to go back? My understanding is that gg(syllables(x)) == x, correct?

Copy link
Author

Choose a reason for hiding this comment

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

Yes that's correct! I have added a small demonstration at the bottom of the example in the recent commit.


# Convert syllables in canonical form into group element
#Thomas
function (G::PcGroup)(sylls::Vector{Pair{Int64, ZZRingElem}}; check::Bool=true)
Copy link
Member

Choose a reason for hiding this comment

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

Can you also add a similar constructor which takes an exponent vector, i.e., an inverse to letters?

Copy link
Member

Choose a reason for hiding this comment

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

One needs to watch out for the semantic difference to the already existing function for FPGroups in

function (G::FPGroup)(extrep::AbstractVector{T}) where T <: IntegerUnion
, which expects a flattened list of syllable pairs instead.

Copy link
Member

Choose a reason for hiding this comment

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

ugh, OK. perhaps we should kill that (is it documented?) first then. In GAP it made some sense to use such a flat list to avoid memory, as there are no tuples in GAP, only lists. But in Julia there is no real benefit of this over a Vector{Pair{Int64, ZZRingElem}}.

But that is way beyond this PR. So let's leave out the constructor I mentioned.

Copy link
Member

Choose a reason for hiding this comment

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

No, not documented, but used for serialization. I haven't looked into how it is used there, so maybe we can just adapt the deserialization function, in the worst case it needs an upgrade script.

Copy link
Member

Choose a reason for hiding this comment

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

ugh, OK. perhaps we should kill that (is it documented?) first then.

maybe @ThomasBreuer can look into that?

letters(g::Union{PcGroupElem, SubPcGroupElem})

Return the letters of `g` as a list of integers, each entry corresponding to
a group generator.
Copy link
Member

@fingolfin fingolfin Nov 13, 2024

Choose a reason for hiding this comment

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

Note that we can also produce negative numbers: e.g. -3 means "inverse of 3rd generator". This should be explained, and perhaps an example added showing that. E.g. based on this:

julia> x = (gg[1]*gg[2]*gg[3])^-2
g1*g2^-2*g3^3

Perhaps also add something like this (and then mirror it in the other function)

See also [`syllables`](@ref).

Copy link
Author

Choose a reason for hiding this comment

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

I have added a small example with some brief explanation to letters for this. However I am unsure if the example is good as I was not able to get elements with negative exponents and test.

end

# Convert syllables in canonical form into exponent vector
#Thomas
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#Thomas


julia> gg(s) == x
true
"""
Copy link
Member

Choose a reason for hiding this comment

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

you are missing the three backticks here to end the doctest

Copy link
Author

Choose a reason for hiding this comment

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

good catch! I have fixed it now, thanks!

@lgoettgens
Copy link
Member

This PR now unfortunately has conflicts with #4157.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants