Example #1
0
    def __classcall_private__(cls,
                              basis,
                              ambient=None,
                              unitriangular=False,
                              category=None,
                              *args,
                              **opts):
        r"""
        Normalize the input.

        TESTS::

            sage: from sage.modules.with_basis.subquotient import SubmoduleWithBasis
            sage: X = CombinatorialFreeModule(QQ, range(3)); x = X.basis()
            sage: Y1 = SubmoduleWithBasis((x[0]-x[1], x[1]-x[2]), X)
            sage: Y2 = SubmoduleWithBasis([x[0]-x[1], x[1]-x[2]], X)
            sage: Y1 is Y2
            True
        """
        basis = Family(basis)
        if ambient is None:
            ambient = basis.an_element().parent()
        default_category = ModulesWithBasis(
            ambient.category().base_ring()).Subobjects()
        category = default_category.or_subcategory(category, join=True)
        return super(SubmoduleWithBasis,
                     cls).__classcall__(cls, basis, ambient, unitriangular,
                                        category, *args, **opts)
Example #2
0
    def __init_extra__(self):
        """
        Sets up the coercions between the different bases

        EXAMPLES::

            sage: Sym = SymmetricFunctions(QQ) # indirect doctest
            sage: s = Sym.s(); p = Sym.p()
            sage: s.coerce_map_from(p)
            Generic morphism:
              From: Symmetric Function Algebra over Rational Field, Power symmetric functions as basis
              To:   Symmetric Function Algebra over Rational Field, Schur symmetric functions as basis
        """
        #category   = Bases(self)
        #category   = GradedHopfAlgebrasWithBasis(self.base_ring())
        category   = ModulesWithBasis(self.base_ring())
        powersum   = self.powersum  ()
        complete   = self.complete  ()
        elementary = self.elementary()
        schur      = self.schur     ()
        monomial   = self.monomial  ()

        iso = self.register_isomorphism

        from sage.combinat.sf.classical import conversion_functions
        from sage.categories.morphism import SetMorphism
        from sage.categories.homset import Hom

        for (basis1_name, basis2_name) in conversion_functions.keys():
            basis1 = getattr(self, basis1_name)()
            basis2 = getattr(self, basis2_name)()
            on_basis = SymmetricaConversionOnBasis(t = conversion_functions[basis1_name,basis2_name], domain = basis1, codomain = basis2)
            iso(basis1._module_morphism(on_basis, codomain = basis2, category = category))
Example #3
0
        def internal_coproduct(self):
            """
            Compute the internal coproduct of ``self``.

            If :meth:`internal_coproduct_on_basis()` is available, construct
            the internal coproduct morphism from ``self`` to ``self``
            `\otimes` ``self`` by extending it by linearity. Otherwise, this uses
            :meth:`internal_coproduct_by_coercion()`, if available.

            OUTPUT:

            - an element of the tensor squared of ``self``

            EXAMPLES::

                sage: q = SymmetricFunctionsNonCommutingVariables(QQ).q()
                sage: q.internal_coproduct(q[[1,3],[2]] - 2*q[[1]])
                -2*q{{1}} # q{{1}} + q{{1, 2, 3}} # q{{1, 3}, {2}} + q{{1, 3}, {2}} # q{{1, 2, 3}}
                 + q{{1, 3}, {2}} # q{{1, 3}, {2}}
            """
            if self.internal_coproduct_on_basis is not NotImplemented:
                return Hom(self, tensor([self, self]),
                           ModulesWithBasis(self.base_ring()))(
                               on_basis=self.internal_coproduct_on_basis)
            elif hasattr(self, "internal_coproduct_by_coercion"):
                return self.internal_coproduct_by_coercion
Example #4
0
 def super_categories(self):
     # TODO: make this a Steenrod algebra module
     return [
         ModulesWithBasis(
             self.base_category().ModuleCategory().base_ring()
         ).Homsets(),
     ]
        def coproduct(self):
            """
            If :meth:`coproduct_on_basis` is available, construct the
            coproduct morphism from ``self`` to ``self`` `\otimes`
            ``self`` by extending it by linearity. Otherwise, use
            :meth:`~Coalgebras.Realizations.ParentMethods.coproduct_by_coercion`,
            if available.

            EXAMPLES::

                sage: A = HopfAlgebrasWithBasis(QQ).example(); A
                An example of Hopf algebra with basis: the group algebra of the Dihedral group of order 6 as a permutation group over Rational Field
                sage: [a,b] = A.algebra_generators()
                sage: a, A.coproduct(a)
                (B[(1,2,3)], B[(1,2,3)] # B[(1,2,3)])
                sage: b, A.coproduct(b)
                (B[(1,3)], B[(1,3)] # B[(1,3)])

            """
            if self.coproduct_on_basis is not NotImplemented:
                # TODO: if self is a hopf algebra, then one would want
                # to create a morphism of algebras with basis instead
                # should there be a method self.coproduct_homset_category?
                return Hom(self, tensor([self, self]),
                           ModulesWithBasis(self.base_ring()))(
                               on_basis=self.coproduct_on_basis)
            elif hasattr(self, "coproduct_by_coercion"):
                return self.coproduct_by_coercion
Example #6
0
    def _test_category_contains(self, tester=None, **options):
        """
        Test the implicit __contains__ method of this category::

            sage: from yacop.modules.projective_spaces import RealProjectiveSpace
            sage: M=RealProjectiveSpace()
            sage: M.category()
            Category of yacop left module algebras over mod 2 Steenrod algebra, milnor basis
            sage: M in M.category()
            True
            sage: M._test_category_contains()

        """
        from sage.misc.lazy_format import LazyFormat
        from sage.rings.finite_rings.finite_field_constructor import FiniteField

        tester = self._tester(**options)
        tester.assertTrue(
            self in self.category(),
            LazyFormat("%s not contained in its category %s" %
                       (self, self.category())),
        )
        M = ModulesWithBasis(FiniteField(self.base_ring().characteristic()))
        tester.assertTrue(self in M,
                          LazyFormat("%s not contained in %s" % (self, M)))
Example #7
0
    def __classcall_private__(cls, submodule, category=None):
        r"""
        Normalize the input.

        TESTS::

            sage: from sage.modules.with_basis.subquotient import QuotientModuleWithBasis
            sage: X = CombinatorialFreeModule(QQ, range(3)); x = X.basis()
            sage: I = X.submodule( (x[0]-x[1], x[1]-x[2]) )
            sage: J1 = QuotientModuleWithBasis(I)
            sage: J2 = QuotientModuleWithBasis(I, category=Modules(QQ).WithBasis().Quotients())
            sage: J1 is J2
            True
        """
        default_category = ModulesWithBasis(submodule.category().base_ring()).Quotients()
        category = default_category.or_subcategory(category, join=True)
        return super(QuotientModuleWithBasis, cls).__classcall__(cls, submodule, category)
Example #8
0
    def super_categories(self):
        """
        EXAMPLES::

            sage: CoalgebrasWithBasis(QQ).super_categories()
            [Category of modules with basis over Rational Field, Category of coalgebras over Rational Field]
        """
        R = self.base_ring()
        return [ModulesWithBasis(R), Coalgebras(R)]
Example #9
0
    def super_categories(self):
        """
        EXAMPLES::

            sage: FiniteDimensionalModulesWithBasis(QQ).super_categories()
            [Category of modules with basis over Rational Field]
        """
        R = self.base_ring()
        return [ModulesWithBasis(R)]
Example #10
0
    def __classcall_private__(cls, submodule, category=None):
        r"""
        Normalize the input.

        TESTS::

            sage: from sage.modules.with_basis.subquotient import QuotientModuleWithBasis
            sage: X = CombinatorialFreeModule(QQ, range(3)); x = X.basis()
            sage: I = X.submodule( (x[0]-x[1], x[1]-x[2]) )
            sage: J1 = QuotientModuleWithBasis(I)
            sage: J2 = QuotientModuleWithBasis(I, category=Modules(QQ).WithBasis().Quotients())
            sage: J1 is J2
            True
        """
        default_category = ModulesWithBasis(submodule.category().base_ring()).Quotients()
        category = default_category.or_subcategory(category, join=True)
        return super(QuotientModuleWithBasis, cls).__classcall__(
            cls, submodule, category)
    def super_categories(self):
        """
        EXAMPLES::

            sage: GradedModulesWithBasis(QQ).super_categories()
            [Category of graded modules over Rational Field, Category of modules with basis over Rational Field]
        """
        R = self.base_ring()
        return [GradedModules(R), ModulesWithBasis(R)]
Example #12
0
    def __classcall_private__(cls, basis, ambient=None, unitriangular=False, category=None, *args, **opts):
        r"""
        Normalize the input.

        TESTS::

            sage: from sage.modules.with_basis.subquotient import SubmoduleWithBasis
            sage: X = CombinatorialFreeModule(QQ, range(3)); x = X.basis()
            sage: Y1 = SubmoduleWithBasis((x[0]-x[1], x[1]-x[2]), X)
            sage: Y2 = SubmoduleWithBasis([x[0]-x[1], x[1]-x[2]], X)
            sage: Y1 is Y2
            True
        """
        basis = Family(basis)
        if ambient is None:
            ambient = basis.an_element().parent()
        default_category = ModulesWithBasis(ambient.category().base_ring()).Subobjects()
        category = default_category.or_subcategory(category, join=True)
        return super(SubmoduleWithBasis, cls).__classcall__(cls, basis, ambient, unitriangular, category, *args, **opts)
Example #13
0
    def super_categories(self):
        """
        EXAMPLES::

            sage: HeckeModules(QQ).super_categories()
            [Category of modules with basis over Rational Field]
        """
        from sage.categories.all import ModulesWithBasis
        R = self.base_ring()
        return [ModulesWithBasis(R)]
Example #14
0
    def super_categories(self):
        """
        TESTS::

            sage: from yacop.categories import *
            sage: A=SteenrodAlgebra(3)
            sage: YacopLeftModules(A).super_categories()
            [Category of yacop differential modules over mod 3 Steenrod algebra, milnor basis,
             Category of vector spaces with basis over Finite Field of size 3,
             Category of left modules over mod 3 Steenrod algebra, milnor basis]
            sage: YacopRightModules(A).super_categories()
            [Category of yacop differential modules over mod 3 Steenrod algebra, milnor basis,
             Category of vector spaces with basis over Finite Field of size 3,
             Category of right modules over mod 3 Steenrod algebra, milnor basis]
            sage: YacopBimodules(A).super_categories()
            [Category of yacop differential modules over mod 3 Steenrod algebra, milnor basis,
             Category of vector spaces with basis over Finite Field of size 3,
             Category of bimodules over mod 3 Steenrod algebra, milnor basis on the left and mod 3 Steenrod algebra, milnor basis on the right]
            sage: YacopLeftModuleAlgebras(A).super_categories()
            [Category of yacop differential modules over mod 3 Steenrod algebra, milnor basis,
             Category of vector spaces with basis over Finite Field of size 3,
             Category of left modules over mod 3 Steenrod algebra, milnor basis,
             Category of algebras with basis over Finite Field of size 3]
            sage: YacopRightModuleAlgebras(A).super_categories()
            [Category of yacop differential modules over mod 3 Steenrod algebra, milnor basis,
             Category of vector spaces with basis over Finite Field of size 3,
             Category of right modules over mod 3 Steenrod algebra, milnor basis,
             Category of algebras with basis over Finite Field of size 3]
            sage: YacopBimoduleAlgebras(A).super_categories()
            [Category of yacop differential modules over mod 3 Steenrod algebra, milnor basis,
             Category of vector spaces with basis over Finite Field of size 3,
             Category of bimodules over mod 3 Steenrod algebra, milnor basis on the left and mod 3 Steenrod algebra, milnor basis on the right,
             Category of algebras with basis over Finite Field of size 3]

        """
        from sage.categories.modules_with_basis import ModulesWithBasis
        from yacop.categories.differential_modules import YacopDifferentialModules

        (left, right, algebra) = self._yacop_category

        R = self.base_ring()
        x = []
        x.append(YacopDifferentialModules(R))
        x.append(ModulesWithBasis(R.base_ring()))
        if left and right:
            x.append(Bimodules(R, R))
        else:
            if left:
                x.append(LeftModules(R))
            if right:
                x.append(RightModules(R))
        if algebra:
            x.append(AlgebrasWithBasis(R.base_ring()))
        return x
Example #15
0
    def __init__(self, submodule):
        """
        Initialize ``self``.

        EXAMPLES::

            sage: S = SymmetricGroupAlgebra(QQ, 3)
            sage: L = S.cell_module([2,1]).simple_module()
            sage: TestSuite(L).run()
        """
        cat = ModulesWithBasis(submodule.category().base_ring()).Quotients()
        QuotientModuleWithBasis.__init__(self, submodule, cat)
        # We set some print options since QuotientModuleWithBasis doesn't take them
        self.print_options(prefix='L', bracket=False)
Example #16
0
    def super_categories(self):
        """
        TESTS::

            sage: from yacop.categories import *
            sage: YacopLeftModules(SteenrodAlgebra(2)).is_subcategory(ModulesWithBasis(GF(2)))
            True

        """
        from sage.categories.modules_with_basis import ModulesWithBasis

        R = self.base_ring()
        x = []
        x.append(YacopDifferentialModules(R))
        x.append(ModulesWithBasis(R.base_ring()))
        x.append(LeftModules(R))
        return x
    def super_categories(self):
        """
        TESTS::

            sage: from yacop.categories import *
            sage: YacopDifferentialModules(SteenrodAlgebra(2)).super_categories()
            [Category of vector spaces with basis over Finite Field of size 2,
             Category of yacop graded objects]

        """
        from sage.categories.modules_with_basis import ModulesWithBasis

        R = self.base_ring()
        x = []
        x.append(ModulesWithBasis(R.base_ring()))
        x.append(YacopGradedObjects())
        return x
Example #18
0
    def __init__(self, A, mu, **kwds):
        r"""
        Initialize ``self``.

        TESTS::

            sage: S = SymmetricGroupAlgebra(QQ, 3)
            sage: W = S.cell_module([2,1])
            sage: TestSuite(W).run()
        """
        self._algebra = A
        self._la = mu
        cat = ModulesWithBasis(A.base_ring()).FiniteDimensional()
        CombinatorialFreeModule.__init__(self,
                                         A.base_ring(),
                                         A.cell_module_indices(mu),
                                         category=cat,
                                         **kwds)
        def module_morphism(self, *args, **kwargs):
            """
            TESTS::

                sage: from yacop.categories import *
                sage: from yacop.modules.all import RealProjectiveSpace
                sage: M = RealProjectiveSpace()
                sage: X = cartesian_product((M,M))
                sage: f = X.cartesian_projection(0)
                sage: C = YacopLeftModules(SteenrodAlgebra(2))
                sage: f in C.Homsets() # random, works in sage shell
                True
                sage: hasattr(f,"kernel") # indirect test that f is in the Homsets category
                True

            """
            # hack to fix the automatic category detection
            Y = self.__yacop_category__()
            cat = kwargs.pop("category", Y)
            codomain = kwargs.pop("codomain", self)
            cat = cat.category().meet((self.category(), codomain.category()))
            kwargs["category"] = cat
            kwargs["codomain"] = codomain
            ans = ModulesWithBasis(
                Y.base_ring().base_ring()).parent_class.module_morphism(
                    self, *args, **kwargs)

            # there is a known issue with morphism categories (see sage code)
            # disable the _test_category and _test_pickling method for this instance:

            def dummy(*args, **kwopts):
                pass

            setattr(ans, "_test_category", dummy)
            setattr(ans, "_test_pickling", dummy)
            return ans