Beispiel #1
0
    def __init__(self, domain, action, category=None):
        """
        TESTS::

            sage: M = FiniteSetMaps(["a", "b", "c"])
            sage: M.category()
            Category of finite enumerated monoids
            sage: M.__class__
            <class 'sage.sets.finite_set_maps.FiniteSetEndoMaps_Set_with_category'>
            sage: TestSuite(M).run()
        """
        category = (EnumeratedSets()
                    & Monoids().Finite()).or_subcategory(category)
        FiniteSetMaps_MN.__init__(self,
                                  domain.cardinality(),
                                  domain.cardinality(),
                                  category=category)

        self._domain = domain
        self._codomain = domain

        import sage.combinat.ranker as ranker
        ldomain = domain.list()
        self._unrank_domain = ranker.unrank_from_list(ldomain)
        self._rank_domain = ranker.rank_from_list(ldomain)
        self._unrank_codomain = self._unrank_domain
        self._rank_codomain = self._rank_domain
        self._action = action
Beispiel #2
0
    def __init__(self, domain, action, category=None):
        """
        TESTS::

            sage: M = FiniteSetMaps(["a", "b", "c"])
            sage: M.category()
            Join of Category of finite monoids and Category of finite enumerated sets
            sage: M.__class__
            <class 'sage.sets.finite_set_maps.FiniteSetEndoMaps_Set_with_category'>
            sage: TestSuite(M).run()
        """
        category = (EnumeratedSets() & Monoids().Finite()).or_subcategory(category)
        FiniteSetMaps_MN.__init__(self, domain.cardinality(), domain.cardinality(),
                                 category=category)

        self._domain = domain
        self._codomain = domain

        import sage.combinat.ranker as ranker
        ldomain = domain.list()
        self._unrank_domain = ranker.unrank_from_list(ldomain)
        self._rank_domain = ranker.rank_from_list(ldomain)
        self._unrank_codomain = self._unrank_domain
        self._rank_codomain = self._rank_domain
        self._action = action
        def cartan_matrix(self, q = None, idempotents = None):
            """
            EXAMPLES::

                sage: import sage_semigroups.monoids.catalog as semigroups
                sage: M = semigroups.NDPFMonoidPoset(Posets(3)[3])
                sage: M.cartan_matrix(var('q'))
                [1 0 0 0]
                [0 1 q 0]
                [0 0 1 0]
                [0 0 0 1]

            The algorithm used for computing the q-Cartan matrix is
            experimental. It has been tested for the 0-Hecke monoid in
            types A1-A4, B2-3,G2, and for NDPFMonoidB 1-5.

                sage: M =  PiMonoid(["A",3])               # long time
                sage: m1 = M.cartan_matrix(var('q'))       # long time
                sage: m2 = M.cartan_matrix_mupad(var('q')) # long time
                sage: isomorphic_cartan_matrices(m1,m2)    # long time
                True

                sage: M =  PiMonoid(["A",4])               # long time
                sage: m1 = M.cartan_matrix(var('q'))       # long time
                sage: m2 = M.cartan_matrix_mupad(var('q')) # long time
                sage: isomorphic_cartan_matrices(m1,m2)    # long time
                True

            The current version *does* fail for the 0-Hecke monoid of
            type D_4!!!

                sage: ZZ.<q> = ZZ[]
                sage: list(sum(sum(PiMonoid(["D",4]).cartan_matrix(q)))) # long time
                [16, 38, 62, 35, 20, 15, 6]

            Compare with:

                sage: list(sum(sum(PiMonoid(["D",4]).cartan_matrix_mupad(q)))) # long time
                [16, 38, 62, 38, 20, 12, 6]

            Which could mean that the factorization constraints are too weak.

            """
            #left_symbols,  right_modules = cartan_data_of_j_trivial_monoid(self, side="left" )
            #right_symbols, left_modules  = cartan_data_of_j_trivial_monoid(self, side="right")
            if idempotents is None:
                idempotents = self.idempotents()
            #idempotents = [self.retract(self.ambient.e(w)) for w in self.ambient.W]
            rank = rank_from_list(idempotents)
            from sage.matrix.constructor import matrix
            if q is None:
                cartan_matrix = matrix(len(idempotents), len(idempotents), sparse=True)
            else:
                cartan_matrix = matrix(q.parent(), len(idempotents), len(idempotents), sparse=True)
            for (e,f),coeff in self.cartan_matrix_as_table(q).iteritems():
                cartan_matrix[rank(e), rank(f)] = coeff
            return cartan_matrix
Beispiel #4
0
        def cartan_matrix(self, q = None, idempotents = None):
            """
            EXAMPLES::

                sage: import sage_semigroups.monoids.catalog as semigroups
                sage: M = semigroups.NDPFMonoidPoset(Posets(3)[3])
                sage: M.cartan_matrix(var('q'))
                [1 0 0 0]
                [0 1 q 0]
                [0 0 1 0]
                [0 0 0 1]

            The algorithm used for computing the q-Cartan matrix is
            experimental. It has been tested for the 0-Hecke monoid in
            types A1-A4, B2-3,G2, and for NDPFMonoidB 1-5.

                sage: M =  PiMonoid(["A",3])               # long time
                sage: m1 = M.cartan_matrix(var('q'))       # long time
                sage: m2 = M.cartan_matrix_mupad(var('q')) # long time
                sage: isomorphic_cartan_matrices(m1,m2)    # long time
                True

                sage: M =  PiMonoid(["A",4])               # long time
                sage: m1 = M.cartan_matrix(var('q'))       # long time
                sage: m2 = M.cartan_matrix_mupad(var('q')) # long time
                sage: isomorphic_cartan_matrices(m1,m2)    # long time
                True

            The current version *does* fail for the 0-Hecke monoid of
            type D_4!!!

                sage: ZZ.<q> = ZZ[]
                sage: list(sum(sum(PiMonoid(["D",4]).cartan_matrix(q)))) # long time
                [16, 38, 62, 35, 20, 15, 6]

            Compare with:

                sage: list(sum(sum(PiMonoid(["D",4]).cartan_matrix_mupad(q)))) # long time
                [16, 38, 62, 38, 20, 12, 6]

            Which could mean that the factorization constraints are too weak.

            """
            #left_symbols,  right_modules = cartan_data_of_j_trivial_monoid(self, side="left" )
            #right_symbols, left_modules  = cartan_data_of_j_trivial_monoid(self, side="right")
            if idempotents is None:
                idempotents = self.idempotents()
            #idempotents = [self.retract(self.ambient.e(w)) for w in self.ambient.W]
            rank = rank_from_list(idempotents)
            from sage.matrix.constructor import matrix
            if q is None:
                cartan_matrix = matrix(len(idempotents), len(idempotents), sparse=True)
            else:
                cartan_matrix = matrix(q.parent(), len(idempotents), len(idempotents), sparse=True)
            for (e,f),coeff in self.cartan_matrix_as_table(q).iteritems():
                cartan_matrix[rank(e), rank(f)] = coeff
            return cartan_matrix
Beispiel #5
0
    def __init__(self, domain, codomain, category=None):
        """
        EXAMPLES::

            sage: M = FiniteSetMaps(["a", "b"], [3, 4, 5])
            sage: M
            Maps from {'a', 'b'} to {3, 4, 5}
            sage: M.cardinality()
            9
            sage: for f in M: print(f)
            map: a -> 3, b -> 3
            map: a -> 3, b -> 4
            map: a -> 3, b -> 5
            map: a -> 4, b -> 3
            map: a -> 4, b -> 4
            map: a -> 4, b -> 5
            map: a -> 5, b -> 3
            map: a -> 5, b -> 4
            map: a -> 5, b -> 5

        TESTS::

            sage: M.__class__
            <class 'sage.sets.finite_set_maps.FiniteSetMaps_Set_with_category'>
            sage: M.category()
            Category of finite enumerated sets
            sage: TestSuite(M).run()
        """
        FiniteSetMaps_MN.__init__(self,
                                  domain.cardinality(),
                                  codomain.cardinality(),
                                  category=category)

        self._domain = domain
        self._codomain = codomain

        import sage.combinat.ranker as ranker
        ldomain = domain.list()
        lcodomain = codomain.list()
        self._unrank_domain = ranker.unrank_from_list(ldomain)
        self._rank_domain = ranker.rank_from_list(ldomain)
        self._unrank_codomain = ranker.unrank_from_list(lcodomain)
        self._rank_codomain = ranker.rank_from_list(lcodomain)
Beispiel #6
0
    def __init__(self, domain, codomain, category=None):
        """
        EXAMPLES::

            sage: M = FiniteSetMaps(["a", "b"], [3, 4, 5])
            sage: M
            Maps from {'a', 'b'} to {3, 4, 5}
            sage: M.cardinality()
            9
            sage: for f in M: print f
            map: a -> 3, b -> 3
            map: a -> 3, b -> 4
            map: a -> 3, b -> 5
            map: a -> 4, b -> 3
            map: a -> 4, b -> 4
            map: a -> 4, b -> 5
            map: a -> 5, b -> 3
            map: a -> 5, b -> 4
            map: a -> 5, b -> 5

        TESTS::

            sage: M.__class__
            <class 'sage.sets.finite_set_maps.FiniteSetMaps_Set_with_category'>
            sage: M.category()
            Category of finite enumerated sets
            sage: TestSuite(M).run()
        """
        FiniteSetMaps_MN.__init__(self, domain.cardinality(), codomain.cardinality(),
                                 category=category)

        self._domain = domain
        self._codomain = codomain

        import sage.combinat.ranker as ranker
        ldomain = domain.list()
        lcodomain = codomain.list()
        self._unrank_domain = ranker.unrank_from_list(ldomain)
        self._rank_domain = ranker.rank_from_list(ldomain)
        self._unrank_codomain = ranker.unrank_from_list(lcodomain)
        self._rank_codomain = ranker.rank_from_list(lcodomain)
        def cartan_matrix(self, q=None):
            """
            EXAMPLES::

                sage: M = Monoids().HTrivial().Finite().example(4); M
                The finite H-trivial monoid of order preserving maps on {1, .., 4}
                sage: M.cartan_matrix()
                [1 1 0 0]
                [0 1 1 0]
                [0 0 1 1]
                [0 0 0 1]


            """
            from sage.combinat.ranker import rank_from_list
            index_set = list(self.simple_modules_index_set())
            rank = rank_from_list(index_set)
            from sage.matrix.constructor import matrix
            cartan_matrix = matrix(len(index_set), len(index_set), sparse=True)
            for (i, j), coeff in self.cartan_matrix_as_table().iteritems():
                cartan_matrix[rank(i), rank(j)] = coeff
            return cartan_matrix
        def cartan_matrix(self, q = None):
            """
            EXAMPLES::

                sage: M = Monoids().HTrivial().Finite().example(4); M
                The finite H-trivial monoid of order preserving maps on {1, .., 4}
                sage: M.cartan_matrix()
                [1 1 0 0]
                [0 1 1 0]
                [0 0 1 1]
                [0 0 0 1]


            """
            from sage.combinat.ranker import rank_from_list
            index_set = list(self.simple_modules_index_set())
            rank = rank_from_list(index_set)
            from sage.matrix.constructor import matrix
            cartan_matrix = matrix(len(index_set), len(index_set), sparse=True)
            for (i,j),coeff in self.cartan_matrix_as_table().iteritems():
                cartan_matrix[rank(i), rank(j)] = coeff
            return cartan_matrix
Beispiel #9
0
def polarizationSpace(P, generators, verbose=False, row_symmetry=None, use_commutativity=False, side="down"):
    """
    Starting from  polynomials (generators)of the polynomial ring in one 
    set of variables (possibly with additional inert variables), constructs
    the space obtained by polarization.
    
    The possible values for row_symmetry : 
        - "permutation" : the action of the symmetric group on the rows
        - "euler+intersection" or "decompose" or "multipolarization" for stategies on lie algebras
    
    INPUT:
    
        - `P` -- a diagonal polynomial ring (or assymmetric version)
        - `generators`: polynomials in one set of variables (and possibly inert variables) 
            
    OUTPUT: `F`  -- a Subspace

    EXAMPLES::
        sage: load("derivative_space.py")
        sage: P = DiagonalPolynomialRing(QQ, 3, 2, inert=1)
        sage: mu = Partition([3])
        sage: basis = DerivativeHarmonicSpace(QQ, mu.size()).basis_by_shape(Partition([2,1]))
        sage: generators = {}
        sage: for gen in basis : 
        ....:     d = P.multidegree((P(gen)))
        ....:     if d in generators.keys():
        ....:         generators[d] += [P(gen)]
        ....:     else:
        ....:         generators[d] = [P(gen)]
        sage: generators
        {(2, 0): [1/3*x00^2 - 2/3*x00*x01 + 2/3*x01*x02 - 1/3*x02^2],
         (1, 0): [-2*x00 + 2*x02]}
        sage: S = polarizationSpace(P, generators)
        sage: S.basis()
        {(0, 1): (x10 - x12,),
         (2, 0): (-1/2*x00^2 + x00*x01 - x01*x02 + 1/2*x02^2,),
         (1, 0): (x00 - x02,),
         (1, 1): (x00*x10 - x01*x10 - x00*x11 + x02*x11 + x01*x12 - x02*x12,),
         (0, 2): (1/2*x10^2 - x10*x11 + x11*x12 - 1/2*x12^2,)}
         
        sage: basis = DerivativeVandermondeSpaceWithInert(QQ, mu).basis_by_shape(Partition([1,1,1]))
        sage: generators = {P.multidegree(P(gen)): [P(gen) for gen in g] for (d,g) in basis.iteritems()}
        sage: generators
        {(3, 0): [-x00^2*x01 + x00*x01^2 + x00^2*x02 - x01^2*x02 - x00*x02^2 + x01*x02^2]}
        sage: S = polarizationSpace(P, generators)
        sage: S.basis()
        {(1, 2): (-1/2*x01*x10^2 + 1/2*x02*x10^2 - x00*x10*x11 + x01*x10*x11 + 1/2*x00*x11^2 - 1/2*x02*x11^2 + x00*x10*x12 - x02*x10*x12 - x01*x11*x12 + x02*x11*x12 - 1/2*x00*x12^2 + 1/2*x01*x12^2,),
         (3, 0): (x00^2*x01 - x00*x01^2 - x00^2*x02 + x01^2*x02 + x00*x02^2 - x01*x02^2,),
         (0, 3): (x10^2*x11 - x10*x11^2 - x10^2*x12 + x11^2*x12 + x10*x12^2 - x11*x12^2,),
         (1, 1): (-x01*x10 + x02*x10 + x00*x11 - x02*x11 - x00*x12 + x01*x12,),
         (2, 1): (-x00*x01*x10 + 1/2*x01^2*x10 + x00*x02*x10 - 1/2*x02^2*x10 - 1/2*x00^2*x11 + x00*x01*x11 - x01*x02*x11 + 1/2*x02^2*x11 + 1/2*x00^2*x12 - 1/2*x01^2*x12 - x00*x02*x12 + x01*x02*x12,)}
        
        sage: mu = Partition([2,1])
        sage: basis = DerivativeVandermondeSpaceWithInert(QQ, mu).basis_by_shape(Partition([2,1]))
        sage: generators = {P.multidegree(P(gen)): [P(gen) for gen in g] for (d,g) in basis.iteritems()}
        sage: generators
        {(0, 0): [-theta00 + theta02]}
        sage: S = polarizationSpace(P, generators)
        sage: S.basis()
        {(0, 0): (theta00 - theta02,)}

    """
    S = SymmetricFunctions(QQ)
    s = S.s()
    m = S.m()
    r = P._r
    
    if isinstance(P, DiagonalAntisymmetricPolynomialRing):
        antisymmetries = P._antisymmetries
    else:
        antisymmetries = None
        
    if row_symmetry in ("euler+intersection", "decompose", "multipolarization")  :
        # The hilbert series will be directly expressed in terms of the
        # dimensions of the highest weight spaces, thus as a symmetric
        # function in the Schur basis
        def hilbert_parent(dimensions):
            return s.sum_of_terms([Partition(d), c]
                                   for d,c in dimensions.iteritems() if c)
    elif row_symmetry == "permutation":
        def hilbert_parent(dimensions):
            return s(m.sum_of_terms([Partition(d), c]
                                     for d,c in dimensions.iteritems())
                    ).restrict_partition_lengths(r, exact=False)
    else:
        def hilbert_parent(dimensions):
            return s(S.from_polynomial(P._hilbert_parent(dimensions))
                    ).restrict_partition_lengths(r,exact=False)

    operators = polarization_operators_by_multidegree(P, side=side, row_symmetry=row_symmetry, min_degree=1 if row_symmetry and row_symmetry!="permutation" else 0)
    #ajout operateurs Steenrod
    #for i in range(1, r):
    #    for d in [2,3]:
    #        operators[P._grading_set((-d+1 if j==i else 0 for j in range(0,r)))] = [functools.partial(P.steenrod_op, i=i, k=d)]
    
    if row_symmetry == "euler+intersection":
        operators[P._grading_set.zero()] = [
            functools.partial(lambda v,i: P.polarization(P.polarization(v, i+1, i, 1, antisymmetries=antisymmetries), i, i+1, 1, antisymmetries=antisymmetries), i=i)
            for i in range(r-1)]
    elif row_symmetry == "decompose":
        def post_compose(f):
            return lambda x: [q for (q,word) in P.highest_weight_vectors_decomposition(f(x))]
        operators = {d: [post_compose(op) for op in ops]for d, ops in operators.iteritems()}
    elif row_symmetry == "multipolarization":
        F = HighestWeightSubspace(generators,
                 ambient=self,
                 add_degrees=add_degree, degree=P.multidegree,
                 hilbert_parent = hilbert_parent,
                 antisymmetries=antisymmetries,
                 verbose=verbose)
        return F
        
    operators_by_degree = {}
    for degree,ops in operators.iteritems(): 
        d = sum(degree)
        operators_by_degree.setdefault(d,[])
        operators_by_degree[d].extend(ops)

    ranks = {}
    for d, ops in operators_by_degree.iteritems():
        ranker = rank_from_list(ops)
        for op in ops:
            ranks[op] = (d, ranker(op))
    ranker = ranks.__getitem__
    def extend_word(word, op):
        new_word = word + [ranker(op)]
        if use_commutativity and sorted(new_word) != new_word:
            return None
        return new_word

    if row_symmetry == "permutation":
        add_deg = add_degree_symmetric
    else:
        add_deg = add_degree
    
    F = Subspace(generators, operators=operators,
                 add_degrees=add_deg, degree=P.multidegree,
                 hilbert_parent = hilbert_parent,
                 extend_word=extend_word, verbose=verbose) 
    F._antisymmetries = antisymmetries
    return F