示例#1
0
文件: raag.py 项目: swewers/mein_sage
    def __init__(self, R, A):
        """
        Initialize ``self``.

        TESTS::

            sage: C4 = graphs.CycleGraph(4)
            sage: A = groups.misc.RightAngledArtin(C4)
            sage: H = A.cohomology()
            sage: TestSuite(H).run()
        """
        if R not in Fields():
            raise NotImplementedError(
                "only implemented with coefficients in a field")
        self._group = A

        names = tuple(['e' + name[1:] for name in A.variable_names()])
        from sage.graphs.independent_sets import IndependentSets
        from sage.sets.finite_enumerated_set import FiniteEnumeratedSet
        indices = [tuple(ind_set) for ind_set in IndependentSets(A._graph)]
        indices = FiniteEnumeratedSet(indices)
        cat = AlgebrasWithBasis(
            R.category()).Super().Graded().FiniteDimensional()
        CombinatorialFreeModule.__init__(self,
                                         R,
                                         indices,
                                         category=cat,
                                         prefix='H')
        self._assign_names(names)
示例#2
0
    def __init__(self, R, names):
        r"""
        Initialize ``self``.

        EXAMPLES::

            sage: F = ShuffleAlgebra(QQ, 'xyz'); F
            Shuffle Algebra on 3 generators ['x', 'y', 'z'] over Rational Field
            sage: TestSuite(F).run()

        TESTS::

            sage: ShuffleAlgebra(24, 'toto')
            Traceback (most recent call last):
            ...
            TypeError: argument R must be a ring
        """
        if R not in Rings():
            raise TypeError("argument R must be a ring")
        self._alphabet = names
        self.__ngens = self._alphabet.cardinality()
        CombinatorialFreeModule.__init__(self,
                                         R,
                                         Words(names, infinite=False),
                                         latex_prefix="",
                                         category=(AlgebrasWithBasis(R),
                                                   CommutativeAlgebras(R),
                                                   CoalgebrasWithBasis(R)))
示例#3
0
    def __init__(self, R, n, names):
        """
        The free algebra on `n` generators over a base ring.

        EXAMPLES::

            sage: F.<x,y,z> = FreeAlgebra(QQ, 3); F # indirect doctest
            Free Algebra on 3 generators (x, y, z) over Rational Field

        TESTS:

        Note that the following is *not* the recommended way to create
        a free algebra::

            sage: from sage.algebras.free_algebra import FreeAlgebra_generic
            sage: FreeAlgebra_generic(ZZ, 3, 'abc')
            Free Algebra on 3 generators (a, b, c) over Integer Ring
        """
        if R not in Rings():
            raise TypeError("Argument R must be a ring.")
        self.__ngens = n
        indices = FreeMonoid(n, names=names)
        cat = AlgebrasWithBasis(R)
        CombinatorialFreeModule.__init__(self,
                                         R,
                                         indices,
                                         prefix='F',
                                         category=cat)
        self._assign_names(indices.variable_names())
示例#4
0
    def __init__(self, R, n, names):
        """
        The free algebra on `n` generators over a base ring.

        INPUT:

        -  ``R`` - ring
        -  ``n`` - an integer
        -  ``names`` - generator names

        EXAMPLES::

            sage: F.<x,y,z> = FreeAlgebra(QQ, 3); F # indirect doctet
            Free Algebra on 3 generators (x, y, z) over Rational Field

        TEST:

        Note that the following is *not* the recommended way to create
        a free algebra.
        ::

            sage: from sage.algebras.free_algebra import FreeAlgebra_generic
            sage: FreeAlgebra_generic(ZZ,3,'abc')
            Free Algebra on 3 generators (a, b, c) over Integer Ring

        """
        if not isinstance(R, Ring):
            raise TypeError("Argument R must be a ring.")
        self.__ngens = n
        #sage.structure.parent_gens.ParentWithGens.__init__(self, R, names)
        self._basis_keys = FreeMonoid(n, names=names)
        Algebra.__init__(self, R, names, category=AlgebrasWithBasis(R))
示例#5
0
    def super_categories(self):
        """
        EXAMPLES::

            sage: MonoidAlgebras(QQ).super_categories()
            [Category of algebras with basis over Rational Field]
        """
        from sage.categories.algebras_with_basis import AlgebrasWithBasis
        R = self.base_ring()
        return [AlgebrasWithBasis(R)]
示例#6
0
    def __init__(self, R, names):
        """
        Initialize ``self``.

        EXAMPLES::

            sage: D = ShuffleAlgebra(QQ, 'ab').dual_pbw_basis()
            sage: TestSuite(D).run()
        """
        self._alphabet = names
        self._alg = ShuffleAlgebra(R, names)
        CombinatorialFreeModule.__init__(self, R, Words(names), prefix='S',
            category=(AlgebrasWithBasis(R), CommutativeAlgebras(R), CoalgebrasWithBasis(R)))
示例#7
0
    def __init__(self, R, names=None):
        r"""
        Initialize ``self``.

        EXAMPLES::

            sage: R.<x,y,z> = QQ[]
            sage: W = DifferentialWeylAlgebra(R)
            sage: TestSuite(W).run()
        """
        self._n = len(names)
        self._poly_ring = PolynomialRing(R, names)
        names = names + tuple('d' + n for n in names)
        if len(names) != self._n * 2:
            raise ValueError("variable names cannot differ by a leading 'd'")
        # TODO: Make this into a filtered algebra under the natural grading of
        #   x_i and dx_i have degree 1
        # Filtered is not included because it is a supercategory of super
        if R.is_field():
            cat = AlgebrasWithBasis(R).NoZeroDivisors().Super()
        else:
            cat = AlgebrasWithBasis(R).Super()
        Algebra.__init__(self, R, names, category=cat)
    def __init__(self, alg):
        """
        Initialize ``self``.

        EXAMPLES::

            sage: PBW = FreeAlgebra(QQ, 2, 'x,y').pbw_basis()
            sage: TestSuite(PBW).run()
        """
        R = alg.base_ring()
        self._alg = alg
        category = AlgebrasWithBasis(R)
        CombinatorialFreeModule.__init__(self, R, alg.monoid(), prefix='PBW',
                                         category=category)
        self._assign_names(alg.variable_names())
示例#9
0
    def __init__(self, base_ring, q, prefix='H'):
        """
        Initialize ``self``.

        EXAMPLES::

            sage: R.<q> = ZZ[]
            sage: H = HallAlgebra(R, q)
            sage: TestSuite(H).run()
            sage: R = PolynomialRing(ZZ, 'q').fraction_field()
            sage: q = R.gen()
            sage: H = HallAlgebra(R, q)
            sage: TestSuite(H).run() # long time
            sage: R.<q> = LaurentPolynomialRing(ZZ)
            sage: H = HallAlgebra(R, q)
            sage: TestSuite(H).run() # long time
        """
        self._q = q
        try:
            q_inverse = q**-1
            if not q_inverse in base_ring:
                hopf_structure = False
            else:
                hopf_structure = True
        except Exception:
            hopf_structure = False
        if hopf_structure:
            category = HopfAlgebrasWithBasis(base_ring)
        else:
            category = AlgebrasWithBasis(base_ring)
        CombinatorialFreeModule.__init__(self,
                                         base_ring,
                                         Partitions(),
                                         prefix=prefix,
                                         bracket=False,
                                         sorting_key=cmp_to_key(transpose_cmp),
                                         category=category)

        # Coercions
        I = self.monomial_basis()
        M = I.module_morphism(I._to_natural_on_basis,
                              codomain=self,
                              triangular='upper',
                              unitriangular=True,
                              inverse_on_support=lambda x: x.conjugate(),
                              invertible=True)
        M.register_as_coercion()
        (~M).register_as_coercion()
    def __init__(self, field, relations, names):
        """
        The finitely presented algebra equivalent to the free algebra over `field` generated by
        `names` modulo the ideal generated by `relations`.
        """
        if field not in Fields: raise TypeError('Base ring must be a field.')

        if type(relations) == str: relations = tuple(relations.split(','))
        elif type(relations) == list: relations = tuple(relations)
        elif not isinstance(relations, tuple):
            raise TypeError(
                'Relations must be given as a list, tuple, or string.')

        if type(names) == str: names = tuple(names.split(','))
        elif type(names) == list: names = tuple(names)
        elif not isinstance(names, tuple):
            raise TypeError(
                'Generators must be given as a list, tuple, or string.')

        self._ngens = len(names)
        self._nrels = len(relations)
        self._free_alg = FreeAlgebra(field, self._ngens, names)
        self._ideal = self._free_alg.ideal(relations)

        self._reduce = []
        for f in self._ideal.gens():
            mons = f.monomials()
            if len(mons) == 1:
                self._reduce.append([_to_word(f), Word(''), field.zero()])
            if len(mons) == 2:
                coeffs = f.coefficients()
                if mons[0] < mons[1]:
                    self._reduce.append([
                        _to_word(mons[1]),
                        _to_word(mons[0]), -coeffs[0] * coeffs[1]**(-1)
                    ])
                elif mons[0] > mons[1]:
                    self._reduce.append([
                        _to_word(mons[0]),
                        _to_word(mons[1]), -coeffs[1] * coeffs[0]**(-1)
                    ])

        QuotientRing_nc.__init__(self,
                                 self._free_alg,
                                 self._ideal,
                                 names,
                                 category=AlgebrasWithBasis(field))
示例#11
0
    def __init__(self, base_ring, q, prefix='I'):
        """
        Initialize ``self``.

        EXAMPLES::

            sage: R.<q> = ZZ[]
            sage: I = HallAlgebra(R, q).monomial_basis()
            sage: TestSuite(I).run()
            sage: R = PolynomialRing(ZZ, 'q').fraction_field()
            sage: q = R.gen()
            sage: I = HallAlgebra(R, q).monomial_basis()
            sage: TestSuite(I).run()
            sage: R.<q> = LaurentPolynomialRing(ZZ)
            sage: I = HallAlgebra(R, q).monomial_basis()
            sage: TestSuite(I).run()
        """
        self._q = q
        try:
            q_inverse = q**-1
            if not q_inverse in base_ring:
                hopf_structure = False
            else:
                hopf_structure = True
        except Exception:
            hopf_structure = False
        if hopf_structure:
            category = HopfAlgebrasWithBasis(base_ring)
        else:
            category = AlgebrasWithBasis(base_ring)
        CombinatorialFreeModule.__init__(self,
                                         base_ring,
                                         Partitions(),
                                         prefix=prefix,
                                         bracket=False,
                                         category=category)

        # Coercions
        if hopf_structure:
            e = SymmetricFunctions(base_ring).e()
            f = lambda la: q**sum(-((r * (r - 1)) // 2) for r in la)
            M = self.module_morphism(diagonal=f, codomain=e)
            M.register_as_coercion()
            (~M).register_as_coercion()
示例#12
0
        def extra_super_categories(self):
            """
            EXAMPLES::

                sage: Semigroups().Algebras(QQ).extra_super_categories()
                [Category of algebras with basis over Rational Field]
                sage: Semigroups().Algebras(QQ).super_categories()
                [Category of algebras with basis over Rational Field, Category of set algebras over Rational Field]

                sage: Semigroups().example().algebra(ZZ).categories()
                [Category of semigroup algebras over Integer Ring,
                 Category of algebras with basis over Integer Ring,
                 ...
                 Category of objects]

            FIXME: that should be non unital algebras!
            """
            from sage.categories.algebras_with_basis import AlgebrasWithBasis
            return [AlgebrasWithBasis(self.base_ring())]
示例#13
0
        def extra_super_categories(self):
            """
            EXAMPLES::

                sage: Monoids().Algebras(QQ).extra_super_categories()
                [Category of algebras with basis over Rational Field]
                sage: Monoids().Algebras(QQ).super_categories()
                [Category of semigroup algebras over Rational Field]

                sage: Monoids().example().algebra(ZZ).categories()
                [Category of monoid algebras over Integer Ring,
                 Category of semigroup algebras over Integer Ring,
                 Category of algebras with basis over Integer Ring,
                 ...
                 Category of objects]

            """
            from sage.categories.algebras_with_basis import AlgebrasWithBasis
            return [AlgebrasWithBasis(self.base_ring())]
示例#14
0
    def __init__(self, R, n, r):
        """
        Initialize ``self``.

        TESTS::

            sage: S = SchurAlgebra(ZZ, 2, 2)
            sage: TestSuite(S).run()

        ::

            sage: SchurAlgebra(ZZ, -2, 2)
            Traceback (most recent call last):
            ...
            ValueError: n (=-2) must be a positive integer
            sage: SchurAlgebra(ZZ, 2, -2)
            Traceback (most recent call last):
            ...
            ValueError: r (=-2) must be a non-negative integer
            sage: SchurAlgebra('niet', 2, 2)
            Traceback (most recent call last):
            ...
            ValueError: R (=niet) must be a commutative ring
        """
        if n not in ZZ or n <= 0:
            raise ValueError("n (={}) must be a positive integer".format(n))
        if r not in ZZ or r < 0:
            raise ValueError(
                "r (={}) must be a non-negative integer".format(r))
        if not R in Rings.Commutative():
            raise ValueError("R (={}) must be a commutative ring".format(R))

        self._n = n
        self._r = r

        CombinatorialFreeModule.__init__(
            self,
            R,
            schur_representative_indices(n, r),
            prefix='S',
            bracket=False,
            category=AlgebrasWithBasis(R).FiniteDimensional())