# 1: decreasing # set([(0, 1), (0, 0), (0, 2)]), InputPermutationSet() permProp = lambda p: p.avoids([2, 3, 1]) G = OverlayGeneratingRule([[decr, N, X], [N, P, N]], [(set([(0, 1), (0, 0), (0, 2)]), InputPermutationSet(permProp))]) # +-+-+-+ # |X| |X| # +-+-+-+ # | |o| | # +-+-+-+ # set([(0, 1), (0, 0), (0, 2)]), InputPermutationSet() permProp = lambda p: p.avoids([1, 3, 2, 4]) G = OverlayGeneratingRule( [[X, N, X], [N, P, N]], # [ (set([(0, 1), (0, 0), (0, 2)]), InputPermutationSet(permProp)) ] [(set([(0, 0), (0, 2)]), InputPermutationSet(permProp))]) # print(generate_all_of_length(6, G, empty)) for l, perms in sorted(generate_all_of_length(6, G, empty).items()): # print(l, perms) # print(sorted(perms)) print(l, len(perms)) assert len(perms) == len(set(perms)) # # print(perms) for perm in perms: assert permProp(Permutation(perm))
[ (set([(0, 1), (0, 0), (0, 2)]), InputPermutationSet(permProp)) ] ) # +-+-+-+ # |X| |X| # +-+-+-+ # | |o| | # +-+-+-+ # set([(0, 1), (0, 0), (0, 2)]), InputPermutationSet() permProp = lambda p: p.avoids([1,3,2,4]) G = OverlayGeneratingRule([ [X, N, X], [N, P, N] ], # [ (set([(0, 1), (0, 0), (0, 2)]), InputPermutationSet(permProp)) ] [ (set([(0, 0), (0, 2)]), InputPermutationSet(permProp)) ] ) # print(generate_all_of_length(6, G, empty)) for l, perms in sorted(generate_all_of_length(6, G, empty).items()): # print(l, perms) # print(sorted(perms)) print(l, len(perms)) assert len(perms) == len(set(perms)) # # print(perms) for perm in perms: assert permProp(Permutation(perm))
# [P,P], # [P,P], # ]) G = GeneratingRule([ [P,P,P,P], [P,P,P,P], [P,P,P,P], [P,P,P,P], ]) # av321_132 = (lambda perm: perm.avoids(Permutation([3,2,1])) and perm.avoids(Permutation([1,3,2])),StaticPermutationSet.from_predicate(lambda x: x.avoids(p), 6, description='Av(%s,%s)' % (Permutation([3,2,1]), Permutation([1,3,2])))) # inp_without_incr = (lambda perm: perm.avoids(p), StaticPermutationSet.from_predicate(lambda x: x.avoids(p), 6, description='input without incr')) # # res = generate_all_of_length(10, G, {0:[()], 1:[(1,)]}, 2) res = generate_all_of_length(8, G, {0:[()]}, 2) # # print(res) for l in res: # print(res) print(len(res[l])) # # import sys # sys.exit(0) inputs = [ (permProp, X), (lambda perm: len(perm) == 1, P), (lambda perm: perm == Permutation(sorted(perm)), incr), (lambda perm: perm == Permutation(sorted(perm)[::-1]), decr), (lambda perm: len(perm) >= 1 and perm == Permutation(sorted(perm)), incr_nonempty),