def classical_avoiders_2_nonempty(p1, p2, n): return StaticPermutationSet.from_predicate( lambda x: len(x) > 0 and x.avoids(p1) and x.avoids(p2), n, description='Av(%s, %s) nonempty' % (str(p1), str(p2)))
def from_predicate(pred, desc, n): return StaticPermutationSet.from_predicate(pred, n, description=desc)
def input_without_decr(perm_prop, n): return StaticPermutationSet.from_predicate( lambda x: perm_prop(x) and not x.avoids([1, 2]), n, description='input without decr')
def classical_avoiders_2(p1, p2, n): return StaticPermutationSet.from_predicate( lambda x: x.avoids(p1) and x.avoids(p2), n, description='Av(%s, %s)' % (str(p1), str(p2)))
# for l in range(1, 8): # cnt = 0 # for p in Permutations(l): # if avoids_231_vinc(p) and p.avoids([1,2,3]): # cnt += 1 # # print(p) # print(l, cnt) # # import sys # sys.exit(0) avoiders_len_3 = [] for p in Permutations(3): avoiders_len_3.append((lambda perm: perm.avoids(p),StaticPermutationSet.from_predicate(lambda x: x.avoids(p), 6, description='Av(%s)' % str(p)))) # avoiders_len_3.append((lambda perm: len(perm) >= 3 and perm.avoids(p),StaticPermutationSet.from_predicate(lambda x: x.avoids(p), 6, description='Av(%s)' % str(p)))) incr = SimpleGeneratingRule(Permutation([1,2]), [X, P], description='increasing').to_static(8, empty) decr = SimpleGeneratingRule(Permutation([2,1]), [X, P], description='decreasing').to_static(8, empty) incr_nonempty = SimpleGeneratingRule(Permutation([1,2]), [X, P], description='increasing nonempty').to_static(8, {1:[Permutation([1])]}) decr_nonempty = SimpleGeneratingRule(Permutation([2,1]), [X, P], description='decreasing nonempty').to_static(8, {1:[Permutation([1])]}) max_len = 6 n_range = (2, 3) # number of rows (min, max) m_range = (2, 3) # numbor of columns (min, max) max_nonempty = 4 max_ec_cnt = 4
def classical_avoiders(p, n): return StaticPermutationSet.from_predicate(lambda x: x.avoids(p), n, description='Av(%s)' % str(p))
def classical_avoiders_2_nonempty(p1, p2, n): return StaticPermutationSet.from_predicate(lambda x: len(x) > 0 and x.avoids(p1) and x.avoids(p2), n, description='Av(%s, %s) nonempty' % (str(p1), str(p2)))
def classical_avoiders_2(p1, p2, n): return StaticPermutationSet.from_predicate(lambda x: x.avoids(p1) and x.avoids(p2), n, description='Av(%s, %s)' % (str(p1), str(p2)))
def input_without_decr(perm_prop, n): return StaticPermutationSet.from_predicate(lambda x: perm_prop(x) and not x.avoids([1,2]), n, description='input without decr')