# Ticket #14136: trac_14136_p_partition_enumerator_v1.patch

File trac_14136_p_partition_enumerator_v1.patch, 3.6 KB (added by chapoton, 8 years ago)
• ## sage/combinat/posets/posets.py

# HG changeset patch
# User Frederic Chapoton <chapoton at math.univ-lyon1.fr>
# Date 1367338060 -7200
# Node ID 6edbb91649bc49f824ea9346e729089eb096a29f
# Parent  d38af13415d6e01c39449656a183a533f951e553
trac #14136 implement P-partition enumerator of a poset

diff --git a/sage/combinat/posets/posets.py b/sage/combinat/posets/posets.py
 a This module implements finite partialy o :meth:~FinitePoset.order_filter | Returns the order filter generated by a list of elements. :meth:~FinitePoset.order_ideal | Returns the order ideal generated by a list of elements. :meth:~FinitePoset.order_polytope | Returns the order polytope of the poset. :meth:~FinitePoset.p_partition_enumerator | Returns a P-partition enumerator of the poset. :meth:~FinitePoset.plot | Returns a Graphic object corresponding the Hasse diagram of the poset. :meth:~FinitePoset.product | Returns the cartesian product of self and other. :meth:~FinitePoset.promotion | Computes the (extended) promotion on the linear extension of the poset self class FinitePoset(UniqueRepresentation, return False return True def p_partition_enumerator(self, tup, R, check=False): r""" return a P-partition enumerator of self This is a quasisymmetric function which depends on a total order on the vertices of the poset. INPUT: - tup -- tuple: the elements of P in some total order; this does not have to be a linear extension. - R -- commutative ring OUTPUT: the P-partition enumerator of self according to tup in the algebra QSym over the base ring R. This is the quasisymmetric function \sum\limits_{f\text{ a }P\text{-partition}} \prod\limits_{p \in P} x_{f(p)}, where a P-partition is a function P \to \{1,2,3,...\} satisfying the following properties: For any two elements i and j of P, - if i < j then f(i) \leq f(j), - if i < j and i appears left of j in tup then f(i) < f(j). EXAMPLES:: sage: P = Poset([[1,2,3,4],[[1,4],[2,4],[4,3]]]) sage: FP = P.p_partition_enumerator((3,1,2,4), QQ, check=True);FP 2*M[1, 1, 1, 1] + 2*M[1, 2, 1] + M[2, 1, 1] + M[3, 1] sage: expansion = FP.expand(5) sage: xs = expansion.parent().gens() sage: expansion == sum([xs[a]*xs[b]*xs[c]*xs[d] for a in range(5) for b in range(5) for c in range(5) for d in range(5) if a <= b and c <= b and b < d]) True sage: P = Poset([[],[]]) sage: FP = P.p_partition_enumerator((), QQ, check=True) ; FP M[] """ if check: if sorted(self.list()) != sorted(tup): raise ValueError("the elements of tup are not those of P") from sage.combinat.ncsf_qsym.qsym import QuasiSymmetricFunctions from sage.combinat.composition import Composition print('no error yet') QR = QuasiSymmetricFunctions(R) print('error is before this line') n = len(tup) res = QR.zero() tupdict = dict(zip(tup, range(n))) for lin in self.linear_extensions(facade=True): descents = [i + 1 for i in xrange(n-1) if tupdict[lin[i]] > tupdict[lin[i+1]]] res += QR.Fundamental()(Composition(from_subset=(descents, n))) return res FinitePoset._dual_class = FinitePoset ##### Posets #####