Sage cell
Use this to produce the statistic values!
xxxxxxxxxx
1
# code by Jang Soo Kim
2
def delete_elements(P,A):
3
"Return the poset obtained from P by deleting the elements in A"
4
elms = [x for x in P.list() if x not in A]
5
rels = [R for R in P.relations() if R[0] not in A and R[1] not in A]
6
return Poset([elms,rels], cover_relations=False)
7
8
def add_bottom(P):
9
"Return the poset obtained from P by adding the minimum element 0."
10
elms = ["zero_hat"] + P.list()
11
rels = [["zero_hat",x] for x in P.list()] + P.relations()
12
return Poset([elms,rels], cover_relations=False)
13
14
def Poin(P,t,omega=0):
15
"""
16
Input:
17
18
P: a poset or a list of numbers [a,b,c,...].
19
If P = [a,b,c,...], then P is set to be the cell poset of the partition [a,b,c,...].
20
21
t: a variable
22
23
omega: a labeling of P which is given by default to the first lin ext of P.
24
25
Output: The Poincare polynomial of the poset P.
26
The bijection from linear extensions to P-transverse permutations is used.
27
"""
28
if type(P) == list:
29
P = Partition(P).cell_poset().dual()
30
if omega == 0:
31
omega = P.linear_extensions()[0]
32
poly = 0
33
for L in P.linear_extensions():
34
poly += t^(len(P)-len(get_P_transverse_permutation(P,omega,L)))
35
return poly
36
37
def get_P_transverse_permutation(P,omega,L):
38
"""
39
Input:
40
P: a poset
41
omega: a labeling of P
42
L: a linear extension of P
43
44
Output: The P-transverse permutation corresponding to L with respect to omega.
45
"""
46
Q = add_bottom(P)
47
pi = []
48
while len(L)>0:
49
N = next_level(Q,P,omega,L)
50
pi = pi + N[-1]
51
[Q, P, omega, L] = N[:-1]
52
return pi
53
54
def next_level(Q,P,omega,L):
55
"""
56
INPUT: Q,P,omega,L
57
Q: poset containing P
58
omega: labeling
59
L: a linear extension of P
60
61
OUTPUT: [Q1, P1, omega, L1, pi]
62
Q1 = P
63
P1 = P - minimal blocks
64
omega = omega
65
L1 = L restricted to P1
66
pi = P-transverse permutation of the minimal blocks in P.
67
"""
68
L1 = L
69
pi = []
70
C = [] # the list of current level elements in P
71
D = [] # the list of current level elements in P that are not minimal in Q
72
B = []
73
for x in L:
74
if x not in P.minimal_elements(): # If x is not a minimal element in P this level is done.
75
break
76
C.append(x)
77
if x not in Q.minimal_elements():
78
D.append(x)
79
if omega.index(x) == min([omega.index(d) for d in D]):
80
if len(B)>0:
81
pi.append(B)
82
B = [x]
83
else:
84
B.append(x)
85
pi.append(B)
86
Q1 = P
87
P1 = delete_elements(P,C)
88
L1 = L[len(C):]
89
return [Q1, P1, omega, L1, pi]
90
91
statistic = lambda P: Poin(P, -1)
92
93
94
def parent_initializer(n):
95
class MyPosets():
96
def __iter__(self):
97
for P in Posets(n):
98
yield P
99
def cardinality(self):
100
l = [1, 1, 2, 5, 16, 63, 318, 2045, 16999, 183231, 2567284, 46749427, 1104891746, 33823827452, 1338193159771, 68275077901156, 4483130665195087]
101
if n < len(l):
102
return l[n]
103
else:
104
return Infinity
105
return MyPosets()
106
element_repr = lambda X: str( ( sorted(X._hasse_diagram.canonical_label().cover_relations()), len(X._hasse_diagram.vertices(sort=False)) ) )
107
levels = [2, 3, 4, 5]
108
for level in levels:
109
for elt in parent_initializer(level):
110
print('%s => %s' % (element_repr(elt), statistic(elt)))
Messages
searching the database
Sorry, this statistic was not found in the database
or
add this statistic to the database – it's very simple and we need your support!