def extend_to_length(self, l): for i in range(self.length + 1, l + 1): self.append(permset.PermSet()) if (l <= self.length): return old = self.length self.length = l for n in range(old + 1, l + 1): for P in self[n - 1]: insertion_locations = P.insertion_locations add_this_time = [] for Q in P.right_extensions(): is_good = True for B in self.basis: if B.involved_in(Q, last_require=2): is_good = False insertion_locations[Q[-1]] = 0 # break if is_good: add_this_time.append(Q) for Q in add_this_time: # print Q,'is good' # print '\tchanging IL from ',Q.insertion_locations,'to',(insertion_locations[:Q[-1]+1]+ insertion_locations[Q[-1]:]) Q.insertion_locations = insertion_locations[:Q[ -1] + 1] + insertion_locations[Q[-1]:] self[n].add(Q)
def all_extensions(self): S = set() for i in range(0, len(self) + 1): for j in range(0, len(self) + 1): # insert (i-0.5) after entry j (i.e., first when j=0) l = list(self[:]) l.insert(j, i - 0.5) S.add(Permutation(l)) return permset.PermSet(S)
def sum_indec_bdd_by(self, n): l = [1] S = list(self.children()) while len(S) > 0 and len(S[0]) > 0: l = [len([s for s in S if not s.sum_decomposable()])] + l if l[0] > n: return False S = list(permset.PermSet(S).layer_down()) return True
def right_juxtaposition(self, C, generate_perms=True): A = permset.PermSet() max_length = max([len(P) for P in self.basis]) + max( [len(P) for P in C.basis]) for n in range(2, max_length + 1): for i in range(0, factorial(n)): P = Permutation(i, n) for Q in self.basis: for R in C.basis: if len(Q) + len(R) == n: if (Q == Permutation(P[0:len(Q)]) and R == Permutation(P[len(Q):n])): A.add(P) elif len(Q) + len(R) - 1 == n: if (Q == Permutation(P[0:len(Q)]) and Permutation(R) == Permutation( P[len(Q) - 1:n])): A.add(P) return AvClass(list(A.minimal_elements()), length=(8 if generate_perms else 0))
def all_syms(self): S = permset.PermSet([self]) S = S.union(permset.PermSet([P.reverse() for P in S])) S = S.union(permset.PermSet([P.complement() for P in S])) S = S.union(permset.PermSet([P.inverse() for P in S])) return S
def downset(self): return permset.PermSet([self]).downset()