Ticket #8589: trac_8589_feature_group_algebras_vf.patch

File trac_8589_feature_group_algebras_vf.patch, 15.9 KB (added by vferay, 11 years ago)
  • sage/categories/algebra_functor.py

    # HG changeset patch
    # User Valentin Feray <feray at labri.fr>
    # Date 1287155720 -7200
    # Node ID a74eab6e29fee2a80754db03a146113dafb0700c
    # Parent  0eec06f001782d0d73c763f5e2545b04cf737577
    #8589 : added some features on group algebras
    
    diff --git a/sage/categories/algebra_functor.py b/sage/categories/algebra_functor.py
    a b def Algebras(self, base_ring): 
    3434        sage: Monoids().Algebras(QQ)
    3535        Category of monoid algebras over Rational Field
    3636
    37         sage: Groups().Algebras(QQ) # todo: update once there will be a category for group algebras
    38         Category of monoid algebras over Rational Field
     37        sage: Groups().Algebras(QQ)
     38        Category of group algebras over Rational Field
    3939
    4040        sage: M = Monoids().example(); M
    4141        An example of a monoid: the free monoid generated by ('a', 'b', 'c', 'd')
  • sage/categories/coalgebras.py

    diff --git a/sage/categories/coalgebras.py b/sage/categories/coalgebras.py
    a b class Coalgebras(Category_over_base_ring 
    7474            return tensor([self, self])
    7575
    7676        @abstract_method
     77        def counit(self, x):
     78            """
     79            Returns the counit of x.
     80
     81            Eventually, there will be a default implementation,
     82            delegating to the overloading mechanism and forcing the
     83            conversion back
     84
     85            EXAMPLES::
     86
     87                sage: A = HopfAlgebrasWithBasis(QQ).example(); A
     88                An example of Hopf algebra with basis: the group algebra of the Dihedral group of order 6 as a permutation group over Rational Field
     89                sage: [a,b] = A.algebra_generators()
     90                sage: a, A.counit(a)
     91                (B[(1,2,3)], 1)
     92                sage: b, A.counit(b)
     93                (B[(1,3)], 1)
     94
     95            TODO: implement some tests of the axioms of coalgebras, bialgebras
     96            and Hopf algebras using the counit.
     97            """
     98           
     99
     100        @abstract_method
    77101        def coproduct(self, x):
    78102            """
    79103            Returns the coproduct of x.
    class Coalgebras(Category_over_base_ring 
    111135            """
    112136            return self.parent().coproduct(self)
    113137
     138        def counit(self):
     139            """
     140            Returns the counit of ``self``
     141
     142            EXAMPLES::
     143
     144                sage: A = HopfAlgebrasWithBasis(QQ).example(); A
     145                An example of Hopf algebra with basis: the group algebra of the Dihedral group of order 6 as a permutation group over Rational Field
     146                sage: [a,b] = A.algebra_generators()
     147                sage: a, a.counit()
     148                (B[(1,2,3)], 1)
     149                sage: b, b.counit()
     150                (B[(1,3)], 1)
     151            """
     152            return self.parent().counit(self)
     153
    114154    class TensorProducts(TensorProductsCategory):
    115155
    116156        @cached_method
  • sage/categories/coalgebras_with_basis.py

    diff --git a/sage/categories/coalgebras_with_basis.py b/sage/categories/coalgebras_with_basis.py
    a b class CoalgebrasWithBasis(Category_over_ 
    4848        @abstract_method(optional = True)
    4949        def coproduct_on_basis(self, i):
    5050            """
    51             The product of the algebra on the basis (optional)
     51            The coproduct of the algebra on the basis (optional)
    5252
    5353            INPUT:
    5454             - ``i``: the indices of an element of the basis of self
    class CoalgebrasWithBasis(Category_over_ 
    6565                sage: A.coproduct_on_basis(a)
    6666                B[(1,2,3)] # B[(1,2,3)]
    6767            """
     68       
     69        @abstract_method(optional = True)
     70        def counit_on_basis(self, i):
     71            """
     72            The counit of the algebra on the basis (optional)
     73
     74            INPUT:
     75             - ``i``: the indices of an element of the basis of self
     76
     77            Returns the counit of the corresponding basis elements
     78            If implemented, the counit of the algebra is defined
     79            from it by linearity.
     80
     81            EXAMPLES::
     82
     83                sage: A = HopfAlgebrasWithBasis(QQ).example(); A
     84                An example of Hopf algebra with basis: the group algebra of the Dihedral group of order 6 as a permutation group over Rational Field
     85                sage: (a, b) = A._group.gens()
     86                sage: A.counit_on_basis(a)
     87                1
     88            """
    6889
    6990    class ParentMethods:
    7091        @lazy_attribute
    7192        def coproduct(self):
    7293            """
    73             If :meth:`.coproduct_basis` is available, construct the
     94            If :meth:`.coproduct_on_basis` is available, construct the
    7495            coproduct morphism from ``self`` to ``self`` `\otimes`
    7596            ``self`` by extending it by linearity
    7697
    class CoalgebrasWithBasis(Category_over_ 
    91112                # should there be a method self.coproduct_hom_category?
    92113                return Hom(self, tensor([self, self]), ModulesWithBasis(self.base_ring()))(on_basis = self.coproduct_on_basis)
    93114
     115        @lazy_attribute
     116        def counit(self):
     117            """
     118            If :meth:`.counit_on_basis` is available, construct the
     119            counit morphism from ``self`` to ``self`` `\otimes`
     120            ``self`` by extending it by linearity
     121
     122            EXAMPLES::
     123
     124                sage: A = HopfAlgebrasWithBasis(QQ).example(); A
     125                An example of Hopf algebra with basis: the group algebra of the Dihedral group of order 6 as a permutation group over Rational Field
     126                sage: [a,b] = A.algebra_generators()
     127                sage: a, A.counit(a)
     128                (B[(1,2,3)], 1)
     129                sage: b, A.counit(b)
     130                (B[(1,3)], 1)
     131
     132            """
     133            if self.counit_on_basis is not NotImplemented:
     134                return self.module_morphism(self.counit_on_basis,codomain=self.base_ring())
     135
    94136    class ElementMethods:
    95137        pass
  • sage/categories/examples/hopf_algebras_with_basis.py

    diff --git a/sage/categories/examples/hopf_algebras_with_basis.py b/sage/categories/examples/hopf_algebras_with_basis.py
    a b class MyGroupAlgebra(CombinatorialFreeMo 
    109109        g = self.monomial(g)
    110110        return tensor([g, g])
    111111
     112    def counit_on_basis(self, g):
     113        r"""
     114        Counit, on basis elements, as per :meth:`HopfAlgebrasWithBasis.ParentMethods.counit_on_basis`.
     115
     116        The counit on the basis elements is 1.
     117
     118        EXAMPLES::
     119
     120            sage: A = HopfAlgebrasWithBasis(QQ).example()
     121            sage: (a, b) = A._group.gens()
     122            sage: A.counit_on_basis(a)
     123            1
     124        """
     125        return self.base_ring().one()
     126
    112127    def antipode_on_basis(self, g):
    113128        r"""
    114129        Antipode, on basis elements, as per :meth:`HopfAlgebrasWithBasis.ParentMethods.antipode_on_basis`.
  • sage/categories/finite_groups.py

    diff --git a/sage/categories/finite_groups.py b/sage/categories/finite_groups.py
    a b class FiniteGroups(Category): 
    8282
    8383                sage: A = AlternatingGroup(4)
    8484                sage: A.semigroup_generators()
    85                 [(1,2,3), (2,3,4)]
     85                Family ((1,2,3), (2,3,4))
    8686            """
    8787            return self.group_generators()
    8888
  • sage/categories/groups.py

    diff --git a/sage/categories/groups.py b/sage/categories/groups.py
    a b Groups 
    1414from sage.misc.cachefunc import cached_method
    1515from sage.categories.category import Category
    1616from sage.categories.monoids import Monoids
     17from sage.categories.algebra_functor import AlgebrasCategory
    1718
    1819class Groups(Category):
    1920    """
    class Groups(Category): 
    4243        """
    4344        return [Monoids()]
    4445
     46    def example(self):
     47        from sage.rings.rational_field import QQ 
     48        from sage.groups.matrix_gps.general_linear import GL
     49        """
     50        EXAMPLES::
     51
     52            sage: Groups().example()
     53            General Linear Group of degree 4 over Rational Field
     54        """
     55        return GL(4,QQ)
     56
    4557    class ParentMethods:
    4658
    4759        def group_generators(self):
     60            from sage.sets.family import Family
    4861            """
    4962            Returns group generators for self.
    5063
    class Groups(Category): 
    5568
    5669                sage: A = AlternatingGroup(4)
    5770                sage: A.group_generators()
    58                 [(1,2,3), (2,3,4)]
     71                Family ((1,2,3), (2,3,4))
    5972            """
    60             return self.gens()
     73            return Family(self.gens())
    6174
    6275        def _test_inverse(self, **options):
    6376            """
    class Groups(Category): 
    6982
    7083                sage: G = SymmetricGroup(3)
    7184                sage: G._test_inverse()
    72 
    7385            """
    7486            tester = self._tester(**options)
    7587            for x in tester.some_elements():
    class Groups(Category): 
    320332    class ElementMethods:
    321333        ## inv(x), x/y
    322334        pass
     335
     336    class Algebras(AlgebrasCategory):
     337
     338        def extra_super_categories(self):
     339            """
     340            EXAMPLES::
     341
     342                sage: Groups().Algebras(QQ).super_categories()
     343                [Category of hopf algebras with basis over Rational Field, Category of monoid algebras over Rational Field]
     344
     345                sage: Groups().example().algebra(ZZ).categories()
     346                [Category of group algebras over Integer Ring, Category of hopf algebras with basis over Integer Ring, Category of bialgebras with basis over Integer Ring, Category of coalgebras with basis over Integer Ring, Category of hopf algebras over Integer Ring, Category of bialgebras over Integer Ring, Category of coalgebras over Integer Ring, Category of monoid algebras over Integer Ring, Category of semigroup algebras over Integer Ring, Category of algebras with basis over Integer Ring, Category of algebras over Integer Ring, Category of rings, Category of rngs, Category of semirings, Category of monoids, Category of semigroups, Category of magmas, Category of set algebras over Integer Ring, Category of modules with basis over Integer Ring, Category of modules over Integer Ring, Category of bimodules over Integer Ring on the left and Integer Ring on the right, Category of left modules over Integer Ring, Category of right modules over Integer Ring, Category of commutative additive groups, Category of commutative additive monoids, Category of commutative additive semigroups, Category of additive magmas, Category of sets, Category of sets with partial maps, Category of objects]
     347            """
     348            from sage.categories.hopf_algebras_with_basis import HopfAlgebrasWithBasis
     349            return [HopfAlgebrasWithBasis(self.base_ring())]
     350
     351        class ParentMethods:
     352
     353            def _repr_(self):
     354                r"""
     355                Print the string representation of `self`. For the moment, this
     356                function is not used because it is defined in a higher category.
     357                """
     358                return 'Group algebra of %s over %s'%(self.basis().keys(),self.base_ring())
     359
     360            def coproduct_on_basis(self, g):
     361                r"""
     362                Returns the coproduct of the element of the basis (which are
     363                group-like). Used to compute the coproduct of any element.
     364
     365                EXAMPLES::
     366
     367                    sage: A=CyclicPermutationGroup(6).algebra(ZZ);A
     368                    Group algebra of Cyclic group of order 6 as a permutation group over Integer Ring
     369                    sage: g=CyclicPermutationGroup(6).an_element();g
     370                    (1,2,3,4,5,6)
     371                    sage: A.coproduct_on_basis(g)
     372                    B[(1,2,3,4,5,6)] # B[(1,2,3,4,5,6)]
     373                    sage: a=A.an_element();a
     374                    B[()] + 3*B[(1,2,3,4,5,6)] + 3*B[(1,3,5)(2,4,6)]
     375                    sage: a.coproduct()
     376                    B[()] # B[()] + 3*B[(1,2,3,4,5,6)] # B[(1,2,3,4,5,6)] + 3*B[(1,3,5)(2,4,6)] # B[(1,3,5)(2,4,6)]
     377                """
     378                from sage.categories.tensor import tensor
     379                g = self.term(g)
     380                return tensor([g, g])
     381
     382            def antipode_on_basis(self,g):
     383                r"""
     384                Returns the antipode of the element of the basis (which are group-
     385                like). Used to compute the antipode of any element.
     386
     387                EXAMPLES::
     388
     389                    sage: A=CyclicPermutationGroup(6).algebra(ZZ);A
     390                    Group algebra of Cyclic group of order 6 as a permutation group over Integer Ring
     391                    sage: g=CyclicPermutationGroup(6).an_element();g
     392                    (1,2,3,4,5,6)
     393                    sage: A.antipode_on_basis(g)
     394                    B[(1,6,5,4,3,2)]
     395                    sage: a=A.an_element();a
     396                    B[()] + 3*B[(1,2,3,4,5,6)] + 3*B[(1,3,5)(2,4,6)]
     397                    sage: a.antipode()
     398                    B[()] + 3*B[(1,5,3)(2,6,4)] + 3*B[(1,6,5,4,3,2)]
     399                """
     400                return self.term(g**(-1))
     401           
     402            def counit_on_basis(self,g):
     403                r"""
     404                Returns the counit of the element of the basis, that is 1 in a
     405                group algebra.
     406
     407                EXAMPLES::
     408
     409                    sage: A=CyclicPermutationGroup(6).algebra(ZZ);A
     410                    Group algebra of Cyclic group of order 6 as a permutation group over Integer Ring
     411                    sage: g=CyclicPermutationGroup(6).an_element();g
     412                    (1,2,3,4,5,6)
     413                    sage: A.counit_on_basis(g)
     414                    1
     415                """
     416                return self.base_ring().one()
     417           
     418            def counit(self,x):
     419                r"""
     420                Returns the counit of the element x, that is the sum of the
     421                coefficient in a group algebra.
     422
     423                EXAMPLES::
     424
     425                    sage: A=CyclicPermutationGroup(6).algebra(ZZ);A
     426                    Group algebra of Cyclic group of order 6 as a permutation group over Integer Ring
     427                    sage: a=A.an_element();a
     428                    B[()] + 3*B[(1,2,3,4,5,6)] + 3*B[(1,3,5)(2,4,6)]
     429                    sage: a.counit()
     430                    7
     431                """
     432                return sum(x.coefficients())
     433
     434        class ElementMethods:
     435            pass
  • sage/categories/monoids.py

    diff --git a/sage/categories/monoids.py b/sage/categories/monoids.py
    a b class Monoids(Category): 
    329329                    3*B['']
    330330                """
    331331                return self.basis().keys().one()
     332
     333            def an_element(self):
     334                r"""
     335                Returns an element of `self`. For the moment, this function is not
     336                used because it is defined in a higher category
     337                """
     338                return (2*self(self.basis().keys().an_element())+
     339                        self.base_ring().an_element * self.one())
     340
     341
     342        class ElementMethods:
     343           
     344            def is_central(self):
     345                r"""
     346                Returns True if the element is central and False otherwise.
     347               
     348                EXAMPLES::
     349   
     350                    sage: A=DihedralGroup(5).algebra(QQ)
     351                    sage: sum(i for i in A.basis()).is_central()
     352                    True
     353                """
     354                gen=self.parent().algebra_generators()
     355                for i in gen:
     356                    if i*self != self*i:
     357                        return False
     358                return True
     359
     360
  • sage/categories/semigroups.py

    diff --git a/sage/categories/semigroups.py b/sage/categories/semigroups.py
    a b class Semigroups(Category): 
    431431
    432432            @cached_method
    433433            def algebra_generators(self):
     434                from sage.sets.family import Family
    434435                r"""
    435436                The generators of this algebra, as per
    436437                :meth:`Algebras.ParentMethods.algebra_generators()