Exemplo n.º 1
0
def build_ssb(size):
    if size == 1:
        sst_list = bss.build_stacks(size)
        return [[
            s,
        ] for s in sst_list]
    else:
        prev_list = [[
            sst,
        ] for sst in bss.build_stacks(size)]

        for idx in reversed(range(1, size)):

            sst_list = bss.build_stacks(idx)

            new_list = []

            for sst in sst_list:
                for prev in prev_list:
                    if is_compatible(sst, prev[-1]):
                        new_list.append([
                            sst,
                        ] + prev)

            prev_list = new_list

        return new_list
Exemplo n.º 2
0
def compare_pst():
    pst = build.build_pst(3)
    #for x in pst:
    #    print(x)
    #print(len(pst))

    plat = build.build_plateaus(build.build_stacks(3), 3)
    print(len(plat))

    print('plateaus not pst are:')
    for p in plat:
        if p not in pst:
            print(p)

    flipped_ogogs = flip_ogog_list(ogog3)

    print('ogogs are')
    for ogog in ogog3:
        print(ogog)

    print('flipped ogogs not pst are:')
    for f in flipped_ogogs:
        if f not in pst:
            for row in f:
                print(f)
Exemplo n.º 3
0
def compare_plateau_to_gog():
    for nn in range(4, 5):
        sst = build.build_stacks(nn)
        stacks = build.build_plateaus(sst, nn)
        #print_stack_list(stacks)
        #stacks = stats.one_one_per_row(stacks, nn)
        #print(len(stacks))
        #print_stack_list(stacks)
        #print(stack_list_to_tex(stacks))

        #start_of_row_stats(nn)

        temp_list = []
        # [ [a], [b,c], [d, e, f] ] to [ [d], [b, e], [a, c, f]]
        for stack in stacks:
            temp = [[stack[2][0]], [stack[1][0], stack[2][1]],
                    [stack[0][0], stack[1][1], stack[2][2]]]
            temp_list.append(temp)

        # [ [a], [b,c], [d, e, f] ] to [ [d], [e, b], [f, c, a]]
        #for stack in stacks:
        #    temp = [[ stack[2][0]], [stack[2][1], stack[1][0]],  [stack[2][2], stack[1][1], stack[0][0]]]
        #    temp_list.append(temp)

        print_stack_list(stacks)
Exemplo n.º 4
0
def invert_is_sst(stacks, n):
    good_stacks = []
    sst = build.build_stacks(n)
    for stack in stacks:
        inv_stack = build.invert(stack)
        if inv_stack in sst:
            good_stacks.append(inv_stack)
    return good_stacks
Exemplo n.º 5
0
def reflect_is_sst(stacks, n):
    sst = build.build_stacks(n)
    good_stacks = []
    for stack in stacks:
        reflect_stack = build.reflect(stack)
        if reflect_stack in sst:
            good_stacks.append(reflect_stack)

    return good_stacks
Exemplo n.º 6
0
def start_of_row_stats(nn):
    print(nn)
    my_set = set()
    stacks2 = build.build_stacks(nn)
    for s in stacks2:
        #for x in s:
        #    print(x)
        #print('----')
        key = 0
        for idx, row in enumerate(s):
            if 0 in row:
                val = row.index(0) + 1
            else:
                val = 0
            key = 10**(idx) * val + key
        my_set.add(key)

    #for key in my_set:
    #    print(key)

    print('len key=', len(my_set))

    print('num sst', len(stacks2))

    # the non-permutations: more than one 1 in a row
    # bad_stacks = []
    # for s in stacks2:
    #     good = True
    #     for x in s:
    #         if sum(x) > 1:
    #             good = False
    #             break
    #     if good == False:
    #         bad_stacks.append(s)

    #for b in bad_stacks:
    #for x in b:
    #print(x)
    #print('----')
    #print(len(bad_stacks))

    #stacks3 = []
    #for s in stacks:
    #    if s in stacks2:
    #        stacks3.append(s)

    #print('in both: ', len(stacks3))
    #print('in sst only: ', len(stacks2) -  len(stacks3))
    print('--------')
Exemplo n.º 7
0
def get_sst_seq(n):
    sst_list = bss.build_stacks(n)

    if n == 1:
        return [[
            t,
        ] for t in sst_list]
    else:
        new_list = []
        prev_seq_list = get_sst_seq(n - 1)

        for sst in sst_list:
            for seq in prev_seq_list:
                prev_sst = seq[0]

                if is_sst_compatible(sst, prev_sst):
                    new_list.append([
                        sst,
                    ] + seq)

    return new_list
Exemplo n.º 8
0
def compare_plateau_to_gog_two():
    for nn in range(3, 4):
        sst = build.build_stacks(nn)
        temp_list = []
        for stack in sst:
            temp = [[stack[2][0]], [stack[1][0], stack[2][1]],
                    [stack[0][0], stack[1][1], stack[2][2]]]
            temp_list.append(temp)

        # print_stack_list(temp_list)

        plateau_stacks = build.build_plateaus(temp_list, nn)
        # print_stack_list(stacks)
        # stacks = stats.one_one_per_row(stacks, nn)
        # print(len(stacks))
        # print_stack_list(stacks)
        # print(stack_list_to_tex(stacks))

        # start_of_row_stats(nn)

        print_stack_list(temp_list)
Exemplo n.º 9
0
def transform_stacks(n):
    stacks = build.build_stacks(n)
    return [transform_stack(stack) for stack in stacks]
Exemplo n.º 10
0
def write_bin_layers(bin_list, layer_list, suffix):

    sst_list = bss.build_stacks(len(bin_list[0]))


    lines = util.get_tex_header()

    num = -1
    for bin_tri, layer_tri in zip(bin_list, layer_list):

        num += 1

        if True:

            # need to invert this mapping!
            xinv = [[1 - a for a in row] for row in bin_tri]

            omega_before = binary_comb.get_omega_for_cliff(xinv)
            B, D = binary_comb.comb(xinv)
            omega = binary_comb.get_omega(B, D)

            print(layer_tri)
            size = len(layer_tri)



            binlayer_list = [ binary_for_layer(row, size) for row in layer_tri ]

            #binlayer_list = [ [row for row in reversed(tri)]  for tri in binlayer_list]



            #### this implementation rotates the triangle!!!!

            print('binary:', bin_tri)
            for x in binlayer_list:
                print('\t', x)

            rot_bin_tri = util.rotate_triangle(bin_tri)



            rot_bin_tri = [row for row in reversed(rot_bin_tri)]

#            if rot_bin_tri in sst_list:
            if True:


                lines.append('\\subsubsection*{Triangle Number ' + str(num) + '}')
                lines.append('')



                lines.append('\\begin{tikzpicture}[scale=.5]')

                lines.append('\\node at (0,' + str(3  * size + 1) + ') {')
                lines.append(util.to_tex_ytableau([ row for row in reversed(rot_bin_tri)]))
                lines.append('};')


                lines.append('\\begin{scope}[shift={(0,' + str(3  * size/ 2) + ')}]')
                lines.append(util.omega_to_tangle(invert_bin_to_omega(rot_bin_tri)))
                lines.append('\\end{scope}')

                lines.append('\\begin{scope}[shift={(0,0)}]')
                lines.append(util.omega_to_tangle(invert_bin_to_combed_omega(rot_bin_tri)))
                lines.append('\\end{scope}')



                for count,bl in enumerate(binlayer_list):




                    lines.append('\\node at (' + str( (count +1) * 3/2 * size ) + ',' + str(3  * size +1) + ') {')
                    lines.append(util.to_tex_ytableau([row for row in reversed(bl)]))
                    lines.append('};')

                    lines.append('\\begin{scope}[shift={(' + str((count + 1) * 3/2 * size) + ',' + str(3  * size/ 2) + ')}]')
                    lines.append(util.omega_to_tangle(invert_bin_to_omega(bl)))
                    lines.append('\\end{scope}')


                    lines.append('\\begin{scope}[shift={(' + str((count + 1) * 3/2 * size) + ',0)}]')
                    lines.append(util.omega_to_tangle(invert_bin_to_combed_omega(bl)))
                    lines.append('\\end{scope}')

                lines.append('\\end{tikzpicture}')
                lines.append('')
                lines.append('\medskip')


    lines = lines + util.get_tex_footer()





    file_name = '/Users/abeverid/PycharmProjects/asm/data/sst_layer_' + suffix + str(size) + '.tex'


    print('writing to', file_name)

    out_file = open(file_name, 'w')

    out_file.writelines(["%s\n" % item for item in lines])
Exemplo n.º 11
0
def build_trees(size):
    sst_list = build_stack_set.build_stacks(size)
    sst_list = stack_set_stats.one_one_per_col(sst_list, size)

    tree_list = []

    for sst in sst_list:
        index_list = []
        for row in sst:
            index_list.append([i for i, x in enumerate(row) if x == 1])

        #### match to the rightmost available
        #m = len(index_list[-1])
        #path_list = []
        # for idx in range(1,m+1):
        #     path = [index_list[-1][-idx]+1]
        #     for row_idx in range(2,size+1):
        #         print(index_list[-row_idx], 'has size', len(index_list[-row_idx]))
        #         if len(index_list[-row_idx]) >= idx:
        #             path.append(index_list[-row_idx][-idx]+1)
        #
        #     path_list.append(path)

        #### match to the "first available"
        #### this actually seems to do worse. ugh!
        path_list = [[
            x,
        ] for x in index_list[-1]]

        print('processing ', sst)

        for k in reversed(range(size - 1)):
            taken_idx_list = []
            row_idx_list = index_list[k]

            for val in reversed(row_idx_list):
                for i, path in enumerate(path_list):
                    if not i in taken_idx_list and val < path[-1]:
                        print('\tmatching', val, 'to', path[-1])
                        taken_idx_list.append(i)
                        path.append(val)
                        break

        path_list = [[x + 1 for x in path] for path in path_list]

        print('\t\t', path_list)

        tree_list.append(path_list)

    print('THE INVOLUTIONS')

    sst_inv_list = []

    for sst, tree in zip(sst_list, tree_list):
        #print(tree)
        inv = tree_to_involution(tree)
        #print(inv)

        temp = [0] * size

        for x in inv:
            if len(x) == 1:
                val = x[0]
                temp[val - 1] = val
            else:
                v1 = x[0]
                v2 = x[1]
                temp[v1 - 1] = v2
                temp[v2 - 1] = v1

        print(temp)

        if str(temp) == '[3, 4, 1, 2, 5]':
            print('duplicate', inv, 'tree', tree)
            util.print_array(sst)

        sst_inv_list.append(temp)
        #util.print_array(sst)

    print(len(sst_inv_list))

    inv_list = get_involutions(size)
    for x in inv_list:
        if not x in sst_inv_list:
            print('missing', x)
    print(len(inv_list))
Exemplo n.º 12
0
def compare_words():
    for size in range(4, 5):

        sst_list = build_stack_set.build_stacks(size)
        sst_list = stack_set_stats.one_one_per_col(sst_list, size)

        words = get_words(size)
        bad_count = 0

        good_tri_list = []

        bad_map = dict()

        for w in words:
            t = word_to_triangle(w)
            is_sst = check_sst(t)

            if not is_sst:
                print(w)
                util.print_array(t)
                key = get_key(t)

                if not key in bad_map:
                    bad_map[key] = []

                bad_map[key].append(t)

                bad_count += 1
            else:
                good_tri_list.append(t)

        print('size', size)
        print('total', len(words))
        print('bad', bad_count)
        print('good', len(words) - bad_count)

        sst_unmatched_map = dict()

        for sst in sst_list:
            if not sst in good_tri_list:
                key = get_key(sst)

                if not key in sst_unmatched_map:
                    sst_unmatched_map[key] = []
                sst_unmatched_map[key].append(sst)
        print('bad map', len(bad_map))
        print('sst unmatched map', len(sst_unmatched_map))

        print('--------------')

    for key in bad_map:
        print('==================')
        word_list = bad_map[key]
        sst_list = sst_unmatched_map[key]
        print('KEY', key, 'bad', len(word_list), 'sst', len(sst_list))
        print('words')
        for w in word_list:
            util.print_array(w)
        print('sst')
        for s in sst_list:
            util.print_array(s)
Exemplo n.º 13
0
def get_stack_set(size):
    sst_list = bss.build_stacks(size)

    return [[row for row in reversed(t)] for t in sst_list]
Exemplo n.º 14
0
def explore_zeros_and_hooks(n):

    stacks = build.build_stacks(n)
    #stacks = [[ [1], [1, 1], [1, 0, 1], [0, 1, 1, 1]],]

    #stacks = [ [ [1], [1, 0], [1, 1, 0], [1, 0, 0, 1], [0, 1, 1, 1, 1]], ]
    #for s in stacks[0]:
    #    print(s)

    zero_map = dict()
    total_zeros = 0
    total_min_nested_hooks = 0
    total_correct_nest = 0
    compare_count = 0

    for stack in stacks:
        # print(stack)

        #size = len(stack)
        # num_ones = 0
        # for s in stack:
        #    num_ones = num_ones + s[0]

        # if num_ones < size+1:

        ells = get_ells(stack)

        z = len(ells)

        if not z in zero_map:
            zero_map[z] = 0

        zero_map[z] = zero_map[z] + 1
        total_zeros = total_zeros + z

        if len(ells) > 1:
            hooks = [hook.Hook(ell[0], ell[1], ell[2]) for ell in ells]

            #for s in stack:
            #    print('\t\t', s)

            for pair in itertools.combinations(hooks, 2):
                if pair[0].update_comparison(pair[1]):
                    #print('comparable', pair[0].toString(), pair[1].toString())
                    compare_count = compare_count + 1

            for h in hooks:
                #print('minimal=', h.is_minimal())
                if h.is_minimal() and h.has_hooks_above():
                    print(h.toString(), len(h.hooks_below), 'above count',
                          len(h.hooks_above))
                    # let's assume it's the height of this poset rather than the width of
                    # height 1.

                    height = h.get_height_above()

                    #total_min_nested_hooks  = total_min_nested_hooks + h.get_num_directly_above()
                    total_min_nested_hooks = total_min_nested_hooks + 1
                    #total_min_nested_hooks  = total_min_nested_hooks + height
                    #total_min_nested_hooks = total_min_nested_hooks + height - h.get_num_directly_above()
                    if len(h.hooks_above) > 1:
                        for s in stack:
                            print(s)
                        print('>>>>>>>', h.toString(), 'nests',
                              len(h.hooks_above))
                        print('\t\tand directly above =',
                              h.get_num_directly_above())

        # if z == 2:
        #    for x in stack:
        #        print(x)
        #    print('---------')

    print('total min nested hooks', total_min_nested_hooks)
    print('total comparable hook pairs', compare_count)
    print('total zeros', total_zeros)
    total = total_zeros + total_min_nested_hooks
    print('total', total)
    for key in zero_map:
        print(key, 'zeros:', zero_map[key])
Exemplo n.º 15
0
# weak incr col and one one per row 2,4,7,11,16,22   A000124
# weak incr col and exact one per row 1
# weak incr col and one one per diag  2,5,13,34,89,233  A001519
# weak incr col and exact one per diag  1,2,4,8,16,32

# weak dec col and one one per row 4,8,16,32,64
# weak dec col and exact one per row 2,4,16,32
# weak dec col and one one per diag  1,3,4,5,6
# weak dec col and exact one per diag  1

# invert is stackset 6, 28, 202, 2252
# reflect is stackset 6, 25, 149, 1259
# invert reflect is stackset 6, 26, 158, 1332

nn = 3
stacks = build.build_stacks(nn)
#stacks = build.build_inverted_stacks(nn)
#stacks0 = stats.one_one_per_col(stacks,nn)
#stacks0 = stats.one_one_per_row(stacks, nn)
#good_stacks = stats.one_one_per_diag(stacks,nn)
#good_stacks = stats.one_one_per_row(stacks0,nn)
good_stacks = stats.cols_weak_decreasing(stacks, nn)
#good_stacks = stats.reflect_is_sst(stacks,nn)
#good_stacks = stats.invert_is_sst(stacks, nn)
#good_stacks = stats.has_num_zero_below_one(stacks, 1, nn)
#good_stacks = stacks

for s in good_stacks:
    util.print_array(s)

print(len(good_stacks))