Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
GuillaumeLaplante-Anfossi
GitHub Repository: GuillaumeLaplante-Anfossi/Poissons
Path: blob/main/GeneratingDiagonalsViaShift/SU_degeneracy.py
1017 views
1
'''
2
SU degeneracy projections,
3
using Proposition 6 of DIAGONALS ON THE PERMUTAHEDRA, MULTIPLIHEDRA AND ASSOCIAHEDRA.
4
'''
5
from itertools import combinations
6
7
from diagonals_via_shift import SU_diag, LA_diag
8
9
10
def exceptional(A,k):
11
'''
12
return: True if the subset A_k is exceptional, False if not
13
'''
14
minAk = min(A[k])
15
maxAk = max(A[k])
16
17
for x in A[k+1:]:
18
for aij in x:
19
if minAk < aij and aij < maxAk:
20
return True
21
22
return False
23
24
def Mult_filter(A):
25
for j in range(len(A)-1):
26
minAj = min(A[j])
27
if (min(A[j]) > min([min(x) for x in A[j+1:]])) and exceptional(A,j):
28
return False
29
30
return True
31
32
def LA_Mult_diag(n):
33
valid = []
34
for p in LA_diag(n):
35
if Mult_filter(p[0]) and Mult_filter(p[1]):
36
valid.append(p)
37
38
return valid
39
40
def SU_Mult_diag(n):
41
valid = []
42
for p in SU_diag(n):
43
if Mult_filter(p[0]) and Mult_filter(p[1]):
44
valid.append(p)
45
46
return valid
47
48
def Assoc_filter(A):
49
for k in range(len(A)-1):
50
if exceptional(A,k):
51
return False
52
53
return True
54
55
def LA_Assoc_diag(n):
56
valid = []
57
for p in LA_diag(n):
58
if Assoc_filter(p[0]) and Assoc_filter(p[1]):
59
valid.append(p)
60
61
return valid
62
63
def SU_Assoc_diag(n):
64
valid = []
65
for p in SU_diag(n):
66
if Assoc_filter(p[0]) and Assoc_filter(p[1]):
67
valid.append(p)
68
69
return valid
70
71
def compare_Mult(n):
72
LA = sorted(LA_Mult_diag(n))
73
SU = sorted(SU_Mult_diag(n))
74
75
LA_only = []
76
SU_only = []
77
shared = []
78
for x in LA:
79
if x in SU:
80
shared.append(x)
81
else:
82
LA_only.append(x)
83
for x in SU:
84
if x not in LA:
85
SU_only.append(x)
86
87
return LA, LA_only, shared, SU_only, SU
88
89
def compare_Assoc(n):
90
LA = sorted(LA_Assoc_diag(n))
91
SU = sorted(SU_Assoc_diag(n))
92
93
LA_only = []
94
SU_only = []
95
shared = []
96
for x in LA:
97
if x in SU:
98
shared.append(x)
99
else:
100
LA_only.append(x)
101
for x in SU:
102
if x not in LA:
103
SU_only.append(x)
104
105
return LA, LA_only, shared, SU_only, SU
106
107
108
def iso2(p,n):
109
'''
110
Applies the iso t(r x r)
111
'''
112
def r(op,n):
113
rev = []
114
for block in op:
115
revblock = []
116
for x in block:
117
revblock.append(n-x+1)
118
rev.append(sorted(revblock))
119
return rev
120
121
def iso1(p):
122
'''
123
Applies the iso t(s x s)
124
'''
125
return [p[1][::-1],p[0][::-1]]
126
127
if __name__ == '__main__':
128
129
print("\nAssoc")
130
for n in range(1,6):
131
print("\nn={}".format(n))
132
LA, LA_only, shared, SU_only, SU = compare_Assoc(n)
133
134
print("|LA|={}, |LA only|={}, |shared|={}, |SU only|={}, |SU|={}".format(
135
len(LA), len(LA_only), len(shared), len(SU_only), len(SU)))
136
137
print("\nMult")
138
for n in range(1,8):
139
print("\nn={}".format(n))
140
LA, LA_only, shared, SU_only, SU = compare_Mult(n)
141
142
print("|LA|={}, |LA only|={}, |shared|={}, |SU only|={}, |SU|={}".format(
143
len(LA), len(LA_only), len(shared), len(SU_only), len(SU)))
144
145
146