Example #1
0
    def __init__(self, R, M, ordering=None):
        """
        Initialize ``self``.

        EXAMPLES::

            sage: M = matroids.Wheel(3)
            sage: OS = M.orlik_solomon_algebra(QQ)
            sage: TestSuite(OS).run()

        We check on the matroid associated to the graph with 3 vertices and
        2 edges between each vertex::

            sage: G = Graph([[1,2],[1,2],[2,3],[2,3],[1,3],[1,3]], multiedges=True)
            sage: M = Matroid(G)
            sage: OS = M.orlik_solomon_algebra(QQ)
            sage: elts = OS.some_elements() + list(OS.algebra_generators())
            sage: TestSuite(OS).run(elements=elts)
        """
        self._M = M
        self._sorting = {x:i for i,x in enumerate(ordering)}

        # set up the dictionary of broken circuits
        self._broken_circuits = dict()
        for c in self._M.circuits():
            L = sorted(c, key=lambda x: self._sorting[x])
            self._broken_circuits[frozenset(L[1:])] = L[0]

        cat = Algebras(R).FiniteDimensional().WithBasis().Graded()
        CombinatorialFreeModule.__init__(self, R, M.no_broken_circuits_sets(ordering),
                                         prefix='OS', bracket='{',
                                         sorting_key=self._sort_key,
                                         category=cat)
Example #2
0
    def __init__(self, group, base_ring=IntegerRing()):
        r"""
        See :class:`GroupAlgebra` for full documentation.

        EXAMPLES::

            sage: GroupAlgebra(GL(3, GF(7)))
            Group algebra of group "General Linear Group of degree 3 over Finite Field of size 7" over base ring Integer Ring
        """
        from sage.groups.group import Group
        from sage.groups.old import Group as OldGroup
        if not base_ring.is_commutative():
            raise NotImplementedError("Base ring must be commutative")

        if not isinstance(group, (Group, OldGroup)):
            raise TypeError('"%s" is not a group' % group)

        self._group = group
        CombinatorialFreeModule.__init__(self, base_ring, group,
                                         prefix='',
                                         bracket=False,
                                         category=HopfAlgebrasWithBasis(base_ring))

        if not base_ring.has_coerce_map_from(group) :
            ## some matrix groups assume that coercion is only valid to
            ## other matrix groups. This is a workaround
            ## call _element_constructor_ to coerce group elements
            #try :
            self._populate_coercion_lists_(coerce_list=[base_ring, group])
            #except TypeError :
            #    self._populate_coercion_lists_( coerce_list = [base_ring] )
        else :
            self._populate_coercion_lists_(coerce_list=[base_ring])
Example #3
0
    def __init__(self, root_system, base_ring):
        r"""
        EXAMPLES::

            sage: R = RootSystem(["A",3,1])
            sage: R.cartan_type().AmbientSpace
            <class 'sage.combinat.root_system.type_affine.AmbientSpace'>
            sage: e = R.ambient_space(); e
            Ambient space of the Root system of type ['A', 3, 1]
            sage: TestSuite(R.ambient_space()).run()

            sage: L = RootSystem(['A',3]).coroot_lattice()
            sage: e.has_coerce_map_from(L)
            True
            sage: e(L.simple_root(1))
            e[0] - e[1]
        """
        self.root_system = root_system
        classical = root_system.cartan_type().classical().root_system().ambient_space(base_ring)
        basis_keys = tuple(classical.basis().keys()) + ("delta","deltacheck")
        CombinatorialFreeModule.__init__(self, base_ring,
                                         basis_keys,
                                         prefix = "e",
                                         latex_prefix = "e",
                                         category = WeightLatticeRealizations(base_ring))
        self._weight_space = self.root_system.weight_space(base_ring=base_ring,extended=True)
        self.classical().module_morphism(self.monomial, codomain=self).register_as_coercion()
        # Duplicated from ambient_space.AmbientSpace
        coroot_lattice = self.root_system.coroot_lattice()
        coroot_lattice.module_morphism(self.simple_coroot, codomain=self).register_as_coercion()
Example #4
0
        def __init__(self, QSym):
            r"""
            The dual immaculate basis of the non-commutative symmetric functions. This basis first
            appears in Berg, Bergeron, Saliola, Serrano and Zabrocki's " A lift of the Schur and Hall-Littlewood
            bases to non-commutative symmetric functions".

            EXAMPLES ::

                sage: QSym = QuasiSymmetricFunctions(QQ)
                sage: dI = QSym.dI()
                sage: dI([1,3,2])*dI([1])  # long time (6s on sage.math, 2013)
                dI[1, 1, 3, 2] + dI[2, 3, 2]
                sage: dI([1,3])*dI([1,1])
                dI[1, 1, 1, 3] + dI[1, 1, 4] + dI[1, 2, 3] - dI[1, 3, 2] - dI[1, 4, 1] - dI[1, 5] + dI[2, 3, 1] + dI[2, 4]
                sage: dI([3,1])*dI([2,1])  # long time (7s on sage.math, 2013)
                dI[1, 1, 5] - dI[1, 4, 1, 1] - dI[1, 4, 2] - 2*dI[1, 5, 1] - dI[1, 6] - dI[2, 4, 1] - dI[2, 5] - dI[3, 1, 3] + dI[3, 2, 1, 1] + dI[3, 2, 2] + dI[3, 3, 1] + dI[4, 1, 1, 1] + 2*dI[4, 2, 1] + dI[4, 3] + dI[5, 1, 1] + dI[5, 2]
                sage: F = QSym.F()
                sage: dI(F[1,3,1])
                -dI[1, 1, 1, 2] + dI[1, 1, 2, 1] - dI[1, 2, 2] + dI[1, 3, 1]
                sage: F(dI(F([2,1,3])))
                F[2, 1, 3]
            """
            CombinatorialFreeModule.__init__(self, QSym.base_ring(), Compositions(),
                                             prefix='dI', bracket=False,
                                             category=QSym.Bases())
Example #5
0
    def __init__(self, basis, ambient, unitriangular, category):
        r"""
        Initialization.

        TESTS::

            sage: from sage.modules.with_basis.subquotient import SubmoduleWithBasis
            sage: X = CombinatorialFreeModule(QQ, range(3), prefix="x"); x = X.basis()
            sage: ybas = (x[0]-x[1], x[1]-x[2])
            sage: Y = SubmoduleWithBasis(ybas, X)
            sage: Y.print_options(prefix='y')
            sage: Y.basis().list()
            [y[0], y[1]]
            sage: [ y.lift() for y in Y.basis() ]
            [x[0] - x[1], x[1] - x[2]]
            sage: TestSuite(Y).run()
        """
        import operator

        ring = ambient.base_ring()
        CombinatorialFreeModule.__init__(self, ring, basis.keys(), category=category.Subobjects())
        self._ambient = ambient
        self._basis = basis
        self._unitriangular = unitriangular
        self.lift_on_basis = self._basis.__getitem__
Example #6
0
    def __init__(self, root_system, base_ring, extended):
        """
        TESTS::

            sage: R = RootSystem(['A',4])
            sage: from sage.combinat.root_system.weight_space import WeightSpace
            sage: Q = WeightSpace(R, QQ); Q
            Weight space over the Rational Field of the Root system of type ['A', 4]
            sage: TestSuite(Q).run()

            sage: WeightSpace(R, QQ, extended = True)
            Traceback (most recent call last):
            ...
            AssertionError: extended weight lattices are only implemented for affine root systems
        """
        basis_keys = root_system.index_set()
        self._extended = extended
        if extended:
            assert root_system.cartan_type().is_affine(), "extended weight lattices are only implemented for affine root systems"
            basis_keys = tuple(basis_keys) + ("delta",)

        self.root_system = root_system
        CombinatorialFreeModule.__init__(self, base_ring,
                                         basis_keys,
                                         prefix = "Lambdacheck" if root_system.dual_side else "Lambda",
                                         latex_prefix = "\\Lambda^\\vee" if root_system.dual_side else "\\Lambda",
                                         category = WeightLatticeRealizations(base_ring))

        if root_system.cartan_type().is_affine() and not extended:
            # For an affine type, register the quotient map from the
            # extended weight lattice/space to the weight lattice/space
            domain = root_system.weight_space(base_ring, extended=True)
            domain.module_morphism(self.fundamental_weight,
                                   codomain = self
                                   ).register_as_coercion()
Example #7
0
    def __init__(self, R, M, ordering=None):
        """
        Initialize ``self``.

        EXAMPLES::

            sage: M = matroids.Wheel(3)
            sage: OS = M.orlik_solomon_algebra(QQ)
            sage: TestSuite(OS).run()

        We check on the matroid associated to the graph with 3 vertices and
        2 edges between each vertex::

            sage: G = Graph([[1,2],[1,2],[2,3],[2,3],[1,3],[1,3]], multiedges=True)
            sage: M = Matroid(G)
            sage: OS = M.orlik_solomon_algebra(QQ)
            sage: elts = OS.some_elements() + list(OS.algebra_generators())
            sage: TestSuite(OS).run(elements=elts)
        """
        self._M = M
        self._sorting = {x:i for i,x in enumerate(ordering)}

        # set up the dictionary of broken circuits
        self._broken_circuits = dict()
        for c in self._M.circuits():
            L = sorted(c, key=lambda x: self._sorting[x])
            self._broken_circuits[frozenset(L[1:])] = L[0]

        cat = Algebras(R).FiniteDimensional().WithBasis().Graded()
        CombinatorialFreeModule.__init__(self, R, M.no_broken_circuits_sets(ordering),
                                         prefix='OS', bracket='{',
                                         sorting_key=self._sort_key,
                                         category=cat)
Example #8
0
    def __init__(self, k, q1, q2, q3, base_ring, prefix):
        r"""
        Initialize ``self``.

        TESTS::

            sage: R.<q,r,s> = ZZ[]
            sage: B4 = algebras.Blob(4, q, r, s)
            sage: TestSuite(B4).run()

            sage: B3 = algebras.Blob(3, q, r, s)
            sage: B = list(B3.basis())
            sage: TestSuite(B3).run(elements=B)  # long time
        """
        self._q1 = q1
        self._q2 = q2
        self._q3 = q3
        diagrams = BlobDiagrams(k)
        cat = Algebras(base_ring.category()).FiniteDimensional().WithBasis()
        CombinatorialFreeModule.__init__(self,
                                         base_ring,
                                         diagrams,
                                         category=cat,
                                         prefix=prefix,
                                         bracket=False)
Example #9
0
    def __init__(self, g, q, c):
        """
        Initialize ``self``.

        TESTS::

            sage: O = lie_algebras.OnsagerAlgebra(QQ)
            sage: Q = O.quantum_group()
            sage: TestSuite(Q).run()  # long time
        """
        self._g = g
        self._q = q
        self._c = c
        self._q_two = q + ~q
        R = self._q_two.parent()
        from sage.monoids.indexed_free_monoid import IndexedFreeAbelianMonoid
        monomials = IndexedFreeAbelianMonoid(g.basis().keys(),
                                             prefix='B',
                                             bracket=False,
                                             sorting_key=self._monoid_key)
        CombinatorialFreeModule.__init__(
            self,
            R,
            monomials,
            prefix='',
            bracket=False,
            latex_bracket=False,
            sorting_key=self._monomial_key,
            category=Algebras(R).WithBasis().Filtered())
Example #10
0
    def __init__(self, root_system, base_ring):
        """
        EXAMPLES::

            sage: P = RootSystem(['A',4]).root_space()
            sage: s = P.simple_reflections()

        """
        from sage.categories.morphism import SetMorphism
        from sage.categories.homset import Hom
        from sage.categories.sets_with_partial_maps import SetsWithPartialMaps
        self.root_system = root_system
        CombinatorialFreeModule.__init__(
            self,
            base_ring,
            root_system.index_set(),
            prefix="alphacheck" if root_system.dual_side else "alpha",
            latex_prefix="\\alpha^\\vee"
            if root_system.dual_side else "\\alpha",
            category=RootLatticeRealizations(base_ring))
        if base_ring is not ZZ:
            # Register the partial conversion back from ``self`` to the root lattice
            # See :meth:`_to_root_lattice` for tests
            root_lattice = self.root_system.root_lattice()
            SetMorphism(Hom(self, root_lattice, SetsWithPartialMaps()),
                        self._to_root_lattice).register_as_conversion()
Example #11
0
    def __init__(self, M, prefix='T', category=None, **options):
        r"""
        Initialize ``self``.

        EXAMPLES::

            sage: C = CombinatorialFreeModule(QQ, ['a','b','c'])
            sage: TA = TensorAlgebra(C)
            sage: TestSuite(TA).run()
            sage: m = SymmetricFunctions(QQ).m()
            sage: Tm = TensorAlgebra(m)
            sage: TestSuite(Tm).run()
        """
        self._base_module = M
        R = M.base_ring()
        category = GradedHopfAlgebrasWithBasis(
            R.category()).or_subcategory(category)

        CombinatorialFreeModule.__init__(self,
                                         R,
                                         IndexedFreeMonoid(M.indices()),
                                         prefix=prefix,
                                         category=category,
                                         **options)

        # the following is not the best option, but it's better than nothing.
        self._print_options['tensor_symbol'] = options.get(
            'tensor_symbol', tensor.symbol)
Example #12
0
    def __init__(self, R, q):
        r"""
        Initialize ``self``.

        TESTS::

            sage: A = algebras.AlternatingCentralExtensionQuantumOnsager(QQ)
            sage: TestSuite(A).run()  # long time
        """
        I = DisjointUnionEnumeratedSets(
            [PositiveIntegers(), ZZ,
             PositiveIntegers()],
            keepkey=True,
            facade=True)
        monomials = IndexedFreeAbelianMonoid(I, prefix='A', bracket=False)
        self._q = q
        CombinatorialFreeModule.__init__(
            self,
            R,
            monomials,
            prefix='',
            bracket=False,
            latex_bracket=False,
            sorting_key=self._monomial_key,
            category=Algebras(R).WithBasis().Filtered())
Example #13
0
    def __init__(self, base_ring):
        r"""
        EXAMPLES::

            sage: A = FiniteDimensionalAlgebrasWithBasis(QQ).example(); A
            An example of a finite dimensional algebra with basis:
            the path algebra of the Kronecker quiver
            (containing the arrows a:x->y and b:x->y) over Rational Field
            sage: TestSuite(A).run()
        """
        basis_keys = ['x', 'y', 'a', 'b']
        self._nonzero_products = {
            'xx': 'x',
            'xa': 'a',
            'xb': 'b',
            'yy': 'y',
            'ay': 'a',
            'by': 'b'
        }

        CombinatorialFreeModule.__init__(
            self,
            base_ring,
            basis_keys,
            category=FiniteDimensionalAlgebrasWithBasis(base_ring))
Example #14
0
    def __init__(self, root_system, base_ring):
        """
        EXAMPLES::

            sage: e = RootSystem(['A',3]).ambient_lattice()
            sage: s = e.simple_reflections()

            sage: L = RootSystem(['A',3]).coroot_lattice()
            sage: e.has_coerce_map_from(L)
            True
            sage: e(L.simple_root(1))
            (1, -1, 0, 0)
        """
        self.root_system = root_system
        CombinatorialFreeModule.__init__(
            self,
            base_ring,
            range(0, self.dimension()),
            element_class=AmbientSpaceElement,
            prefix='e',
            category=WeightLatticeRealizations(base_ring))
        coroot_lattice = self.root_system.coroot_lattice()
        coroot_lattice.module_morphism(self.simple_coroot,
                                       codomain=self).register_as_coercion()

        # FIXME: here for backward compatibility;
        # Should we use dimension everywhere?
        self.n = self.dimension()
        ct = root_system.cartan_type()
        if ct.is_irreducible() and ct.type() == 'E':
            self._v0 = self([0, 0, 0, 0, 0, 0, 1, 1])
            self._v1 = self([0, 0, 0, 0, 0, -2, 1, -1])
Example #15
0
    def __init__(self, R, names=None):
        """
        Initialize ``self``.

        TESTS::

            sage: A = algebras.FreePreLie(QQ, '@'); A
            Free PreLie algebra on one generator ['@'] over Rational Field
            sage: TestSuite(A).run()

            sage: F = algebras.FreePreLie(QQ, 'xy')
            sage: TestSuite(F).run() # long time

            sage: F = algebras.FreePreLie(QQ, ZZ)
            sage: elts = F.some_elements()[:-1] # Skip the last element
            sage: TestSuite(F).run(some_elements=elts) # long time
        """
        if names.cardinality() == 1:
            Trees = RootedTrees()
        else:
            Trees = LabelledRootedTrees()
        # Here one would need LabelledRootedTrees(names)
        # so that one can restrict the labels to some fixed set

        self._alphabet = names
        cat = MagmaticAlgebras(R).WithBasis().Graded()
        CombinatorialFreeModule.__init__(self, R, Trees,
                                         latex_prefix="",
                                         category=cat)
Example #16
0
    def __init__(self, I, prefix='R'):
        """
        Initialize ``self``.

        TESTS::

            sage: P = posets.BooleanLattice(3)
            sage: R = P.incidence_algebra(QQ).reduced_subalgebra()
            sage: TestSuite(R).run()  # long time
        """
        self._ambient = I
        EC = {}
        P = self._ambient._poset
        if not P.is_finite():
            raise NotImplementedError("only implemented for finite posets")
        for i in self._ambient.basis().keys():
            S = P.subposet(P.interval(*i))
            added = False
            for k in EC:
                if S._hasse_diagram.is_isomorphic(k._hasse_diagram):
                    EC[k].append(i)
                    added = True
                    break
            if not added:
                EC[S] = [i]
        self._equiv_classes = map(sorted, EC.values())
        self._equiv_classes = {cls[0]: cls for cls in self._equiv_classes}
        cat = Algebras(I.base_ring()).FiniteDimensional().WithBasis()
        CombinatorialFreeModule.__init__(self,
                                         I.base_ring(),
                                         sorted(self._equiv_classes.keys()),
                                         prefix=prefix,
                                         category=cat)
Example #17
0
    def __init__(self, R, names=None):
        """
        Initialize ``self``.

        TESTS::

            sage: A = algebras.FreeDendriform(QQ, '@'); A
            Free Dendriform algebra on one generator ['@'] over Rational Field
            sage: TestSuite(A).run()

            sage: F = algebras.FreeDendriform(QQ, 'xy')
            sage: TestSuite(F).run() # long time
        """
        if names.cardinality() == 1:
            Trees = BinaryTrees()
            key = BinaryTree._sort_key
        else:
            Trees = LabelledBinaryTrees()
            key = LabelledBinaryTree._sort_key
        # Here one would need LabelledBinaryTrees(names)
        # so that one can restrict the labels to some fixed set
        self._alphabet = names
        cat = Algebras(R).WithBasis().Graded()
        CombinatorialFreeModule.__init__(self, R, Trees,
                                         latex_prefix="",
                                         sorting_key=key,
                                         category=cat)
Example #18
0
    def __init__(self, group, base_ring=IntegerRing()):
        r"""
        See :class:`GroupAlgebra` for full documentation.

        EXAMPLES::

            sage: GroupAlgebra(GL(3, GF(7)))
            Group algebra of group "General Linear Group of degree 3 over Finite Field of size 7" over base ring Integer Ring
        """
        from sage.groups.group import is_Group
        if not base_ring.is_commutative():
            raise NotImplementedError("Base ring must be commutative")

        if not is_Group(group):
            raise TypeError('"%s" is not a group' % group)

        self._group = group
        CombinatorialFreeModule.__init__(self, base_ring, group,
                                         prefix='',
                                         bracket=False,
                                         category=GroupAlgebras(base_ring))

        if not base_ring.has_coerce_map_from(group) :
            ## some matrix groups assume that coercion is only valid to
            ## other matrix groups. This is a workaround
            ## call _element_constructor_ to coerce group elements
            #try :
            self._populate_coercion_lists_(coerce_list=[group])
Example #19
0
        def __init__(self, M, prefix='KL'):
            """
            Initialize ``self``.

            TESTS::

                sage: L = posets.BooleanLattice(4)
                sage: M = L.quantum_moebius_algebra()
                sage: TestSuite(M.KL()).run() # long time
            """
            self._basis_name = "Kazhdan-Lusztig"
            CombinatorialFreeModule.__init__(self, M.base_ring(),
                                             tuple(M._lattice),
                                             prefix=prefix,
                                             category=MoebiusAlgebraBases(M))

            ## Change of basis:
            E = M.E()
            phi = self.module_morphism(self._to_natural_basis,
                                       codomain=E, category=self.category(),
                                       triangular='lower', unitriangular=True,
                                       key=M._lattice._element_to_vertex)

            phi.register_as_coercion()
            (~phi).register_as_coercion()
Example #20
0
    def __init__(self, alg, graded=True):
        r"""
        Initialize ``self``.

        EXAMPLES::

            sage: G = algebras.FSym(QQ).G()
            sage: TestSuite(G).run()  # long time

        Checks for the antipode::

            sage: FSym = algebras.FSym(QQ)
            sage: G = FSym.G()
            sage: for b in G.basis(degree=3):
            ....:     print("%s : %s" % (b, b.antipode()))
            G[123] : -G[1|2|3]
            G[13|2] : -G[13|2]
            G[12|3] : -G[12|3]
            G[1|2|3] : -G[123]

            sage: F = FSym.dual().F()
            sage: for b in F.basis(degree=3):
            ....:     print("%s : %s" % (b, b.antipode()))
            F[123] : -F[1|2|3]
            F[13|2] : -F[13|2]
            F[12|3] : -F[12|3]
            F[1|2|3] : -F[123]
        """
        CombinatorialFreeModule.__init__(self,
                                         alg.base_ring(),
                                         StandardTableaux(),
                                         category=FSymBases(alg),
                                         bracket="",
                                         prefix=self._prefix)
    def __init__(self, base_ring, cell_complex, cohomology=False, cat=None):
        """
        Initialize ``self``.

        EXAMPLES::

            sage: RP2 = simplicial_complexes.ProjectivePlane()
            sage: H = RP2.homology_with_basis(QQ)
            sage: TestSuite(H).run()
            sage: H = RP2.homology_with_basis(GF(2))
            sage: TestSuite(H).run()
            sage: H = RP2.cohomology_ring(GF(2))
            sage: TestSuite(H).run()
            sage: H = RP2.cohomology_ring(GF(5))
            sage: TestSuite(H).run()
            sage: H = simplicial_complexes.ComplexProjectivePlane().cohomology_ring()
            sage: TestSuite(H).run()
        """
        # phi is the associated chain contraction.
        # M is the homology chain complex.
        phi, M = cell_complex.algebraic_topological_model(base_ring)
        if cohomology:
            phi = phi.dual()
            # We only need the rank of M in each degree, and since
            # we're working over a field, we don't need to dualize M
            # if working with cohomology.
        cat = Modules(base_ring).WithBasis().Graded().or_subcategory(cat)
        self._contraction = phi
        self._complex = cell_complex
        self._cohomology = cohomology
        self._graded_indices = {deg: range(M.free_module_rank(deg))
                                for deg in range(cell_complex.dimension()+1)}
        indices = [(deg, i) for deg in self._graded_indices
                   for i in self._graded_indices[deg]]
        CombinatorialFreeModule.__init__(self, base_ring, indices, category=cat)
Example #22
0
    def __init__(self, R, names=None):
        """
        Initialize ``self``.

        TESTS::

            sage: A = algebras.FreePreLie(QQ, '@'); A
            Free PreLie algebra on one generator ['@'] over Rational Field
            sage: TestSuite(A).run()

            sage: F = algebras.FreePreLie(QQ, 'xy')
            sage: TestSuite(F).run() # long time

            sage: F = algebras.FreePreLie(QQ, ZZ)
            sage: elts = F.some_elements()[:-1] # Skip the last element
            sage: TestSuite(F).run(some_elements=elts) # long time
        """
        if names.cardinality() == 1:
            Trees = RootedTrees()
            key = RootedTree.sort_key
        else:
            Trees = LabelledRootedTrees()
            key = LabelledRootedTree.sort_key
        # Here one would need LabelledRootedTrees(names)
        # so that one can restrict the labels to some fixed set

        self._alphabet = names
        cat = MagmaticAlgebras(R).WithBasis().Graded()
        CombinatorialFreeModule.__init__(self,
                                         R,
                                         Trees,
                                         latex_prefix="",
                                         sorting_key=key,
                                         category=cat)
Example #23
0
    def __init__(self, I, prefix='R'):
        """
        Initialize ``self``.

        TESTS::

            sage: P = posets.BooleanLattice(3)
            sage: R = P.incidence_algebra(QQ).reduced_subalgebra()
            sage: TestSuite(R).run()  # long time
        """
        self._ambient = I
        EC = {}
        P = self._ambient._poset
        if not P.is_finite():
            raise NotImplementedError("only implemented for finite posets")
        for i in self._ambient.basis().keys():
            S = P.subposet(P.interval(*i))
            added = False
            for k in EC:
                if S._hasse_diagram.is_isomorphic(k._hasse_diagram):
                    EC[k].append(i)
                    added = True
                    break
            if not added:
                EC[S] = [i]
        self._equiv_classes = map(sorted, EC.values())
        self._equiv_classes = {cls[0]: cls for cls in self._equiv_classes}
        cat = Algebras(I.base_ring()).FiniteDimensional().WithBasis()
        CombinatorialFreeModule.__init__(self, I.base_ring(),
                                         sorted(self._equiv_classes.keys()),
                                         prefix=prefix, category=cat)
Example #24
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 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 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())
Example #25
0
    def __init__(self, g, basis_key, prefix, **kwds):
        """
        Initialize ``self``.

        TESTS::

            sage: L = lie_algebras.sl(QQ, 2)
            sage: PBW = L.pbw_basis()
            sage: E,F,H = PBW.algebra_generators()
            sage: TestSuite(PBW).run(elements=[E, F, H])
            sage: TestSuite(PBW).run(elements=[E, F, H, E*F + H]) # long time
        """
        if basis_key is not None:
            self._basis_key = basis_key
        else:
            self._basis_key_inverse = None

        R = g.base_ring()
        self._g = g
        monomials = IndexedFreeAbelianMonoid(g.basis().keys(), prefix,
                                             sorting_key=self._monoid_key, **kwds)
        CombinatorialFreeModule.__init__(self, R, monomials,
                                         prefix='', bracket=False, latex_bracket=False,
                                         sorting_key=self._monomial_key,
                                         category=Algebras(R).WithBasis().Filtered())
Example #26
0
    def __init__(self, R, names=None):
        """
        Initialize ``self``.

        TESTS::

            sage: A = algebras.FreeDendriform(QQ, '@'); A
            Free Dendriform algebra on one generator ['@'] over Rational Field
            sage: TestSuite(A).run()  # long time (3s)

            sage: F = algebras.FreeDendriform(QQ, 'xy')
            sage: TestSuite(F).run() # long time (3s)
        """
        if names is None:
            Trees = BinaryTrees()
            key = BinaryTree._sort_key
            self._alphabet = Alphabet(['o'])
        else:
            Trees = LabelledBinaryTrees()
            key = LabelledBinaryTree._sort_key
            self._alphabet = names
        # Here one would need LabelledBinaryTrees(names)
        # so that one can restrict the labels to some fixed set
        
        cat = HopfAlgebras(R).WithBasis().Graded().Connected()
        CombinatorialFreeModule.__init__(self, R, Trees,
                                         latex_prefix="",
                                         sorting_key=key,
                                         category=cat)
Example #27
0
        def __init__(self, NCSymD):
            """
            EXAMPLES::

                sage: w = SymmetricFunctionsNonCommutingVariables(QQ).dual().w()
                sage: TestSuite(w).run()
            """

            def lt_set_part(A, B):
                A = sorted(map(sorted, A))
                B = sorted(map(sorted, B))
                for i in range(len(A)):
                    if A[i] > B[i]:
                        return 1
                    elif A[i] < B[i]:
                        return -1
                return 0

            CombinatorialFreeModule.__init__(
                self,
                NCSymD.base_ring(),
                SetPartitions(),
                prefix="w",
                bracket=False,
                monomial_cmp=lt_set_part,
                category=NCSymDualBases(NCSymD),
            )
Example #28
0
    def __init__(self, base_ring, cartan_type, level, twisted):
        """
        Initialize ``self``.

        EXAMPLES::

            sage: Q = QSystem(QQ, ['A',2])
            sage: TestSuite(Q).run()

            sage: Q = QSystem(QQ, ['E',6,2], twisted=True)
            sage: TestSuite(Q).run()
        """
        self._cartan_type = cartan_type
        self._level = level
        self._twisted = twisted
        indices = tuple(itertools.product(cartan_type.index_set(), [1]))
        basis = IndexedFreeAbelianMonoid(indices, prefix='Q', bracket=False)
        # This is used to do the reductions
        if self._twisted:
            self._cm = cartan_type.classical().cartan_matrix()
        else:
            self._cm = cartan_type.cartan_matrix()
        self._Irev = {ind: pos for pos,ind in enumerate(self._cm.index_set())}
        self._poly = PolynomialRing(ZZ, ['q'+str(i) for i in self._cm.index_set()])

        category = Algebras(base_ring).Commutative().WithBasis()
        CombinatorialFreeModule.__init__(self, base_ring, basis,
                                         prefix='Q', category=category)
Example #29
0
    def __init__(self, base_ring, n, variable_name, filtration):
        r"""
        Initialize ``self``.

        EXAMPLES::

            sage: Y = Yangian(QQ, 4, filtration='loop')
            sage: TestSuite(Y).run(skip="_test_antipode") # Not implemented
            sage: Y = Yangian(QQ, 4, filtration='natural')
            sage: G = Y.algebra_generators()
            sage: elts = [Y.one(), G[1,2,2], G[1,1,4], G[3,3,1], G[1,2,1]*G[2,1,4]]
            sage: TestSuite(Y).run(elements=elts)  # long time
        """
        self._n = n
        self._filtration = filtration
        category = HopfAlgebrasWithBasis(base_ring).Filtered()
        if filtration == 'natural':
            category = category.Connected()
        self._index_set = tuple(range(1,n+1))
        # The keys for the basis are tuples (l, i, j)
        indices = GeneratorIndexingSet(self._index_set)
        # We note that the generators are non-commutative, but we always sort
        #   them, so they are, in effect, indexed by the free abelian monoid
        basis_keys = IndexedFreeAbelianMonoid(indices, bracket=False,
                                              prefix=variable_name)
        CombinatorialFreeModule.__init__(self, base_ring, basis_keys,
                                         sorting_key=Yangian._term_key,
                                         prefix=variable_name, category=category)
    def __init__(self, g, basis_key, prefix, **kwds):
        """
        Initialize ``self``.

        TESTS::

            sage: L = lie_algebras.sl(QQ, 2)
            sage: PBW = L.pbw_basis()
            sage: E,F,H = PBW.algebra_generators()
            sage: TestSuite(PBW).run(elements=[E, F, H])
            sage: TestSuite(PBW).run(elements=[E, F, H, E*F + H]) # long time
        """
        if basis_key is not None:
            self._basis_key = basis_key

        R = g.base_ring()
        self._g = g
        monomials = IndexedFreeAbelianMonoid(g.basis().keys(),
                                             prefix,
                                             sorting_key=self._monoid_key,
                                             **kwds)
        CombinatorialFreeModule.__init__(
            self,
            R,
            monomials,
            prefix='',
            bracket=False,
            latex_bracket=False,
            sorting_key=self._monomial_key,
            category=Algebras(R).WithBasis().Filtered())
Example #31
0
    def __init__(self, submodule, category):
        r"""
        Initialize this quotient of a module with basis by a submodule.

        TESTS::

            sage: from sage.modules.with_basis.subquotient import QuotientModuleWithBasis
            sage: X = CombinatorialFreeModule(QQ, range(3), prefix="x"); x = X.basis()
            sage: I = X.submodule( (x[0]-x[1], x[1]-x[2]) )
            sage: Y = QuotientModuleWithBasis(I)
            sage: Y.print_options(prefix='y')
            sage: Y
            Free module generated by {2} over Rational Field
            sage: Y.category()
            Join of Category of finite dimensional modules with basis over Rational Field and Category of vector spaces with basis over Rational Field and Category of quotients of sets
            sage: Y.basis().list()
            [y[2]]
            sage: TestSuite(Y).run()
        """
        self._submodule = submodule
        self._ambient = submodule.ambient()
        embedding = submodule.lift
        indices = embedding.cokernel_basis_indices()
        CombinatorialFreeModule.__init__(self,
                                         submodule.base_ring(), indices,
                                         category=category)
Example #32
0
    def __init__(self, ct, c, t, base_ring, prefix):
        r"""
        Initialize ``self``.

        EXAMPLES::

            sage: k = QQ['c,t']
            sage: R = algebras.RationalCherednik(['A',2], k.gen(0), k.gen(1))
            sage: TestSuite(R).run()  # long time
        """
        self._c = c
        self._t = t
        self._cartan_type = ct
        self._weyl = RootSystem(ct).root_lattice().weyl_group(prefix=prefix[1])
        self._hd = IndexedFreeAbelianMonoid(ct.index_set(),
                                            prefix=prefix[0],
                                            bracket=False)
        self._h = IndexedFreeAbelianMonoid(ct.index_set(),
                                           prefix=prefix[2],
                                           bracket=False)
        indices = DisjointUnionEnumeratedSets([self._hd, self._weyl, self._h])
        CombinatorialFreeModule.__init__(
            self,
            base_ring,
            indices,
            category=Algebras(base_ring).WithBasis().Graded(),
            sorting_key=self._genkey)
Example #33
0
    def __init__(self, kBoundedRing):
        r"""
        TESTS::

            sage: Sym = SymmetricFunctions(QQ)
            sage: from sage.combinat.sf.new_kschur import kHomogeneous
            sage: KB = Sym.kBoundedSubspace(3,t=1)
            sage: kHomogeneous(KB)
            3-bounded Symmetric Functions over Rational Field with t=1 in the 3-bounded homogeneous basis
        """
        CombinatorialFreeModule.__init__(self, kBoundedRing.base_ring(),
            kBoundedRing.indices(),
            category= KBoundedSubspaceBases(kBoundedRing, kBoundedRing.t),
            prefix='h%d'%kBoundedRing.k)

        self._kBoundedRing = kBoundedRing

        self.k = kBoundedRing.k

        h = self.realization_of().ambient().homogeneous()

        self.lift = self._module_morphism(lambda x: h[x],
                codomain=h, triangular='lower', unitriangular=True,
                inverse_on_support=lambda p:p if p.get_part(0) <= self.k else None)

        self.ambient = ConstantFunction(h)

        self.lift.register_as_coercion()

        self.retract = SetMorphism(Hom(h, self, SetsWithPartialMaps()),
                self.lift.preimage)
        self.register_conversion(self.retract)
    def __init__(self, n, k, q, F):
        r"""
        Initialize ``self``.

        EXAMPLES::

            sage: Cl = algebras.QuantumClifford(1,2)
            sage: TestSuite(Cl).run(elements=Cl.basis())

            sage: Cl = algebras.QuantumClifford(1,3)
            sage: TestSuite(Cl).run(elements=Cl.basis())  # long time

            sage: Cl = algebras.QuantumClifford(3)  # long time
            sage: elts = Cl.some_elements() + list(Cl.algebra_generators())  # long time
            sage: TestSuite(Cl).run(elements=elts)  # long time

            sage: Cl = algebras.QuantumClifford(2,4)  # long time
            sage: elts = Cl.some_elements() + list(Cl.algebra_generators())  # long time
            sage: TestSuite(Cl).run(elements=elts)  # long time
        """
        self._n = n
        self._k = k
        self._q = q
        self._psi = cartesian_product([(-1,0,1)]*n)
        self._w_poly = PolynomialRing(F, n, 'w')
        indices = [(tuple(psi), tuple(w))
                   for psi in self._psi
                   for w in product(*[list(range((4-2*abs(psi[i]))*k)) for i in range(n)])]
        indices = FiniteEnumeratedSet(indices)

        cat = Algebras(F).FiniteDimensional().WithBasis()
        CombinatorialFreeModule.__init__(self, F, indices, category=cat)
        self._assign_names(self.algebra_generators().keys())
Example #35
0
    def __init__(self, A, category=None):
        """
        Initialize ``self``.

        EXAMPLES::

            sage: A = Algebras(QQ).WithBasis().Filtered().example()
            sage: grA = A.graded_algebra()
            sage: TestSuite(grA).run(elements=[prod(grA.algebra_generators())])
        """
        if A not in ModulesWithBasis(A.base_ring().category()).Filtered():
            raise ValueError("the base algebra must be filtered and with basis")
        self._A = A

        base_ring = A.base_ring()
        base_one = base_ring.one()

        category = A.category().Graded().or_subcategory(category)
        try:
            opts = copy(A.print_options())
            if not opts['prefix'] and not opts['bracket']:
                opts['bracket'] = '('
            opts['prefix'] = opts['prefix'] + 'bar'
        except AttributeError:
            opts = {'prefix': 'Abar'}

        CombinatorialFreeModule.__init__(self, base_ring, A.basis().keys(),
                                         category=category, **opts)

        # Setup the conversion back
        phi = self.module_morphism(diagonal=lambda x: base_one, codomain=A)
        self._A.register_conversion(phi)
Example #36
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()  # long time

        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()
        cat = GradedHopfAlgebrasWithBasis(R).Commutative().Connected()
        CombinatorialFreeModule.__init__(self, R, Words(names, infinite=False),
                                         latex_prefix="",
                                         category=cat)
Example #37
0
    def __init__(self, root_system, base_ring, index_set=None):
        """
        EXAMPLES::

            sage: e = RootSystem(['A',3]).ambient_lattice()
            sage: s = e.simple_reflections()

            sage: L = RootSystem(['A',3]).coroot_lattice()
            sage: e.has_coerce_map_from(L)
            True
            sage: e(L.simple_root(1))
            (1, -1, 0, 0)
        """
        self.root_system = root_system
        if index_set is None:
            index_set = tuple(range(0, self.dimension()))
        CombinatorialFreeModule.__init__(self, base_ring,
                                         index_set,
                                         prefix='e',
                                         category = WeightLatticeRealizations(base_ring))
        coroot_lattice = self.root_system.coroot_lattice()
        coroot_lattice.module_morphism(self.simple_coroot, codomain=self).register_as_coercion()

        # FIXME: here for backward compatibility;
        # Should we use dimension everywhere?
        self.n = self.dimension()
        ct = root_system.cartan_type()
        if ct.is_irreducible() and ct.type() == 'E':
            self._v0 = self([0,0,0,0,0, 0,1, 1])
            self._v1 = self([0,0,0,0,0,-2,1,-1])
Example #38
0
        def __init__(self, alg, prefix="D"):
            r"""
            Initialize ``self``.

            EXAMPLES::

                sage: TestSuite(DescentAlgebra(QQ, 4).D()).run()
            """
            self._prefix = prefix
            self._basis_name = "standard"
            p_set = subsets(range(1, alg._n))
            CombinatorialFreeModule.__init__(self,
                                             alg.base_ring(),
                                             map(tuple, p_set),
                                             category=DescentAlgebraBases(alg),
                                             bracket="",
                                             prefix=prefix)

            # Change of basis:
            B = alg.B()
            self.module_morphism(
                self.to_B_basis, codomain=B,
                category=self.category()).register_as_coercion()

            B.module_morphism(B.to_D_basis,
                              codomain=self,
                              category=self.category()).register_as_coercion()

            # Coercion to symmetric group algebra
            SGA = SymmetricGroupAlgebra(alg.base_ring(), alg._n)
            self.module_morphism(self.to_symmetric_group_algebra_on_basis,
                                 codomain=SGA,
                                 category=Algebras(
                                     alg.base_ring())).register_as_coercion()
Example #39
0
    def __init__(self, R, names=None):
        """
        Initialize ``self``.

        TESTS::

            sage: A = algebras.FreePreLie(QQ, '@'); A
            Free PreLie algebra on one generator ['@'] over Rational Field
            sage: TestSuite(A).run()

            sage: A = algebras.FreePreLie(QQ, None); A
            Free PreLie algebra on one generator ['o'] over Rational Field

            sage: F = algebras.FreePreLie(QQ, 'xy')
            sage: TestSuite(F).run() # long time
        """
        if names is None:
            Trees = RootedTrees()
            key = RootedTree.sort_key
            self._alphabet = Alphabet(['o'])
        else:
            Trees = LabelledRootedTrees()
            key = LabelledRootedTree.sort_key
            self._alphabet = names
        # Here one would need LabelledRootedTrees(names)
        # so that one can restrict the labels to some fixed set

        cat = MagmaticAlgebras(R).WithBasis().Graded() & LieAlgebras(R).WithBasis().Graded()
        CombinatorialFreeModule.__init__(self, R, Trees,
                                         latex_prefix="",
                                         sorting_key=key,
                                         category=cat)
Example #40
0
        def __init__(self, alg, prefix="I"):
            r"""
            Initialize ``self``.

            EXAMPLES::

                sage: TestSuite(DescentAlgebra(QQ, 4).B()).run()
            """
            self._prefix = prefix
            self._basis_name = "idempotent"
            CombinatorialFreeModule.__init__(self,
                                             alg.base_ring(),
                                             Compositions(alg._n),
                                             category=DescentAlgebraBases(alg),
                                             bracket="",
                                             prefix=prefix)

            ## Change of basis:
            B = alg.B()
            self.module_morphism(
                self.to_B_basis, codomain=B,
                category=self.category()).register_as_coercion()

            B.module_morphism(B.to_I_basis,
                              codomain=self,
                              category=self.category()).register_as_coercion()
Example #41
0
    def __init__(self, alg, graded=True):
        r"""
        Initialize ``self``.

        EXAMPLES::

            sage: G = algebras.FSym(QQ).G()
            sage: TestSuite(G).run()  # long time

        Checks for the antipode::

            sage: FSym = algebras.FSym(QQ)
            sage: G = FSym.G()
            sage: for b in G.basis(degree=3):
            ....:     print("%s : %s" % (b, b.antipode()))
            G[123] : -G[1|2|3]
            G[13|2] : -G[13|2]
            G[12|3] : -G[12|3]
            G[1|2|3] : -G[123]

            sage: F = FSym.dual().F()
            sage: for b in F.basis(degree=3):
            ....:     print("%s : %s" % (b, b.antipode()))
            F[123] : -F[1|2|3]
            F[13|2] : -F[13|2]
            F[12|3] : -F[12|3]
            F[1|2|3] : -F[123]
        """
        CombinatorialFreeModule.__init__(self, alg.base_ring(),
                                         StandardTableaux(),
                                         category=FSymBases(alg),
                                         bracket="", prefix=self._prefix)
    def __init__(self, base_ring, cell_complex, cohomology=False, category=None):
        """
        Initialize ``self``.

        EXAMPLES::

            sage: RP2 = simplicial_complexes.ProjectivePlane()
            sage: H = RP2.homology_with_basis(QQ)
            sage: TestSuite(H).run()
            sage: H = RP2.homology_with_basis(GF(2))
            sage: TestSuite(H).run()
            sage: H = RP2.cohomology_ring(GF(2))
            sage: TestSuite(H).run()
            sage: H = RP2.cohomology_ring(GF(5))
            sage: TestSuite(H).run()
            sage: H = simplicial_complexes.ComplexProjectivePlane().cohomology_ring()
            sage: TestSuite(H).run()
        """
        # phi is the associated chain contraction.
        # M is the homology chain complex.
        phi, M = cell_complex.algebraic_topological_model(base_ring)
        if cohomology:
            phi = phi.dual()
            # We only need the rank of M in each degree, and since
            # we're working over a field, we don't need to dualize M
            # if working with cohomology.
        category = Modules(base_ring).WithBasis().Graded().FiniteDimensional().or_subcategory(category)
        self._contraction = phi
        self._complex = cell_complex
        self._cohomology = cohomology
        self._graded_indices = {deg: range(M.free_module_rank(deg))
                                for deg in range(cell_complex.dimension()+1)}
        indices = [(deg, i) for deg in self._graded_indices
                   for i in self._graded_indices[deg]]
        CombinatorialFreeModule.__init__(self, base_ring, indices, category=category)
Example #43
0
    def __init__(self, cell_complex, degree, cells=None, base_ring=None):
        """
        EXAMPLES::

            sage: T = cubical_complexes.Torus()
            sage: T.n_chains(2, QQ, cochains=True)
            Free module generated by {[1,1] x [0,1] x [1,1] x [0,1],
             [0,0] x [0,1] x [0,1] x [1,1], [0,0] x [0,1] x [1,1] x [0,1],
             [0,0] x [0,1] x [0,0] x [0,1], [0,1] x [1,1] x [0,1] x [0,0],
             [0,1] x [0,0] x [0,0] x [0,1], [1,1] x [0,1] x [0,1] x [0,0],
             [0,1] x [1,1] x [0,0] x [0,1], [0,0] x [0,1] x [0,1] x [0,0],
             [0,1] x [0,0] x [0,1] x [0,0], [0,1] x [0,0] x [1,1] x [0,1],
             [0,1] x [1,1] x [1,1] x [0,1], [0,1] x [0,0] x [0,1] x [1,1],
             [1,1] x [0,1] x [0,0] x [0,1], [1,1] x [0,1] x [0,1] x [1,1],
             [0,1] x [1,1] x [0,1] x [1,1]} over Rational Field
            sage: T.n_chains(2).dimension()
            16

        TESTS::

            sage: T.n_chains(2, cochains=True).base_ring()
            Integer Ring
            sage: T.n_chains(8, cochains=True).dimension()
            0
            sage: T.n_chains(-3, cochains=True).dimension()
            0
        """
        if base_ring is None:
            base_ring = ZZ
        CellComplexReference.__init__(self, cell_complex, degree, cells=cells)
        CombinatorialFreeModule.__init__(
            self, base_ring, self._cells,
            prefix='\\chi',
            bracket=['_', '']
        )
Example #44
0
    def homogeneous_component(self, n):
        """
        Return the `n`-th homogeneous piece of the path algebra.

        INPUT:

        - ``n`` -- integer

        OUTPUT:

        - :class:`CombinatorialFreeModule`, module spanned by the paths
          of length `n` in the quiver

        EXAMPLES::

            sage: P = DiGraph({1:{2:['a'], 3:['b']}, 2:{4:['c']}, 3:{4:['d']}}).path_semigroup()
            sage: A = P.algebra(GF(7))
            sage: A.homogeneous_component(2)
            Free module spanned by [a*c, b*d] over Finite Field of size 7

            sage: D = DiGraph({1: {2: 'a'}, 2: {3: 'b'}, 3: {1: 'c'}})
            sage: P = D.path_semigroup()
            sage: A = P.algebra(ZZ)
            sage: A.homogeneous_component(3)
            Free module spanned by [a*b*c, b*c*a, c*a*b] over Integer Ring

        """
        basis = []
        for v in self._semigroup._quiver:
            basis.extend(self._semigroup.iter_paths_by_length_and_startpoint(n, v))
        M = CombinatorialFreeModule(self._base, basis, prefix='', bracket=False)
        M._name = "Free module spanned by {0}".format(basis)
        return M
Example #45
0
        def __init__(self, M, prefix='I'):
            """
            Initialize ``self``.

            TESTS::

                sage: L = posets.BooleanLattice(4)
                sage: M = L.moebius_algebra(QQ)
                sage: TestSuite(M.I()).run()
            """
            self._basis_name = "idempotent"
            CombinatorialFreeModule.__init__(self, M.base_ring(),
                                             tuple(M._lattice),
                                             prefix=prefix,
                                             category=MoebiusAlgebraBases(M))

            ## Change of basis:
            E = M.E()
            self.module_morphism(self._to_natural_basis,
                                 codomain=E, category=self.category(),
                                 triangular='lower', unitriangular=True
                                 ).register_as_coercion()

            E.module_morphism(E._to_idempotent_basis,
                              codomain=self, category=self.category(),
                              triangular='lower', unitriangular=True
                              ).register_as_coercion()
Example #46
0
    def __init__(self, A):
        r"""
        Initialize ``self``.

        EXAMPLES::

            sage: S = SymmetricGroupAlgebra(QQ, 3)
            sage: C = S.cellular_basis()
            sage: TestSuite(C).run()
        """
        self._algebra = A
        I = [(la, s, t) for la in A.cell_poset()
             for s in A.cell_module_indices(la)
             for t in A.cell_module_indices(la)]

        # TODO: Use instead A.category().Realizations() so
        #   operations are defined by coercion?
        cat = Algebras(A.category().base_ring()).FiniteDimensional().WithBasis().Cellular()
        CombinatorialFreeModule.__init__(self, A.base_ring(), I,
                                         prefix='C', bracket=False,
                                         category=cat)

        # Register coercions
        if A._to_cellular_element is not NotImplemented:
            to_cellular = A.module_morphism(A._to_cellular_element, codomain=self,
                                            category=cat)
        if A._from_cellular_index is NotImplemented:
            from_cellular = ~to_cellular
        else:
            from_cellular = self.module_morphism(A._from_cellular_index, codomain=A,
                                                 category=cat)
            if A._to_cellular_element is NotImplemented:
                to_cellular = ~from_cellular
        to_cellular.register_as_coercion()
        from_cellular.register_as_coercion()
Example #47
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 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 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())
Example #48
0
    def __init__(self, abstract, prefix, modules, index_set=None):
        """
        INPUT:
         - ``abstract`` -- the abstract character ring
         - ``prefix`` -- a string (e.g. "S", "P")
         - ``modules`` -- a string (e.g. "simple", "projective indecomposable")
         - ``index_set`` -- a list (or iterable) the indexing set for the basis

        By default, the index set is given by the index set for the
        simple modules.

        EXAMPLES::

            sage: G = HTrivialMonoids().Finite().example().character_ring(QQ)

        """
        self._abstract = abstract
        self._modules = modules
        if index_set is None:
            index_set = abstract.base().simple_modules_index_set()
        CombinatorialFreeModule.__init__(self,
                                         abstract.base_ring(), index_set,
                                         prefix = prefix,
                                         category = (abstract.character_ring_category().Realizations(),
                                                     abstract.Realizations()))
Example #49
0
        def __init__(self, alg, prefix="D"):
            r"""
            Initialize ``self``.

            EXAMPLES::

                sage: TestSuite(DescentAlgebra(QQ, 4).D()).run()
            """
            self._prefix = prefix
            self._basis_name = "standard"
            p_set = subsets(range(1, alg._n))
            CombinatorialFreeModule.__init__(self, alg.base_ring(),
                                             map(tuple, p_set),
                                             category=DescentAlgebraBases(alg),
                                             bracket="", prefix=prefix)

            # Change of basis:
            B = alg.B()
            self.module_morphism(self.to_B_basis,
                                 codomain=B, category=self.category()
                                 ).register_as_coercion()

            B.module_morphism(B.to_D_basis,
                              codomain=self, category=self.category()
                              ).register_as_coercion()

            # Coercion to symmetric group algebra
            SGA = SymmetricGroupAlgebra(alg.base_ring(), alg._n)
            self.module_morphism(self.to_symmetric_group_algebra,
                                 codomain=SGA, category=Algebras(alg.base_ring())
                                 ).register_as_coercion()
Example #50
0
    def __init__(self, root_system, base_ring, extended):
        """
        TESTS::

            sage: R = RootSystem(['A',4])
            sage: from sage.combinat.root_system.weight_space import WeightSpace
            sage: Q = WeightSpace(R, QQ); Q
            Weight space over the Rational Field of the Root system of type ['A', 4]
            sage: TestSuite(Q).run()

            sage: WeightSpace(R, QQ, extended = True)
            Traceback (most recent call last):
            ...
            AssertionError: extended weight lattices are only implemented for affine root systems
        """
        basis_keys = root_system.index_set()
        self._extended = extended
        if extended:
            assert root_system.cartan_type().is_affine(), "extended weight lattices are only implemented for affine root systems"
            basis_keys = tuple(basis_keys) + ("delta",)

        self.root_system = root_system
        CombinatorialFreeModule.__init__(self, base_ring,
                                         basis_keys,
                                         prefix = "Lambdacheck" if root_system.dual_side else "Lambda",
                                         latex_prefix = "\\Lambda^\\vee" if root_system.dual_side else "\\Lambda",
                                         category = WeightLatticeRealizations(base_ring))

        if root_system.cartan_type().is_affine() and not extended:
            # For an affine type, register the quotient map from the
            # extended weight lattice/space to the weight lattice/space
            domain = root_system.weight_space(base_ring, extended=True)
            domain.module_morphism(self.fundamental_weight,
                                   codomain = self
                                   ).register_as_coercion()
Example #51
0
            def central_form(self):
                r"""
                Return ``self`` expressed in the canonical basis of the center
                of the group algebra.

                INPUT:

                - ``self`` -- an element of the center of the group algebra

                OUTPUT:

                - A formal linear combination of the conjugacy class
                  representatives representing its coordinates in the
                  canonical basis of the center. See
                  :meth:`Groups.Algebras.ParentMethods.center_basis` for
                  details.

                .. WARNING::

                    - This method requires the underlying group to
                      have a method ``conjugacy_classes_representatives``
                      (every permutation group has one, thanks GAP!).
                    - This method does not check that the element is
                      indeed central. Use the method
                      :meth:`Monoids.Algebras.ElementMethods.is_central`
                      for this purpose.
                    - This function has a complexity linear in the
                      number of conjugacy classes of the group. One
                      could easily implement a function whose
                      complexity is linear in the size of the support
                      of ``self``.

                EXAMPLES::

                    sage: QS3 = SymmetricGroup(3).algebra(QQ)
                    sage: A = QS3([2,3,1]) + QS3([3,1,2])
                    sage: A.central_form()
                    B[(1,2,3)]
                    sage: QS4 = SymmetricGroup(4).algebra(QQ)
                    sage: B = sum(len(s.cycle_type())*QS4(s) for s in Permutations(4))
                    sage: B.central_form()
                    4*B[()] + 3*B[(1,2)] + 2*B[(1,2)(3,4)] + 2*B[(1,2,3)] + B[(1,2,3,4)]

                    sage: QG = GroupAlgebras(QQ).example(PermutationGroup([[(1,2,3),(4,5)],[(3,4)]]))
                    sage: sum(i for i in QG.basis()).central_form()
                    B[()] + B[(4,5)] + B[(3,4,5)] + B[(2,3)(4,5)] + B[(2,3,4,5)] + B[(1,2)(3,4,5)] + B[(1,2,3,4,5)]

                .. SEEALSO::

                    - :meth:`Groups.Algebras.ParentMethods.center_basis`
                    - :meth:`Monoids.Algebras.ElementMethods.is_central`
                """
                from sage.combinat.free_module import CombinatorialFreeModule
                conj_classes_reps = self.parent().basis().keys(
                ).conjugacy_classes_representatives()
                Z = CombinatorialFreeModule(self.base_ring(),
                                            conj_classes_reps)
                return sum(self[i] * Z.basis()[i] for i in Z.basis().keys())
Example #52
0
    def __init__(self, R, gens):
        """
        EXAMPLES::

            sage: L = LieAlgebras(QQ).WithBasis().example()
            sage: TestSuite(L).run()
        """
        cat = LieAlgebras(R).WithBasis()
        CombinatorialFreeModule.__init__(self, R, gens, category=cat)
Example #53
0
    def __init__(self, R, gens):
        """
        EXAMPLES::

            sage: L = LieAlgebras(QQ).WithBasis().example()
            sage: TestSuite(L).run()
        """
        cat = LieAlgebras(R).WithBasis()
        CombinatorialFreeModule.__init__(self, R, gens, category=cat)
Example #54
0
            def central_form(self):
                r"""
                Return ``self`` expressed in the canonical basis of the center
                of the group algebra.

                INPUT:

                - ``self`` -- an element of the center of the group algebra

                OUTPUT:

                - A formal linear combination of the conjugacy class
                  representatives representing its coordinates in the
                  canonical basis of the center. See
                  :meth:`Groups.Algebras.ParentMethods.center_basis` for
                  details.

                .. WARNING::

                    - This method requires the underlying group to
                      have a method ``conjugacy_classes_representatives``
                      (every permutation group has one, thanks GAP!).
                    - This method does not check that the element is
                      indeed central. Use the method
                      :meth:`Monoids.Algebras.ElementMethods.is_central`
                      for this purpose.
                    - This function has a complexity linear in the
                      number of conjugacy classes of the group. One
                      could easily implement a function whose
                      complexity is linear in the size of the support
                      of ``self``.

                EXAMPLES::

                    sage: QS3 = SymmetricGroup(3).algebra(QQ)
                    sage: A = QS3([2,3,1]) + QS3([3,1,2])
                    sage: A.central_form()
                    B[(1,2,3)]
                    sage: QS4 = SymmetricGroup(4).algebra(QQ)
                    sage: B = sum(len(s.cycle_type())*QS4(s) for s in Permutations(4))
                    sage: B.central_form()
                    4*B[()] + 3*B[(1,2)] + 2*B[(1,2)(3,4)] + 2*B[(1,2,3)] + B[(1,2,3,4)]

                    sage: QG = GroupAlgebras(QQ).example(PermutationGroup([[(1,2,3),(4,5)],[(3,4)]]))
                    sage: sum(i for i in QG.basis()).central_form()
                    B[()] + B[(4,5)] + B[(3,4,5)] + B[(2,3)(4,5)] + B[(2,3,4,5)] + B[(1,2)(3,4,5)] + B[(1,2,3,4,5)]

                .. SEEALSO::

                    - :meth:`Groups.Algebras.ParentMethods.center_basis`
                    - :meth:`Monoids.Algebras.ElementMethods.is_central`
                """
                from sage.combinat.free_module import CombinatorialFreeModule

                conj_classes_reps = self.parent().basis().keys().conjugacy_classes_representatives()
                Z = CombinatorialFreeModule(self.base_ring(), conj_classes_reps)
                return sum(self[i] * Z.basis()[i] for i in Z.basis().keys())
Example #55
0
    def __init__(self, base_ring):
        """
        EXAMPLES::

            sage: A = GradedModulesWithBasis(QQ).example(); A
            An example of a graded module with basis: the free module on partitions over Rational Field
            sage: TestSuite(A).run()
        """
        CombinatorialFreeModule.__init__(self, base_ring, Partitions(),
                                         category=GradedModulesWithBasis(base_ring))
Example #56
0
 def C(self, k):
     """The k-dimensional piece of the deConcini-Salvetti complex (C(k) = 0 for k < 0)."""
     if not k in self._modules:
         if k >= 0:
             self._modules[k] = CombinatorialFreeModule(
                 self.W.algebra(self.R), self.S(k))
         else:
             self._modules[k] = CombinatorialFreeModule(
                 self.W.algebra(self.R), [])
     return self._modules[k]
Example #57
0
    def __init__(self, R, G):
        """
        EXAMPLES::

            sage: from sage.categories.examples.group_algebras import MyGroupAlgebra
            sage: MyGroupAlgebra(ZZ,DihedralGroup(4)) # indirect doctest
            The group algebra of the Dihedral group of order 8 as a permutation group over Integer Ring
        """
        self._group = G
        CombinatorialFreeModule.__init__(self, R, G, category=GroupAlgebras(R))
Example #58
0
    def __init__(self, basis, grading=None, category=None):
        self._prime = detect_prime(category)
        CombinatorialFreeModule.__init__(
            self, GF(self._prime), basis, category=category
        )

        if grading is None:
            grading = SteenrodModuleGrading(basis, self)
        self._set_grading(grading)
        self._fix_basis_tests()
    def __init__(self, R, alphabet = ("a", "b", "c")):
        """
        EXAMPLES::

            sage: A = AlgebrasWithBasis(QQ).example(); A
            An example of an algebra with basis: the free algebra on the generators ('a', 'b', 'c') over Rational Field
            sage: TestSuite(A).run()

        """
        self._alphabet = alphabet
        CombinatorialFreeModule.__init__(self, R, Words(alphabet), category = AlgebrasWithBasis(R))
Example #60
0
        def __init__(self, QSym):
            """
            EXAMPLES::

                sage: M = QuasiSymmetricFunctions(QQ).Monomial(); M
                Quasisymmetric functions over the Rational Field in the Monomial basis
                sage: TestSuite(M).run()
            """
            CombinatorialFreeModule.__init__(self, QSym.base_ring(), Compositions(),
                                             prefix='M', bracket=False,
                                             category=QSym.Bases())