Le dimanche 22 janvier 2012 à 11:37 -0800, mmarco a écrit : > I am trying to implement free groups, finitely presented groups and > braid groups in sage. So far i have writen a proof of concept for the > free groups (see ticket 12339), but i don't have any experience with > the category and coercion frameworks. > > Any feedback and/or colaboration would be most welcome.
Hello, Some veterans of the sage combinat community have probably already "think" about adding free groups and braid groups in Sage. It was perhaps discussed during the sage-gap_chevie meeting last year, I don't remember. For this reason, I also send this topic to sage-combinat-devel. You should look at some examples already in Sage (and there is not enough example for now...). I added an example of group using the category framework some time ago (with an expert under my shoulder (my thesis advisor : Nicolas Thiéry)). Categories are in the file : sage/categories/...your...category...py and some of these categories have example in the file : sage/categories/examples/...your...category...py You should look in examples how to initialize properly the category of the parent and where place the element class, look also at the conventional name of methods (I think identity_element() should be one()), ... A nice entrance point for the categories is: sage: sage.categories.primer? I can assure you that the authors will be VERY VERY happy to get some comments about this primer, feel free to post them on sage-combinat-devel. The first time with categories will cost you some time to adapt your code to the framework but it produced a more robust code, more factorized code and better tests. Look at the Dihedral groups in the file : sage/categories/examples/finite_coxeter_groups.py 250 lines allows you to benefit of functorial construction as follows (here the group algebra of a group): **************************************************** sage: D5 = DihedralGroup(5); D5 Dihedral group of order 10 as a permutation group sage: TestSuite(D5).run(verbose=True) running ._test_an_element() . . . pass running ._test_associativity() . . . pass running ._test_category() . . . pass running ._test_elements() . . . Running the test suite of self.an_element() running ._test_category() . . . pass running ._test_eq() . . . pass running ._test_not_implemented_methods() . . . pass running ._test_pickling() . . . pass pass running ._test_elements_eq() . . . pass running ._test_enumerated_set_contains() . . . pass running ._test_enumerated_set_iter_cardinality() . . . pass running ._test_enumerated_set_iter_list() . . . pass running ._test_eq() . . . pass running ._test_inverse() . . . pass running ._test_len() . . . pass running ._test_not_implemented_methods() . . . pass running ._test_one() . . . pass running ._test_pickling() . . . pass running ._test_prod() . . . pass running ._test_some_elements() . . . pass sage: GA_D5 = D5.algebra(QQ); GA_D5 Group algebra of Dihedral group of order 10 as a permutation group over Rational Field sage: p = GA_D5.an_element(); p B[()] + 2*B[(2,5)(3,4)] + 3*B[(1,2)(3,5)] + B[(1,2,3,4,5)] sage: (p+1)^2 17*B[()] + 11*B[(2,5)(3,4)] + 14*B[(1,2)(3,5)] + 10*B[(1,2,3,4,5)] + 3*B[(1,3)(4,5)] + B[(1,3,5,2,4)] + 6*B[(1,5,4,3,2)] + 2*B[(1,5)(2,4)] sage: TestSuite(GA_D5).run(verbose=True) running ._test_additive_associativity() . . . pass running ._test_an_element() . . . pass running ._test_associativity() . . . pass running ._test_category() . . . pass running ._test_distributivity() . . . pass running ._test_elements() . . . Running the test suite of self.an_element() running ._test_category() . . . pass running ._test_eq() . . . pass running ._test_not_implemented_methods() . . . pass running ._test_pickling() . . . pass pass running ._test_elements_eq() . . . pass running ._test_eq() . . . pass running ._test_len() . . . pass running ._test_not_implemented_methods() . . . pass running ._test_one() . . . pass running ._test_pickling() . . . pass running ._test_prod() . . . pass running ._test_some_elements() . . . pass running ._test_zero() . . . pass **************************************************** Checking the TestSuite is an excellent way to verify you correctly use the category framework. (necessary but not sufficient) This was just a small tour about the categories and some expert will probably tell better advises than me. Also sorry for my English. Cheers, Nicolas Borie. -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org