Gaurav Dhingra2016-08-22T00:01:44+05:30https://gxyd.github.ioGaurav Dhingraaxyd0000@gmail.comGSoC 2016 Project with SymPy(wrap up): Computational Group Theory2016-08-22T00:00:00+05:30https://gxyd.github.io/GSoC GSoC 2016 Project with SymPy(wrap up): Computational Group Theory
<p>
Hi, I'm Gaurav Dhingra (<a href="https://github.com/gxyd">@gxyd</a>) and this post is a report of my work for SymPy under <a href="https://summerofcode.withgoogle.com">Google Summer of Code 2016</a>.
</p>
<p>
This is also intended to be a description of my work for submission to <b>GSoC's Final Evaluation</b>.
</p>
<p>
<h3>
<u>Work Product Submission</u>
</h3>
</p>
<p>
<a href="https://github.com/gxyd/sympy/pull/6">PR for GSoC 2016 product submission: Gaurav Dhingra</a>.<br><br>
<a href="https://github.com/gxyd/sympy/wiki/GSoC-2016-Application-Gaurav-Dhingra:-Group-Theory">GSoC proposal</a>
<h4>Pull Requests</h4>
</p>
<p>
<ul>
<font color=green>[Completed]</font>
<li><a href="https://github.com/sympy/sympy/pull/10350">#10350 <i>FreeGroup</i> implementation in SymPy</a></li>
<li><a href="https://github.com/sympy/sympy/pull/11140">#11140 <i>FpGroup</i> implementation in SymPy</a></li>
<li><a href="https://github.com/sympy/sympy/pull/11231">#11231 <i>Low Index Subgroups</i> algorithm implementation in SymPy</a></li>
<li><a href="https://github.com/sympy/sympy/pull/11295">#11295 <i>Reidemeister Schreier</i> algorithm implementation in SymPy</a></li>
<li><a href="https://github.com/sympy/sympy/pull/11460">#11460 Add documentation for FpGroup file and fix separate bug</a></li>
</ul>
</p>
<p>
<ul>
<font color=red>[Work-in-progress]</font>
<li><a href="https://github.com/sympy/sympy/pull/11361">#11361 <i>Modified Todd Coxeter</i> algorithm implementation in SymPy</a></li>
</ul>
</p>
</p>
<p>
<h4>Bugs reported</h4>
<font color="green">[closed]</font>
<ul>
<li><a href="https://github.com/sympy/sympy/issues/11449">#11449 <i>TypeError</i> on compressing a Coset Table generated by coset table method</a>.</li>
</ul>
</p>
<p>
<h3>Brief Information</h3>
</p>
<p>
<b>Project</b>: <a href="https://summerofcode.withgoogle.com/projects/#5798586428162048">Group Theory</a>
<br><br>
<b>Blog</b>: <a href="https://gxyd.github.io/gsoc.html">https://gxyd.github.io/gsoc.html</a>
<br><br>
<b>My Website</b>: https://gxyd.github.io
<br><br>
<b>e-mail</b>: axyd0000[at]gmail.com, igauravdhingra[at]protonmail.com
<br><br>
I am a pre-final year undergraduate student of Applied Mathematics at IIT Roorkee.
</p>
<p>
<h3>Before GSoC</h3>
</p>
<p>
I heard about the GSoC program and about SymPy org. since of one of my college mate, Prasoon Shukla (he also participated in GSoC with SymPy). I was quite amazed by how mathematics and computer science could intersect and help in solving math problems.
</p>
<p>
I have been contributing to SymPy from May last year. In the beginning I tended often to work on issues that were more often related to my then on-going courses in my college. In December I completed a basic course on Group Theory, so I thought of choosing to work on Group Theory and I saw quite a few things in CGT were missing from SymPy and those functionalities were already there in GAP and Magma. So I asked them from Kalevi, regarding things that could be taken up for a gsoc project. So finally with some discussions with him and Aaron, I was sure by December end that I was going to work on implementing Finitely Presented Group in SymPy. I looked upto the last GSoC project on CGT by Alexandar Makelov, for reference material that could be used for the implementation and it turned out that the book by Derek Holt, Handbook of Computational Group Theory (will mention as shortly <i>the Handbook</i>).
<p>
<p>
Though I already started working on <a href="https://github.com/sympy/sympy/pull/10350">PR #10350</a> for implementation of free groups in beginning January though I started working on the proposal from February beginning.
</p>
<p>
So what I should do? Since I was quite sure of the project. Well at that moment I thought, since I am a mathematics major, choosing this project would also help me. So I reached out to Kalevi, said to him what I was thinking to do, what could be good for the project. So we worked upon making a good gsoc proposal.
</p>
<p>
Here is my <a href="https://github.com/gxyd/sympy/wiki/GSoC-2016-Application-Gaurav-Dhingra:-Group-Theory">GSoC proposal</a>. Now that the summer is over and I've tackled a lot more with computational group theory, it seems that the main points in my GSoC proposal were:
<ul>
<li>Implementation of different algebraic structures monoid, free monoid, free group, semi group, free semi group, magma, etc.
<li>Rewriting System for reducing the elements of finitely presented groups.
<li>The Todd-Coxeter algorithm for coset enumeration, used to find the index of a subgroup of a finitely presented group.
<li>Reidemeister Schreier algorithm.
<li>Implementation of main <code>Group</code> class.
</ul>
</p>
<p>
Well, I submitted my proposal and needed to wait until April 22 to the result, and then...
</p>
<img src="../images/gsoc_selection.png" height="200" width="650">
<br><br>
<i>I was selected _/\_</i>
<p>
I got lucky to have Kalevi Suominen like mentor too. Aaron Meurer, the project leader of SymPy was to be co-mentor, and I felt honored to be alloted my preferred mentors.
</p>
<p>
<h3>During GSoC</h3>
</p>
<p>
A more detailed account of my progress can be found on my blog <a href="https://gxyd.gitub.io/gsoc.html">here</a>
<ul>
<li>We started working on 7th May, we first started with working on completing the Free Group <a href="https://github.com/sympy/sympy/pull/10350">PR#10350</a> and we discussed things on our channel <a href="https://gitter.im/sympy/GroupTheory">sympy/GroupTheory</a>. We had some discussion on whether <code>Basic</code> should be a <i>super-class</i> of <code>FreeGroup</code> or not. In the end we decied not to derive <code>FreeGroup</code> from <code>Basic</code>. Its basic methods had already been written, most of them inspired from GAP software.</li>
<li>For the first point in my proposal (i.e implementation of algebraic structures), we didn't started with them (infact we never worked on them). We then moved onto the Coset Enumeration which covered 5 weeks of work in my timeline, but we didn't spend that much time, atleast on the first go at that moment, that did took alomost 3 weeks including the implementation of two strategies of enumeration <i>Felsch</i> and <i>HLT</i>. It was the very heart of our GSoC project. There were quite a few bugs that were there in algorithm, especially the bug #11449, to which the Kalevi found the solution.</li>
<li>For the second point we never reached it, there wasn't sufficient time for that. Then we decided to rather implement the <i>Low Index Subgroups</i> algortithm. It was quite fun to implement the algorithm, since it gave some good insight into CGT. More on this on <a href="gsoc_week_5.html">blog for week 5</a>.</li>
<li>From here I had passed my mid-term evaluations. Then we started with work on <i>Reidemeister Schreier</i> algorithm. The algorithm was mainly implemeted using the <a href="http://staff.itee.uq.edu.au/havas/1974h.pdf">Havas paper</a>, though the current implementation in SymPy doesn't produce the best simplifed presentation. No good pseudocode is available for the algorithm, the major difficulty being the <i>sequence</i> of applying the operation. More on this on <a href="https://gxyd.github.io/gsoc_week_6.html">blog for week 6</a>.</li>
<li>After we thought that the result returned by Reidemeister Schreier algorithm we moved onto <i>modified todd coxeter</i> algorithm. The main difficulty in it was defining the $\tau$ which can be read on the our channel for comments by Kalevi, I belive it can help in solving that problem.</li>
<li>As to the fifth point (i.e making <code>Group</code> class), we never worked upon it. Also the topic of <i>Presenation of Finite Groups</i> , could not get much attention, since of my busy college schedule.</li>
</ul>
</p>
<p>
<h5><u>Commits/Code written during GSoC</u></h5>
</p>
<p>
Since I have commited quite a few commits un-related to my project. So I decided to <i>cherry-pick</i> the commits made for my GSoC project. So the combined commits makes the things quite clear. <a href="https://github.com/sympy/sympy/commits/master?author=gxyd">commits in GSoC 2016 product submission: Gaurav Dhingra</a>.
</p>
<p>
<h5><u>Most annoying issue</u></h5>
</p>
<p>
<a href="https://github.com/sympy/sympy/issues/11449">issue #11449</a>
</p>
<p>
<h3>After GSoC</h3>
</p>
<p>
There is still much to be done regarding the finitely presented groups. As during the program my efforts were directed mainly towards getting the fundamental algorithms for finitely presented groups in, the overall structure of the module hasn't received much attention.
</p>
<p>
The algorithms are in, but the methods in sympy/combinatorics/fp_groups.py are not that much user-friendly. The code organization is not terrible, I think. Some suggestions (both for me and anyone else interested) for future work are:
<ul>
<li><b>Cosets in permutation groups</b>: [verbatim-copy of Kalevi's mail - <i>"next thing to do"</i>] Finding cosets in permutation groups is more challenging to implement since there seems to be no ready-made pseudocode. However, there is a description of the procedure with an example in section 4.6.7. It can be based on the existing implementation of the <i>Screier-Sims algorithm</i>.</li>
<li><b>Finitely generated abelian groups</b>: [verbatim-copy of Kalevi's mail - <i>"next thing to do"</i>] There is useful pseudocode in chapter 9 of the book by Holt that should make it fairly easy to implement the basic methods of abelian groups. We should probably try to base the implementation on the code in <code>polys.agca</code> as abelian groups are the same as Z-modules. It is all essentially about linear algebra over the integers.</li>
<li><b>Complete modified Todd Coxeter algorithm</b>: <a href="https://github.com/sympy/sympy/pull/11361">PR #11361</a> One bug is currently there in the algorithm, which can be fixed since we have to make assignments to $\tau$. Also currently no tests have been added, which can be added.</li>
<li><b>Rewriting System</b>: This can be a good candidate for a major work, I included this topic in my proposal though was left untouched. Perhaps <i>GAP</i> could be first seen in this regard. Like always</li>
<li><b>Groups folder</b>: After a few of the above mentioned things have been done, I believe it could be a good time to make a folder named <code>groups</code>, since finitely presented groups should not be a part of combinatorics module which would contain the all algebraic structures including the permutation groups.</li>
<li><b>Non-associative algebra</b>: (Perhaps I got the spelling of <i>associative</i> this time right!) Albert CAS could be used to understand the workings related to non-associative algebra, it contains quite good functionalities.</li>
</ul>
</p>
<p>
<h3>Things I did right/wrong</h3>
</p>
<p>
<ul>
<li>I often lagged in writing blogs.</li>
<li>I worked more than expected hours before 15 July (before college started) but much less in the last one month of GSoC because of a little busy schedule.</li>
</ul>
</p>
<p>
<h3>Conclusion</h3>
</p>
<p>
I had say that I did about 70% of the work I promised to do in my proposal, considering that I also did two non-included task of Low Index subgroups algorithm and Modified Todd Coxeter algorithm, so I can say I swapped my work. It is good enough, and I hope to get back to extending the things that I have started. There's still some revision to be made, some code to be clean up. And I'm doing that.
</p>
<p>
I don't really know if I'll pass final evaluations by Google, but, regardless, I'm really glad for all the coding and development experience I got during these weeks. I'll probably use for personal projects, may be in Dissertation in last year, and try to contribute more to SymPy.
</p>
<p>
I appreciate the help of my mentor <a href="https://github.com/jksuom">Kalevi Suominen</a> who was always there for any query that I had regarding Group Theory in project, and I appreciate his ability to reply back within 1 hour for any message I left any time of day and every day of the week including weekend (I call it 1-hour rule). I think he was a wonderful mentor and I learnt a lot from him, and my co-mentor <a href="https://github.com/asmeurer">Aaron Meurer</a>, the current project leader of SymPy, and the entire SymPy community for helping me out and reviewing my work!
</p>
<p>
Also thank you <font color="#4885ed">G</font><font color="#db3236">o</font><font color="#f4c20d">o</font><font color="#4885ed">g</font><font color="#3cba54">l</font><font color="#db3236">e</font>.
</p>
</p>
<p>
<p>
अलविदा !
</p>
GSoC Week 122016-08-10T00:00:00+05:30https://gxyd.github.io/GSoC Week 12
<p>
Hi all, here's a brief summary of the 12th week of my GSoC:
<br />
Last week I uploaded the <a href="https://gxyd.github.io/gsoc2016/covhtml/index.html">test-coverage files</a> on my website, that revealed some interesting places where a few versions of <code>scan</code> routine in coset enumeration have un-tested <code>if-elif-else</code> case.
</p>
<p>
As we are now approaching the end of GSoC time period, we decided to do some testing with some of the examples from 1973cdhw paper [2]. Coset Enumeration got my attention again since:
</p>
<p>
There seemed to be one bug raising <code>TypeError</code> so opened issue <a href="https://github.com/sympy/sympy/issues/11449">sympy/sympy/#11449</a>, resulting from coset enumeration by the coset-table based method. From beginning it was clear that the issue was not in <code>compress()</code> method. It was quite difficult for me get onto the main source of problem. But then Kalevi had a closer look on the pseudo-code in Derek Holt and also in Sims Finitely Presented Groups.
</p>
<p>
I wrote docstrings for a few of methods and fixed the issue <a href="https://github.com/sympy/sympy/issue/11449">#11449</a> in PR <a href="https://github.com/sympy/sympy/pull/11460">#11460</a>.
</p>
<p>
The problem there in code is explained briefly below
</p>
<b>Previous code-snippet</b>
<p>
<pre>
1 i = 0
2 while i < len(C.omega):
3 alpha = C.omega[i]
4 i += 1
5 for x in C.A:
6 if C.table[alpha][C.A_dict[x]] is None:
7 C.define_f(alpha, x)
8 C.process_deductions(R_c_list[C.A_dict[x]], R_c_list[C.A_dict_inv[x]])
</pre>
</p>
<b>After code-snippet</b>
<p>
<pre>
1 while alpha < len(C.table):
2 if C.p[alpha] == alpha:
3 for x in C.A:
4 if C.p[alpha] != alpha:
5 break
6 if C.table[alpha][C.A_dict[x]] is None:
7 C.define_c(alpha, x)
8 C.process_deductions(R_c_list[C.A_dict[x]], R_c_list[C.A_dict_inv[x]])
</pre>
</p>
<p>
Here $\alpha$ looks over in till $\lt$ <code>C.table</code>. This way all elements of $C.\Omega$ are tested even in case that the set becomes very small. The inner for $x$ loop should also tests $p[i]$ at each round and break if that becomes different from $i$.
</p>
<p>
The changes that have been addressed in <a href="https://github.com/sympy/sympy/pull/11460">PR #11460</a> also include chaging the file name <code>free_group.py</code> to <code>free_groups.py</code>, similar to what we have.
</p>
<p>
It seems that Presentation of Permutation Groups won't happen during GSoC since there's just one more week; instead, I plan to focus on improving and completing the current PR's <a href="https://github.com/sympy/sympy/pull/11361">#11361</a> on Modified Todd-Coxeter algorithm and <a href="https://github.com/sympy/sympy/pull/11460">PR #11460</a> on addition of docstrings and better user methods.
</p>
<p>
One more thing, that I would start in this week though may not be completed this week will be the sphinx documentation of finitely presented groups. I found the documentation of Poly's module by Kalevi very much readable and interesting, may be I can seek to follow that.
</p>
<p>
<h4>References</h4>
<i>
<ul>
<li>1. Derek F. Holt, Bettina Eick, Bettina, Eamonn A. O'Brien, "Handbook of computational group theory", Discrete Mathematics and its Applications (Boca Raton). Chapman & Hall/CRC, Boca Raton, FL, 2005. ISBN 1-5848-372-3 .</li>
<li>2. <a href="http://staff.itee.uq.edu.au/havas/1973cdhw.pdf">John J. Cannon; Lucien A. Dimino; George Havas; Jane M. Watson, "Implementation and Analysis of the Todd-Coxeter Algorithm" , Mathematics of Computation, Vol. 27, No. 123. (Jul., 1973), pp. 463-490</a></li>
</i>
<br>
</ul>
GSoC Week 72016-07-11T00:00:00+05:30https://gxyd.github.io/GSoC Week 7
<p>
Hi everyone.
</p>
<br>
<br>
<p>
Here's what we have been doing for <i>7th</i> week of <i>GSoC</i>.
</p>
<p>
Kalevi mentioned about the $LaTex$ not getting rendered on Planet Sympy website, thought it works fine on my website. Following the conversation Aaron opened issue <a href="https://github.com/sympy/planet-sympy/issues/45">planet-sympy/issues/45</a>, though it hasn't been fixed.
</p>
<p>
This week we completed PR <a href="https://github.com/sympy/sympy/pull/11295">#11295</a> on Reidemeister Schreier algorithm. Remember the <a href="https://gitter.im/sympy/GroupTheory?at=5776b220cdab7a1f4fbebd34">blog issue</a> I asked on our gitter channel. Kalevi suggested to be more on the 'descriptive' side.
</p>
<p>
<h4>What do we do this week?</h4>
Implemented the Reidemeister Schreier algorithm (shortly RS algorithm) and Titze Transformations (shortly TT) in PR #11295 . Most of the pseudo code for RS algorithm is there in the Handbook [1], perhaps majority of the time was spent working with TT. There isn't any pseudo code available for making that work, but we gathered detailed information from [1] combined with Havas Paper [2].
What issues were there?
In the both [1] and [2], there a few assumptions made, like
<pre>
> shall assume that all relators are always cyclically reduced; that is, that
whenever a relator is changed, it is immediately replaced by its cyclic reduction.
</pre>
</p>
<p>I opened the issue <a href="https://github.com/sympy/sympy/issues/11352">#11352</a> regarding a typo I left in <code>coset_enumeration_c</code>. Though I didn't expect a PR, @kritkaran94 fixed it. Perhaps a good test case which makes use of different value of <code>max_stack_size</code> was suggested by Kalevi. One thing came back to me, "everthing is an object in Python", the fact that initially <code>CosetTableDefaultMaxLimit</code> was a module level variable initially and we changed it to <code>CosetTable.CosetTableDefaultMaxLimit</code>, module is an object so is a <code>class</code>.
</p>
<p>
<h4>What hasn't been done?</h4>
<ul>
<li>No testing for a few of techniques, for example currently no tests exist for <code>elimination_technique_2</code>, which is a variant of the elimination procedures.
<li>TT doesn't produce the best possible result.
</ul>
</p>
<p>
Though doing this seemed easy at first. But I didn't wanted to apply <code>identity_cyclic_reduction</code> every change as there can be a few instance where it not necessary to do this, perhaps because of the property of <i>words</i>.
</p>
<p>
The good thing about this week was that I could now understand the limitations that will remain after my GSoC project. The scope of Computational Group Theory is more than what I expected. Apart from that I will be leaving for my college this week stars from <i>15th</i> of <i>July</i>, perhaps I don't know how things will shift regarding time for GSoC. Let's be realistic :)
</p>
<p>
अलविदा
</p>
<h4>References</h4>
<i>
<ul>
<li>1. Derek F. Holt, Bettina Eick, Bettina, Eamonn A. O'Brien, "Handbook of computational group theory", Discrete Mathematics and its Applications (Boca Raton). Chapman & Hall/CRC, Boca Raton, FL, 2005. ISBN 1-5848-372-3 .</li>
<li>2.<a href="http://staff.itee.uq.edu.au/havas/1974h.pdf"> George Havas, "Reidemeister-Schreier program"</a></li>
</i>
<br>
</ul>
GSoC Week 62016-07-01T00:00:00+05:30https://gxyd.github.io/GSoC Week 6
<p>
First of all the good news, I have <i>passed</i> the mid-term evaluations.
I received the feedback from Kalevi, "I have had some problems with the blog posts.".
Though Kalevi, mentioned to not take the post seriously.
Well, not to say, that is definitely true. I don't claim that I will be
able to remedy this, but lets see what happens.
</p>
<p>
Kalevi, had sent me a mail, mentioning "next things to do", it included
"Cosets in Permuations group" and "Finitely Presented Abelian groups".
(its been quite sometime since that mail).
It was more of my decision to implement the topic of "presentation of subroups".
To be true, I particularly chose this topic, since that makes the output
of out work done till now, to look beautiful :) . Earlier I had a constant doubts
when I was making proposal about what it exactly means by "presentation of subgroups".
So while I read the examples from the Handbook, it became clear to me.
</p>
<p>
As to the progress in the topic, here's what we have done, I opened the PR on sunday.
This week we started with the implementation of subgroup presentations. There are
two methods to compute "presentation of a subgroup", first being called
"computing presentations on schreier generators" also called the Reidemeister Schreier
procedure. Since we have already implemented the "Todd Coxeter"
procedure, which is used as the first step in Reidemeister Schreier for coset
enumeration. It uses a routine which is called "define_schreier_generators",
Second being "computing presentation on the generators of subgroup".
Well the pseudo code is there for both the two implementations. The code of
</p>
<p>
The important part of finding the "presentation of subgroup" being simplifying
the "presentations", i.e reducing the three factors |X| (no. of subgroup generators),
|R| (no. of subgroup relators) and l (total length of subgroup relators). Though
there doesn't seem to any pseudo code available anywhere for the implementation (this makes
it quite interesting to implement). But the paper by Havas [Reidemeister Schreier program]
(http://staff.itee.uq.edu.au/havas/1974h.pdf) neatly explains the things.
</p>
<p>
Last 2 days were spent on trying to make "elimination_technique_1" work. Its still not
fully functional, since it still returns some dependent relators as a part of the presentation.
As for an example, currently Reidemeister Schreier procedure presentation works this way.
<pre>
<code>
>>> F, x, y = free_group("x, y")
>>> f = FpGroup(F, [x**2*y**2, y**-1*x*y*x**-3])
>>> H = [x]
>>> reidemeister_presentation(f, H)
([x_1], [x_1**-4, x_1**-8])
</code>
</pre>
<p>
Two things need to be fixed here. First being, removal of -ve powers of single syllable
relators, $x_1^{-4}$ -> $x_1^4$, similarly for the other relator.
Second thing being, since $x_1^4 = 0$ implies that $x_1^8 = 0$ (dependent relator) so the relator
should be removed. Perhaps the issue with this is, where should the code for checking this dependence
be introduced? Kalevi seems a bit busy these days with other project. That is not the issue. I believe there may be
something more to the simplification in the "Handbook", (have been referring to [2] for the
elimination of generators, relators and simplification of presentations).
</p>
<p>
Yesterday, I Thought of focussing on a new topic "simplification of presentations", the method
is short descripted in [2], but that is sufficient enough. It starts by checking whether any relator
is of the form $gen^n$, where $n \in \mathbb{N}$. If any such relators are found then all other relators
are processed for strings in the $gen$ known order. All string length exceeding length $n/2$ are
replaced by their shortest equivalent. Further, for even `n` strings gen$^{-n/2}$ replaced by
gen$^{n/2}$. I have written its code, perhaps it only requires a few more tests to be added
to it.
</p>
<p>
I think I will be busy with "presentation of subgroups", this week and next week as well.
</p>
<h4>References</h4>
<i>
<ul>
<li>1. Derek F. Holt, Bettina Eick, Bettina, Eamonn A. O'Brien, "Handbook of computational group theory", Discrete Mathematics and its Applications (Boca Raton). Chapman & Hall/CRC, Boca Raton, FL, 2005. ISBN 1-5848-372-3 .</li>
<li>2.<a href="http://staff.itee.uq.edu.au/havas/1973cdhw.pdf"> George Havas, "Reidemeister-Schreier program"</a></li>
</i>
<br>
</ul>
GSoC Week 52016-07-01T00:00:00+05:30https://gxyd.github.io/GSoC Week 5
<p>
Hi everyone. Here's a brief summary of 5th week of my GSoC.
</p>
<br>
<p>
In the 5th week we worked upon the implementation of Low Index Subgroups algorithm.
The basic problem dealt with by this algorithm is:
<br /><br />
<i>find all subgroups H
such that the index $|G:H|$ is at most a specified number $N > 0$.
</i>
<br /><br />
The term
"low" is used to indicate the impracticalness of solving the problem for large
$N$ values. The Handbook [1] contains the necessary pseudo code for its
implementation, in which it has been explained in a top-down approch instead
of the usual bottom-up approach.
Complexity of the algorithm: exponential.
</p>
<p>
Status update: completion of Low Index Subgroup algorithm.
The main function for calling the algorithm is <code>low_index_subgroups</code> with signature <code>(G, N, Y=[])</code>, here $G$ is the group for which we want to find the subgroups for, $N$ being a positive integer specifying the upper bound on the index value of subgroup generated, and $Y$ is optional argument specifying.
</p>
<p>
This routine also (<code>coset_enumeration_c</code> to needed this) makes use of calling <i>cyclic conjugates</i> of cyclic reductions of a set of relators, so I made a method in <code>CosetTable</code> named <code>conjugates</code>, which does this task now. We have a list $S$, which stores the coset tables for the founds subgroups. The algorithm later calls a routine called <code>descendant_subgroups</code>. One of the things being that in <code>low_index_subgroups</code> the <code>descendant_subgroups</code> routine can be called on any of the generators of inverse of generator of group $G$, though this isn't clear in the Handbook, but I some intuition to it.
</p>
<p>
descendant_subgroups($C$, $\{R_{1x}^C \}$, $R_2$, $N$)
<br><br>
try_descendant($C$, $\{R_{1x}^C\}$, $R_2$, $N$, $\alpha$, $x$, $\beta$)
</p>
<p>
Here is an example of Low Index Subgroup algorithm in work, Yay :) !!
<code><pre>
>>> from sympy.combinatorics.free_group import free_group
>>> from sympy.combinatorics.fp_groups import FpGroup, low_index_subgroups
>>> F, x, y = free_group("x, y")
>>> f = FpGroup(F, [x**2, y**3, (x*y)**4])
>>> L = low_index_subgroups(f, 10)
>>> for i in L:
... print(i.table)
[[0, 0, 0, 0]]
[[0, 0, 1, 2], [1, 1, 2, 0], [3, 3, 0, 1], [2, 2, 3, 3]]
[[0, 0, 1, 2], [2, 2, 2, 0], [1, 1, 0, 1]]
[[0, 0, 1, 2], [3, 3, 2, 0], [4, 4, 0, 1], [1, 1, 5, 4], [2, 2, 3, 5], [5, 5, 4, 3]]
[[1, 1, 0, 0], [0, 0, 1, 1]]
[[1, 1, 0, 0], [0, 0, 2, 3], [4, 4, 3, 1], [5, 5, 1, 2], [2, 2, 5, 6], [3, 3, 6, 4], [7, 7, 4, 5], [6, 6, 7, 7]]
[[1, 1, 1, 2], [0, 0, 2, 0], [3, 3, 0, 1], [2, 2, 4, 5], [5, 5, 5, 3], [4, 4, 3, 4]]
[[1, 1, 2, 3], [0, 0, 4, 5], [5, 5, 3, 0], [4, 4, 0, 2], [3, 3, 5, 1], [2, 2, 1, 4]]
</pre></code>
</p>
<p>
Things I would love to have for this algorithm is to give, a presentation in the form Magma gives the subgroup returned in the form of generators of subgroup. That is coding the <b>Reidemeister Schreier</b> and its variant algorithms.
</p>
GSoC Week 2, 32016-06-20T00:00:00+05:30https://gxyd.github.io/GSoC Week 2, 3
<p>
Hi everyone.
</p>
<br>
<br>
<p>
Here is a brief summary of what we did in the second and third week of GSoC.
</p>
<p>First of all I got late in blogging about our progress for the weeks 2, 3. Since the internet connection was disrupted(<a href="quot;https://en.wikipedia.org/wiki/Jat_reservation_agitation"quot;>reason</a>) for almost 3 weeks in my city, so in between I had to move out to some other place. But still project progress is good :)
</p>
<p>
Status update:
<ul>
<li><a href="quot;https://github.com/sympy/sympy/pull/11140"quot;>PR #11140</a> on implementation of strategies of coset enumeration has been <i>merged</i>.</li>
</ul>
</p>
<p>
We implemented the <i>Coset Enumeration</i> strategies. Suppose $G$ is defined by a finite presentation, and $H$ is a subgroup of $G$ (for $H$ we currently only list of generators which generate $H$), which is specified by words in the generators of $G$ that generate $H$. The procedure is known as coset enumeration and is one of the most fundamental methods in CGT. No algorithm (its been proved mathematically [4]) can be guaranteed to terminate for <i>coset enumeration</i>, so it can't be defined to have a fixed complexity.
</p>
<p>
<i>Coset Table</i> is equivalent to the permutation representation of the input group $G$ in its action by right multiplication on the right cosets of $H$. Beginning with the <code>Coset Table</code>, we have initialised it with various attributes in <i>SymPy</i>, most of them are instances of <code>list</code>, they are appended on the way while strategies like <i>HLT</i>, <i>Felsch</i> run over it. Contrary to what I mentioned in my last post, <code>CosetTable</code> is not a subclass of <code>list</code>.
</p>
<p>
The algorithm we have implemented is known as <i><a href="quot;https://en.wikipedia.org/wiki/Todd%E2%80%93Coxeter_algorithm"quot;>Todd-Coxeter algorithm</a></i>. The algorithm can use too much memory and time, but still memory is more important resource than time in this algorithm. This algorithm has got two major implementations:
</p>
<p>
<h4><u><i>HLT strategy</i></u></h4>
<p>
In this strategy whenever we use the C.scan_and_fill($\alpha$, $w$) for scanning the word $w$ over coset $\alpha$, routine for scanning which if the scan is incomplete makes a new definition of coset using <code>define</code> then we make new definitions to enable the scan to complete; that is, we fill in the gaps in the scan of the relator or subgroup generator. Kalevi suggested to make some modification from the original pseudo-code, which resulted in quite a few improvements, since the changes removes un-necessary scanning.
</p>
</p>
<p>
For calculating the index of $x^{-1}$, for a generator $x$, we initialised the Coset Table with a dictionary <code>A_dict_inv</code>, which has <code>(gen,index)</code> as <code>(key,value)</code> pair.
<code>
<pre>
>>> for x, index in self.A_dict.items():
... if index % 2 == 0:
... self.A_dict_inv[x] = self.A_dict[x] + 1
... else:
... self.A_dict_inv[x] = self.A_dict[x] - 1
</pre>
</code>
</p>
<br>
<p>
We changed the slicing of the Free Group elements, which now work this way.
<code>
<pre>
>>> w = x**2*y**6
>>> w[1]
x
>>> w[3]
y
</pre>
</code>
</p>
<p>
Since earlier it was only possible using the <code>.subword(i, i+1)</code> to obtain the $i_{th}$ "word".
</p>
<br>
<p>
We have now completed the <a href="quot;https://github.com/sympy/sympy/pull/11140"quot;>PR #11140</a>
We used the utf-8 encoding in <code>sympy/combinatorics/fp_groups.py</code> in its comments, which was generating the error in <code>Python2.7</code> but not in <code>Python3.4</code>
<code>
<pre>
SyntaxError: Non-ASCII character '\xce' in file /home/gaurav/Public/sympy/sympy/combinatorics/fp_groups.py
on line 79, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
</pre>
</code>
and then using the line <code># -*- coding: utf-8 -*-</code> at the top of file resolved the issue, so seems like <code>Python2.x</code> is more sensitive to such issues.
</p>
<p>There was one error in the implemted code:
<code>
<pre>
>>> from sympy.combinatorics.free_group import free_group
>>> from sympy.combinatorics.fp_groups import FpGroup, coset_enumeration_r, CosetTable
>>> F, x, y = free_group("x, y")
>>> f = FpGroup(F, [x**2, y**3, (x*y)**3])
>>> Y = [x*y]
>>> C = coset_enumeration_r(f, Y)
>>> C.table # this will return the table
</pre>
</code>
</p>
<p>
As for refinement, I will paste another one.
</p>
<p>
<code>
<pre>
# these are the steps that happen internally
>>> C = CosetTable(f, Y)
>>> C.scan_and_fill(0, x*y)
>>> C.scan_and_fill(0, x**2)
>>> C.scan_and_fill(0, y**3)
>>> C.scan_and_fill(0, (x*y)**3)
# till now coset table is fine.
# here the coset table returned is wrong.
</pre>
</code>
</p>
<p>
In the implementation of <code>scan_and_fill</code> the implemened code differed from that in the book in one significant aspect. In the book, <code>scan_and_fill</code> looped until it filled the $\alpha$ row in the table. ("Made a new definition and continue with scan."). While the implemented code returned after one definition, the error occured since I tried removing the while loop (some testing purpose). Then we also added some "examples" from [2].
</p>
<i><u><h4>Felsch strategy</h4></u></i>
<p>
In this we first find the first undefined coset $\alpha$, in this instead of seeing ahead by making use of <code>lookahead</code>, we make <b>deductions</b>, which are put in a <code>deduction_stack</code> (a <code>list</code> instance which behaves a <i>stack</i>), which contains the pair $(\alpha, x)$, whenever a new <b>definition</b> or a <b>deduction</b> is made, this reduces the number of un-necessary cosets made (loweing the memory use at the cost of time).
</p>
<p>Though we have made use of <code>CosetTableDefaultMaxLimit = 409600</code> (similar to that in <i>GAP</i>), till now I haven't found a single example which would exhaust this much memory in our implementation, every one just seems to take too much of time.
</p>
<p>
Python utilities learned on the way:
<ul>
<li>At one point we had to make a list of generator and inverse of generators of a finitely presented groups i.e <code>A</code> for a <code>CosetTable</code>, I did a bit of searching a arrived at using the <a href="quot;https://docs.python.org/2/library/itertools.html#itertools.chain.from_iterable"quot;><code>chain.from_iterable</code></a> from the <code>itertools</code> which works as follows:
<code>
<pre>
>>> from itertools import chain
>>> list(chain.from_iterable((x**2, x**3) for x in range(4)))
[0, 0, 1, 1, 4, 8, 9, 27]
</pre>
</code>
</li>
<li>
Use of <code>product</code> routine, since in <code>coset enumeration</code>, we often iterate over $w \in Y$ and $x \in A$.
</li>
<li>
In <code>Python2.x</code> a <code>list</code> instance doesn't have a <code>copy</code> attribute, so <code>list()</code> function or <i>slicing</i> is used to make a shallow copy. [3]
</li>
</ul>
</p>
<p>At the end of the post, here's one awesome small example of <code>coset enumeration</code> using the <i>HLT</i> strategy. Here is how the code works!! :)
<code>
<pre>
In[1]: from sympy import *
In[2]: from sympy.combinatorics.free_group import free_group
In[3]: from sympy.combinatorics.fp_groups import FpGroup, CosetTable, coset_enumeration_r
In[4]: F, x, y = free_group("x, y")
In[5]: f = FpGroup(F, [x**2, y**3, (x*y)**4])
In[6]: C = coset_enumeration_r(f, [x])
In[7]: C.table
Out[7]:[[0, 0, 1, 2],
[3, 3, 2, 0],
[6, 6, 0, 1],
[1, 1, 4, 10],
[5, 5, 10, 3],
[4, 4, 6, 7],
[2, 2, 7, 5],
[8, 8, 5, 6],
[7, 7, 9, 12],
[10, 10, 12, 8],
[9, 9, 3, 4],
[None, 10, 12, None],
[12, 12, 8, 9],
[None, 12, 8, 9],
[7, None, None, 13]]
In[8]: C.compress()
In[9]: C.standardize()
In[10]: C.table
Out[10]: [[0, 0, 1, 2],
[3, 3, 2, 0],
[4, 4, 0, 1],
[1, 1, 5, 6],
[2, 2, 7, 8],
[8, 8, 6, 3],
[9, 9, 3, 5],
[10, 10, 8, 4],
[5, 5, 4, 7],
[6, 6, 11, 10],
[7, 7, 9, 11],
[11, 11, 10, 9]]
</pre>
</code>
</p>
<p>
My mentor, Kalevi, has been very much supportive, when I informed him about my possible abscence (due to internet unavailability), he even sent me a mail about the <i>things we could do next</i>, even if I am offline.
So here they are: Cosets in Permutation Groups, Finitely presented abelian groups.
</p>
<h4>References</h4>
<i>
<ul>
<li>1. Derek F. Holt, Bettina Eick, Bettina, Eamonn A. O'Brien, "Handbook of computational group theory", Discrete Mathematics and its Applications (Boca Raton). Chapman & Hall/CRC, Boca Raton, FL, 2005. ISBN 1-5848-372-3 .</li>
<li>2. John J. Cannon, Lucien A. Dimino, George Havas and Jane M. Watson, Implementation and Analysis of the Todd-Coxeter Algorithm</li>
<li>3. https://mail.python.org/pipermail/tutor/2006-November/051189.html</li>
<li>4. http://www.gap-system.org/Manuals/doc/ref/chap47.html</li>
</i>
<br>
</ul>
GSoC Week 12016-05-29T00:00:00+05:30https://gxyd.github.io/GSoC Week 1
<p>
Hi everyone.
</p>
<br>
<br>
<p>
Here is a brief summary of what we have been doing for the first week of GSoC.
</p>
<p>
In last week we opened the <a href="https://github.com/sympy/sympy/pull/11140">PR #11140</a> for working on implementing the Finitely Presented Groups and Coset Enumeration. Implementing the Coset Enumeration first understanding how the routine mentioned in [1] interact with each other. Since The different routines being: <code>define</code>, <code>scan</code>, <code>coincidence</code>, <code>merge</code>, <code>rep</code>. Most of these methods have different versions as well, which can be made to be suitable for a particular class of groups.
</p>
<p>
<code>Coset Table</code>: We represented it using list of lists data structure, inner lists are of fixed length, twice the number of generators, the outer list can grow as much as needed. We started with writing code for the <code>define</code>, <code>scan</code> routines. There was one typo in [1] for <code>scan</code> routine, which I somehow intuitively passed initially while writing code from pseudo-code, but came across it when reading the pseudo-code again. (I didn't expected the book to contain such a type in pseudo-code). Intially we started with <code>-1</code> as an entry for undefined slots but since <code>-1</code> may lead to problems as Python will accept it as an index with no error indications, allowing the bugs to pass silently. So we chose <code>None</code> as a better option to opt for.
</p>
<p>
We wanted to make sure, these implemeted methods work as expected, so I wrote extensive tests (currently in doctests), 4 of which have been taken from [1] while one from the original Todd Coxeter paper [2].
</p>
<p>
Just yesterday we decided to make <code>Coset Table</code> a <code>class</code>, since every <code>Coset Table</code> in itself has certain attributes which are changed along the execution of the Enumeration, which can be better represented by a <code>class</code>. It's struture is be something like<br><br>
<code>
<pre>
class CosetTable(list):
def __init__(self, fp_grp, subgroup):
self.fp_group = fp_grp
self.subgroup = subgroup
self._A = list(chain.from_iterable((gen, gen**-1)
for gen in self.fp_group.generators))
self.append([None]*len(self.A))
@property
def is_complete(self):
for coset in self:
for res in coset:
if res is None:
return False
return True
# other methods
</pre>
</code>
</p>
<p>
On the other side we are working on <a href="https://github.com/sympy/sympy/pull/11150">PR#11150</a>, which deals with implementation of <code>FreeAbelianGroup</code>, it wouldn't be tough to get along with this PR, since it is just similar to the previously implemented <code>FreeGroup</code>, with <code>dict</code> as its data structure.
</p>
<p>
<h4>For next week</h4>
<ul>
<li>Complete the <code>Coset Table</code> PR, i.e implement the different strategies of Felsch, HLT. I am pretty sure, this task would take more than 1 week, since there are whole lot of other strategies which if we decide to implement would take up a lot of time, even the <code>Lookahead</code> version of Todd Coxeter is there, which specifies a whole new data-structure for different compoents involved in Enumeration.</li>
<li>Later, implement different methods for <code>FpGroup</code>.</li>
</ul>
</p>
<p>
Anyway, I'm really enthusiastic about my project and hope that we'll have some nice and reasonably fast algorithms in CGT by the end of the summer!
</p>
<h4>References</h4>
<i>
<ul>
<li>1. Derek F. Holt, Bettina Eick, Bettina, Eamonn A. O'Brien, "Handbook of computational group theory";, Discrete Mathematics and its Applications (Boca Raton). Chapman & Hall/CRC, Boca Raton, FL, 2005. ISBN 1-5848-372-3 .</li>
<li>2. A practical method for enumerating cosets of a finite abstract group by J. A. TODD (University of Manchester), and H.S.M. Coxeter (University of Cambridge)</li>
</i>
<br>
</ul>
</div>
</article>
</div>
</div>
</div>
Community Bonding period ends, Coding period starts2016-05-23T00:00:00+05:30https://gxyd.github.io/Community Bonding period ends, starts Coding period
<p>
The Community bonding period comes to an end now. First of all considering the issues described in the last post:
<ul>
<li>
Aaron created a new channel for our GSoC project discussion, <a href="https://gitter.im/sympy/GroupTheory">sympy/GroupTheory</a>.
</li>
<li>
I have also added rss-feed in my blog.
</li>
<li>
As for time of meeting, me and Kalevi often have discussion on the gitter channel, but since of quite a bit differene in timings between me and Aaron (I tend to sleep early at 11 PM IST). We three haven't been able to together have a meeting. Though Aaron suggested "Kalevi is the primary mentor, so if you have to meet without me that is fine". I also think that's not too big of an issue now, but his opinion has always helped, since he has best knowledge of sympy core.
</li>
</ul>
</p>
<p><br>
In the past few weeks I wasn't too much productive, since I had a touch of fever, anyways I am okay now. We have now completed the implementation of the <code>FreeGroup</code> class in <a href="https://github.com/sympy/sympy/pull/10350">PR #10350</a>. I started working on the PR back in January but I halted, since of my semester classes. <code>FreeGroup</code> is quite similar to the <code>PolyRing</code> implemented in <code>sympy.polys.rings.py</code>. We first started with the list of tuples as the data structure for the <code>FreeGroupElm</code>, where each tuple being <code>(index, exp)</code>, but since of the mutable nature of lists, Kalevi suggested to go with tuple of tuples. Also as tuples are probably more efficient as there is no 'housekeeping' overhead. Also changed the element from <code>(index, exp)</code> --> <code>(symbol, exp)</code>.
</p>
<p><br>
Implementing <code>FreeGroupElm</code> deals elegantly in such a way that it can't be independently created in a public interface. The reason being: every <code>FreeGroupElm</code> is in itself created only by the <code>dtype</code> method of <code>FreeGroup</code> class. The assignment is as follows:
<br>
<code>obj.dtype = type("FreeGroupElm", (FreeGroupElm,), {"group": obj})</code>
<br>.
Its sort of an advanced usage of <code>type</code> function as a <a href="http://www.stackoverflow.com/questions/100003/what-is-a-metaclass-in-python">metaclass</a>.
</p>
<p><br>
Currently the printing code of <code>latex</code> and <code>pprint</code> for <code>FreeGroupElm</code> is a little hacky. I need to work on that as well.
</p>
<br>
<p>
<b><u>Plan for Next few weeks</u></b>
<br><br>
Though according to my <a href="https://github.com/sympy/sympy/wiki/GSoC-2016-Application-Gaurav-Dhingra:-Group-Theory#Proposed_Timeline">proposal timeline</a>, we described to go with implementation of other algebraic structures i.e <code>Magma</code>, <code>SemiGroup</code>, <code>Monoid</code>. But we will next move onto <b>"Coset Enumeration"</b>. It is going to be a big task. That is harder and more important than other algebraic structures. Timline states it to be 5 week task, thats almost half the GSoC coding period. Well how do we go about that? I think of studying the mathematics in parallel with the implementation.
</p>
<p>
We have created a PR for implementation of Finitely Presented Group <a href="https://github.com/sympy/sympy/pull/11140">#11140</a>. Not much code has been added here. Paper on Coset Enumeration using <a href="http://staff.itee.uq.edu.au/havas/1973cdhw.pdf">Implementation and Analysis of Todd Coxeter Algorithm</a> (by John J. Cannon, George Havas), and other paper being the original paper by Todd and Coxeter, "A practical method for enumerating cosets of a finite abstract group" are the ones I am reading. As for the implementation of Todd Coxeter, we will be following the methods described in the book "Handbook of Computational Group Theory" by Derek F. Holt.
</p>
<p>
Also now the "official" coding period begins, good luck to everyone.
</p>
GSoC 2016 Phase I : Proposal, Acceptance2016-05-02T00:00:00+05:30https://gxyd.github.io/GSoC 2016 Phase I : Proposal, Acceptance
<p>Hello, I'm Gaurav Dhingra a 3rd year undergraduate student at IIT Roorkee, my proposal on Group Theory with <i>SymPy</i> has been accepted as a part of <a href="https://summerofcode.withgoogle.com/">Google Summer of Code</a></p>
<p><br>
First, a little bit about <a href="http://www.sympy.org/">SymPy</a>, a <i>Computer Algebra System</i> (CAS) written entirely in Python. SymPy 1.0 was released about 2 months ago, <i>Sympy</i> has been created by hundreds of contributors starting from 2006.
I will be working on Group Theory over the summer, for the next 3 months, to implement Computational Group Theory (CGT) and Group Theory, which are parts of mathematics I particularly enjoy. You can view my project proposal <a href="https://github.com/sympy/sympy/wiki/GSoC-2016-Application-Gaurav-Dhingra:-Group-Theory">GSoC 2016 Application Gaurav Dhingra: Group Theory</a>. Until a few days ago I was pretty busy with my exams, but in the next few weeks I will go over working on the project. I will particularly focus on Finite and Finitely Presented Groups.
</p>
<p><br>
I hope that I'll be able to implement everything that I promised in it. Moving onto the ongoing community bonding. Since I am very well acquitted with the workflow of SymPy, I can get straight to few important things, which i will do in the next few days.
<br><br>
This includes things like:
<ul>
<li>
Setting up a blog with RSS feed i.e this blog in which I am supposed to add an RSS feed functionality.
</li>
<li>
Talking to my mentors regarding the time, and place of chat on internet, we differ by almost 5hrs. Time wouldn't be an issue, since seeing from past, I haven't faced such difficulty as both me and my mentor work for almost the same time intervals. From the GSoC 2015 discussions, I remember that Ondrej tries to make sure everyone knows what time student-mentor meet, since of different time zones.
</li>
<li>
In the past we have had discussion on my private gitter channel <a href=<https://gitter.im/gxyd/group_theory_implementation">Group Theory Implementation</a>. <i>Would it be wise to continue code discussions there?</i>. Since no one can be added in the channel without my permission.
</li>
</ul>
</p>
<p><br>
One thing that has been a hell of a lot annoying has been the GSoC mailing list, it's a lot distracting. I changed list settings to abridged daily updates because I was getting like 50 mails every day and that too about some really stupid and irrelevant things. But yeah like whatever.</p>
<p><br>
<i>"LESS TALK, MORE CODE"</i> is the policy that I always tend to follow (not for blog!!). I will try my best to implement it in a strict way this summer. I have seen this policy working fine for me, mostly first I start writing question in a message box to my mentor, and then i think more about it myself and in the end I come up with a solution on my own, instead of asking.
</p>
<p><br>
I'm quite sure that I will write more than enough blog posts about my project during the summers. Since I enjoy writing and that too regarding things that occupy larger part of my day.
</p>
<p><br>
I'd like to thank all the people involved with contributions to <i>SymPy</i>. My special thanks to my mentor - <a href="https://github.com/jksuom">Kalevi Suominen</a> and my co-mentor - <a href="https://github.com/asmeurer">Aaron Meurer</a> for all the suggestions while making my proposal, and showing faith and enthusiasm in my ability and my proposal.
</p>