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

added method exponent for permutation group #18888

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

Conversation

mohitacecode
Copy link
Contributor

References to other Issues or PRs

Brief description of what is fixed or changed

A method is added to calculate the exponent of a permutation group

Other comments

Release Notes

  • combinatorics
    • Added method exponent in perm_groups.py.

@sympy-bot
Copy link

Hi, I am the SymPy bot (v158). I'm here to help you write a release notes entry. Please read the guide on how to write release notes.

Your release notes are in good order.

Here is what the release notes will look like:

This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.6.

Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it.

Click here to see the pull request description that was parsed.

<!-- Your title above should be a short description of what
was changed. Do not include the issue number in the title. -->

#### References to other Issues or PRs
<!-- If this pull request fixes an issue, write "Fixes #NNNN" in that exact
format, e.g. "Fixes #1234" (see
https://tinyurl.com/auto-closing for more information). Also, please
write a comment on that issue linking back to this pull request once it is
open. -->


#### Brief description of what is fixed or changed
A method is added to calculate the exponent of a permutation group

#### Other comments


#### Release Notes

<!-- Write the release notes for this release below. See
https://github.com/sympy/sympy/wiki/Writing-Release-Notes for more information
on how to write release notes. The bot will check your release notes
automatically to see if they are formatted correctly. -->

<!-- BEGIN RELEASE NOTES -->
- combinatorics
    - Added method `exponent` in `perm_groups.py`.
<!-- END RELEASE NOTES -->

@mohitacecode
Copy link
Contributor Author

Please review @jksuom

@mohitacecode mohitacecode changed the title added method exponent for permuatation group added method exponent for permutation group Mar 17, 2020
@codecov
Copy link

codecov bot commented Mar 17, 2020

Codecov Report

Merging #18888 into master will decrease coverage by 0.014%.
The diff coverage is 100%.

@@              Coverage Diff              @@
##            master    #18888       +/-   ##
=============================================
- Coverage   75.668%   75.653%   -0.015%     
=============================================
  Files          647       647               
  Lines       168520    168524        +4     
  Branches     39709     39710        +1     
=============================================
- Hits        127516    127495       -21     
- Misses       35448     35471       +23     
- Partials      5556      5558        +2

"""
Returns the exponent of a group

The exponent e of a group G is the lcm of the orders of its elements,
Copy link
Member

Choose a reason for hiding this comment

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

There is an existing method in sympy to compute lcm.

exp = 1
for g in self.generators:
    exp = lcm(exp, g.order())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay I will change 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.

Done

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 dedent the docstrings?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure do we need to do it for docstring too?

Copy link
Member

Choose a reason for hiding this comment

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

It’s only for the code convention

assert A.exponent() == 12

c = Permutation(1,2,3,4,5,6)(2,3,4)(5,6,7)(8,9)(10,11,12)
A = PermutationGroup([a,b,c])
Copy link
Member

Choose a reason for hiding this comment

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

I think you should add spacing around commas

Copy link
Member

Choose a reason for hiding this comment

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

This line should have [a, b, c] but I think that the previous line can be left as it is. Otherwise it will grow in size unreasonably.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay I have changed it.

@jksuom
Copy link
Member

jksuom commented Mar 18, 2020

The orders of all elements are needed for the exponent, generators alone do not suffice.

>>> from sympy.combinatorics import *
>>> s = Permutation(0, 1)
>>> t = Permutation(0, 2)
>>> G = PermutationGroup([s, t])
>>> G.exponent()
2
>>> (s*t).order()
3

@mohitacecode
Copy link
Contributor Author

The orders of all elements are needed for the exponent, generators alone do not suffice.

Yes right I have done the changes.

assert A.exponent() == 12

c = Permutation(1,2,3,4,5,6)(2,3,4)(5,6,7)(8,9)(10,11,12)
A = PermutationGroup([a, b, c])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I change this too its order is to large to be used for test?

>>> A.order()
15120

@mohitacecode
Copy link
Contributor Author

why is it failing? it is passing on my system.

@jksuom
Copy link
Member

jksuom commented Mar 18, 2020

I think that this is not a practical method. It should not be necessary to compute all elements and their orders. What does GAP do?

@mohitacecode
Copy link
Contributor Author

mohitacecode commented Mar 18, 2020

they calculate the prime divisor of the order of G and then for every prime they compute the sylow subgroup and find it's exponent.

something like:

P = primedivisor(order(G))
exp=1
for p in P:
  exp = exp * Exponent(sylowsubgroup(G,p))
return exp

@jksuom
Copy link
Member

jksuom commented Mar 18, 2020

That seems a reasonable method. The exponent of a finite group is the product of the exponents of its Sylow subgroups.

@mohitacecode
Copy link
Contributor Author

mohitacecode commented Mar 18, 2020

In case when G = sylow_subgroup(p) do we have to go for normal method of lcm otherwise it will get into infinite loop.?
for example:

>>> A = PermutationGroup([Permutation(1,2,3)])
>>> A.sylow_subgroup(3)
PermutationGroup([
    (1 2 3)])
>>> A
PermutationGroup([
    (1 2 3)])

@divyanshu132
Copy link
Member

If that is the case perhaps, you can have a set having all the sylow-p subgroups to terminate the loop you can probably use break statement if the resultant subgroup is already there in the set.

@mohitacecode
Copy link
Contributor Author

I have done the changes.

Please look will they suffice.

@mohitacecode
Copy link
Contributor Author

Please review the changes.

@jksuom
Copy link
Member

jksuom commented Mar 21, 2020

Does GAP use a special method for computing the exponent of a p-group?

@mohitacecode
Copy link
Contributor Author

mohitacecode commented Mar 21, 2020

Ahh... I did't find any they have a special method for finite abelian group where they calculate the lcm of order of the generators of group.

@jksuom
Copy link
Member

jksuom commented Mar 21, 2020

Maybe for solvable groups. p-groups a solvable, even nilpotent.

@mohitacecode
Copy link
Contributor Author

sry I again did'nt find any :( I searched extensively
but I saw they have only two method one generic and one special for finite abelian group and after that they uses RedispatchOnCondition method which usually means taking some properties and finding the method accordingly .

@mohitacecode
Copy link
Contributor Author

mohitacecode commented Mar 21, 2020

maybe It can be improved more by applying the following property:

1.)the exponent of a cyclic group is it's order(|G|).
2.)For abelian group the exponent is equal to the largest order of its element.

@mohitacecode
Copy link
Contributor Author

mohitacecode commented Mar 22, 2020

Hello @jksuom ,
I finally found a method that gap uses. They use a method for p-group named ExponentOfPGroupAndElm which they have in grppc.gi file.
I am exploring it now but from the overview it looks that it will require some other methods too.

After edit : -
That would require the computation of specialpcgs.

if sylow_p_subgroup not in sylow_groups:
elements = list(sylow_p_subgroup.elements)
exp_p = elements[0].order()
for i in range(1, len(elements)):
Copy link
Member

Choose a reason for hiding this comment

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

This looks inefficient. len(elements) may be very big.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, got it
I looked at the gap implementation that method will require the computation of many other methods too such Leedham-Green series and special pcgs and many others too.

should I go ahead and implement those in new pr's and after that jump to this pr again?

Copy link
Member

Choose a reason for hiding this comment

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

It seems that something like that will be needed. If there are no algorithms in the Handbook, then those method may be hard to implement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes you are right It can be hard probably I can take help of gap implementation (as of now they look possible to implement to me but there need to be too many implemented) but implementing these may take too much time so first I will try to open a pr on which I have already worked and they are on my system.

@oscarbenjamin
Copy link
Contributor

@mohitacecode this has merge conflicts now

@czgdp1807
Copy link
Member

@mohitacecode Please resolve the conflicts. Thanks for your contributions.

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.

None yet

8 participants