Beispiel #1
0
def d_plus_raw(gen):  #checked
    ''' d_+ map that smooths a black-black crossing of a generator `gen`
    of CT-(T_i)) contained in right halfs ( i- 1/2, i)
    Returns a list of elements of the form ((s1, s2), d_plus_raw_term), where
    s1 < s2 are pairs of strands that d_plus is applied, and
    diff_term is a generator in d_plus() obtained by uncrossing these two
    strands. Together they specify all terms in gen.d_plus(). '''
    # applying it to line Bj
    lst = []
    l_strands = list(gen.strands.left_converted.items())
    r_strands = list(gen.strands.right_converted.items())
    types = mod_helper(l_strands, r_strands)
    t_r = list(gen.tangle.r_pairs_wc.items())
    r_crossings = types[4]  # type 4 : right crossings
    for s1, s2 in r_crossings:
        r_s_pairs = r_strands.copy()
        r_s_pairs.remove(s1)
        r_s_pairs.remove(s1)
        is_crossed = False
        for strands in r_s_pairs:  # check double black - black crossing
            if mod_between(strands, (s1[0], s2[0]), (s1[1], s2[1]),
                           False) == 0:
                is_crossed = True
                break
        for tangle in t_r:  # tangle double cross a strand
            if mod_between(tangle, (s1[0], s2[0]), (s1[1], s2[1]), False) == 0:
                is_crossed = True
                break
        if not is_crossed:
            lst.append(mod_helper_2(gen, s1, s2, is_crossed))
    return lst
Beispiel #2
0
def d_minus_raw(gen):  # checked
    '''d_- map that introduces a black-black crossing to a generator 'gen`
    of CT-(T_i) contained in left halfs, (i, i+1/2).
    Returns a list of elements of the form ((s1, s2), d_minus_raw_term), where
    s1 < s2 are pairs of strands that d_minus is applied, and
        diff_term is a generator in d_minus() obtained by crossing these two
        strands. Together they specify all terms in gen.d_minus(). '''
    lst = []  # applying it to line Bj
    l_strands = list(gen.strands.left_converted.items())
    r_strands = list(gen.strands.right_converted.items())
    types = mod_helper(l_strands, r_strands)
    t_l = list(gen.tangle.l_pairs_wc.items())
    # type 1 : left horizontals
    horizontals = types[1]
    for s1, s2 in horizontals:
        l_s_pairs = l_strands.copy()
        is_crossed = False
        l_s_pairs.remove(s1)
        l_s_pairs.remove(s2)
        for strands in l_s_pairs:  # check double strand-strand crossing
            if mod_between(strands, (s1[0], s2[0]), (s1[1], s2[1]), True) == 0:
                is_crossed = True
                break
        for tangle in t_l:  # tangle double cross a strand
            if mod_between(tangle, (s1[0], s2[0]), (s1[1], s2[1]), True) == 0:
                is_crossed = True
                break
        if not is_crossed:
            lst.append(mod_helper_2(gen, s1, s2))
    return lst
Beispiel #3
0
def d_plus_raw(gen): #checked
    ''' d_+ map that smooths a black-black crossing of a generator `gen`
    of CT-(T_i)) contained in right halfs ( i- 1/2, i)
    Returns a list of elements of the form ((s1, s2), d_plus_raw_term), where
    s1 < s2 are pairs of strands that d_plus is applied, and
    diff_term is a generator in d_plus() obtained by uncrossing these two
    strands. Together they specify all terms in gen.d_plus(). '''    
    # applying it to line Bj
    lst = []
    l_strands = list(gen.strands.left_converted.items())
    r_strands = list(gen.strands.right_converted.items())
    types = mod_helper(l_strands, r_strands)
    t_r = list(gen.tangle.r_pairs_wc.items())
    r_crossings = types[4] # type 4 : right crossings
    for s1, s2 in r_crossings: 
        r_s_pairs = r_strands.copy()
        r_s_pairs.remove(s1)
        r_s_pairs.remove(s1)
        is_crossed = False
        for strands in r_s_pairs:# check double black - black crossing
            if mod_between(strands, (s1[0],s2[0]),(s1[1],s2[1]), False) == 0:
                is_crossed = True
                break
        for tangle in t_r:# tangle double cross a strand
            if mod_between(tangle, (s1[0],s2[0]),(s1[1],s2[1]), False) == 0:
                is_crossed = True
                break
        if not is_crossed:
                lst.append(mod_helper_2(gen, s1, s2, is_crossed))
    return lst
Beispiel #4
0
def d_minus_raw(gen): # checked
    '''d_- map that introduces a black-black crossing to a generator 'gen`
    of CT-(T_i) contained in left halfs, (i, i+1/2).
    Returns a list of elements of the form ((s1, s2), d_minus_raw_term), where
    s1 < s2 are pairs of strands that d_minus is applied, and
        diff_term is a generator in d_minus() obtained by crossing these two
        strands. Together they specify all terms in gen.d_minus(). ''' 
    lst = [] # applying it to line Bj
    l_strands = list(gen.strands.left_converted.items())
    r_strands = list(gen.strands.right_converted.items())
    types = mod_helper(l_strands, r_strands)
    t_l = list(gen.tangle.l_pairs_wc.items())
    # type 1 : left horizontals
    horizontals = types[1]
    for s1, s2 in horizontals:
        l_s_pairs = l_strands.copy() 
        is_crossed = False
        l_s_pairs.remove(s1)
        l_s_pairs.remove(s2)
        for strands in l_s_pairs: # check double strand-strand crossing
            if mod_between(strands, (s1[0],s2[0]),(s1[1],s2[1]),True)==0:
                is_crossed = True  
                break
        for tangle in t_l:# tangle double cross a strand
            if mod_between(tangle, (s1[0],s2[0]),(s1[1],s2[1]),True) == 0:
                is_crossed = True
                break
        if not is_crossed:
                lst.append(mod_helper_2(gen, s1, s2))
    return lst
Beispiel #5
0
def helper(tang_left, tang_right, pair_1, pair_2, pair_3, is_left, option):
    ''' Helper methods for diff methods. Assumes compatibility. Given a generator x, taking the is_left side, 
    exchanges pairs = (a,b), it seems whether the 
    whether it violates `option`. Refer to options.jpg
    for options.  
    * tang_left is dictionary object of pairs 
    * tang_right is dictionary object of pairs 
    * Pair_1 is the coordinate of two pairs of strand on the left
    * Pair_2 is the coordinate of two pairs of strand in the middle
    * Pair_3 is the coordinate of two pairs of strand in the right.'''
    mod = False
    if is_left:  # only check mod relations 1,2,3
        for k, v in tang_left.items():
            if option == 1:
                if mod_helper((k, v), pair_1, pair_2, is_left) == 1:
                    mod = True
            elif option == 2:
                if mod_helper((k, v), pair_1, pair_2, is_left) == 0:
                    mod = True
            elif option == 3:
                if mod_helper((k, v), pair_1, pair_2, is_left) == -1:
                    mod = True
            else:
                raise AssertionError(
                    "Something is wrong -- options arent either 1, 2 or 3 ")
    else:  # only check mod relations 4,5,6
        for k, v in tang_right.items():
            if option == 4:
                if mod_helper((k, v), pair_2, pair_3, is_left) == 1:
                    mod = True
            elif option == 5:
                if mod_helper((k, v), pair_2, pair_3, is_left) == 0:
                    mod = True
            elif option == 6:
                if mod_helper((k, v), pair_2, pair_3, is_left) == -1:
                    mod = True
            else:
                raise AssertionError(
                    "Something is wrong about `is_left`-- options arent either 4, 5, 6"
                )
    return mod
Beispiel #6
0
def helper(tang_left, tang_right, pair_1, pair_2, pair_3, is_left, option):
    ''' Helper methods for diff methods. Assumes compatibility. Given a generator x, taking the is_left side, 
    exchanges pairs = (a,b), it seems whether the 
    whether it violates `option`. Refer to options.jpg
    for options.  
    * tang_left is dictionary object of pairs 
    * tang_right is dictionary object of pairs 
    * Pair_1 is the coordinate of two pairs of strand on the left
    * Pair_2 is the coordinate of two pairs of strand in the middle
    * Pair_3 is the coordinate of two pairs of strand in the middle.'''
    mod = False
    if is_left: # only check mod relations 1,2,3
        for k,v in tang_left.items():
            if option ==1:
                if mod_helper((k,v), pair_1, pair_2, is_left) == 1: 
                    mod = True
            elif option == 2:
                if mod_helper((k,v), pair_1, pair_2, is_left) == 0:
                    mod = True
            elif option == 3:
                if mod_helper((k,v), pair_1, pair_2, is_left) == -1: 
                    mod = True
            else:
                raise AssertionError("Something is wrong -- options arent either 1, 2 or 3 ")      
    else: # only check mod relations 4,5,6
        for k,v in tang_right.items():
            if option == 4:
                if mod_helper((k,v), pair_2, pair_3, is_left) == 1:
                    mod = True
            elif option ==5:
                if mod_helper((k,v), pair_2, pair_3, is_left) == 0: 
                    mod = True
            elif option == 6:
                if mod_helper((k,v), pair_2, pair_3, is_left) == -1: 
                    mod = True    
            else:
                raise AssertionError("Something is wrong about `is_left`-- options arent either 4, 5, 6" )
    return mod
Beispiel #7
0
def d_m_raw_B(gen):  # checked
    ''' dm map that picks two pair of points along Bj.
    Exchanges two ends of the corresponding pair of black strands of generator
    `gen` in CT(Ti)
        Returns a list of elements of the form ((s1, s2), d_m_raw_term), where
    s1 < s2 are pairs of strands that d_m is applied, and
        diff_term is a generator in d_plus() obtained by uncrossing or  crossing
        these two strands. Together they specify all terms in d_m(). '''
    lst = []
    l_strands = list(gen.strands.left_converted.items())
    r_strands = list(gen.strands.right_converted.items())
    types = mod_helper(l_strands, r_strands)
    t_l = list(gen.tangle.l_pairs_wc.items())
    t_r = list(gen.tangle.r_pairs_wc.items())
    # right no cross strands
    r_horizontals = types[3]
    for s1, s2 in r_horizontals:
        is_crossed = False
        for tangle in t_r:  # right half tangles
            if abs(mod_between(tangle, (s1[0], s2[0]), (s1[1], s2[1]),
                               False)) == 1:
                is_crossed = True
                break
        for tangle in t_l:  #left half tangles
            x = (tuple(np.subtract(s1[1],
                                   (1, 0))), tuple(np.subtract(s2[1], (1, 0))))
            if mod_between(tangle, x, (s1[0], s2[0]), True) != -2:
                is_crossed = True
                break
        if not is_crossed:
            lst.append(mod_helper_2(gen, s1, s2))
    # left cross strands
    l_cross = types[2]
    for s1, s2 in l_cross:
        is_crossed = False
        for tangle in t_l:  #left half tangles
            if abs(mod_between(tangle, (s1[0], s2[0]), (s1[1], s2[1]),
                               True)) == 1:
                is_crossed = True
                break
        for tangle in t_r:  # right half tangles
            x = (tuple(np.add(s1[0], (1, 0))), tuple(np.add(s2[0], (1, 0))))
            if mod_between(tangle, (s1[1], s2[1]), x, False) != -2:
                is_crossed = True
                break
        if not is_crossed:
            lst.append(mod_helper_2(gen, s1, s2))
    # left above right strands
    l_above_r = types[6]
    for s1, s2 in l_above_r:
        is_crossed = False
        left_pair = (tuple(np.subtract(s2[0], (0.5, 0))), s1[0])
        mid_pair = (s2[0], s1[1])
        right_pair = (tuple(np.add(s1[1], (0.5, 0))), s2[1])
        for tangle in t_l:  # left half tangles
            if -2 < mod_between(tangle, left_pair, mid_pair, True) < 1:
                is_crossed = True
                break
        for tangle in t_r:  # right_half tangles
            if mod_between(tangle, mid_pair, right_pair, False) == -1:
                is_crossed = True
                break
        if not is_crossed:
            lst.append(mod_helper_2(gen, s1, s2))
    # left below  right strands
    l_below_r = types[5]
    for s1, s2 in l_below_r:  #s1 on the left, s2 on the right
        is_crossed = False
        left_pair = (tuple(np.subtract(s2[0], (0.5, 0))), s1[0])
        mid_pair = (s2[0], s1[1])
        right_pair = (tuple(np.add(s1[1], (0.5, 0))), s2[1])
        for tangle in t_l:  # left half tangles
            if mod_between(tangle, left_pair, mid_pair, True) > -1:
                is_crossed = True
                break
        for tangle in t_r:
            if mod_between(tangle, mid_pair, right_pair, False) == 1:
                is_crossed = True
                break
        if not is_crossed:
            lst.append(mod_helper_2(gen, s1, s2))
    return lst
Beispiel #8
0
def d_m_raw_A(left_idem, gen):
    '''dm map that picks two pair of points along  A_j, between x and algebra element
    E_L_D(x), a left idempotent of generator x.
    Exchanges two ends of the corresponding pair of black strands.
    if `alg_left` == True, A(-dLT_i) * CT(T_ii)
    Returns a list of elements of the form ((s1, s2), new_alg_element, new_gen), where
    s1 < s2 are pairs of strands that d_m is applied, and
        diff_term is a generator in d_plus() obtained by uncrossing or  crossing
        these two strands. Together they specify all terms in d_m()'''
    # So far only implemented for A(-dLT_i) * CT(T_ii)
    if not isinstance(left_idem, Simple_Strand):
        raise TypeError(
            "The left element, must be an idempotent in the form of Strand Algebra Element"
        )
    lst = []  # CB
    l_strands = list(left_idem.strands.right_converted.items())
    r_strands = list(gen.strands.left_converted.items())
    t_l = list(left_idem.tangle.r_pairs_wc.items())
    t_r = list(gen.tangle.l_pairs_wc.items())
    types = mod_helper(l_strands, r_strands)
    # left no cross strands
    l_horizontals = types[1]
    for s1, s2 in l_horizontals:
        is_crossed = False
        for tangle in t_l:  # left half tangles
            if abs(mod_between(tangle, (s1[0], s2[0]), (s1[1], s2[1]),
                               True)) == 1:
                is_crossed = True
                break
        for tangle in t_r:  # right half tangles
            x = (tuple(np.add(s1[0], (1, 0))), tuple(np.add(s2[0], (1, 0))))
            if mod_between(tangle, (s1[1], s2[1]), x, False) != -2:
                is_crossed = True
                break
        if not is_crossed:
            lst.append(mod_helper_3(left_idem, gen, s1, s2))
    # right cross strands
    r_cross = types[4]
    for s1, s2 in r_cross:
        is_crossed = False
        for tangle in t_l:  # left half tangles
            x = (tuple(np.subtract(s1[1],
                                   (1, 0))), tuple(np.subtract(s2[1], (1, 0))))
            if mod_between(tangle, x, (s1[0], s2[0]), True) != -2:
                is_crossed = True
                break
        for tangle in t_r:  # right half tangles
            if abs(mod_between(tangle, (s1[0], s2[0]), (s1[1], s2[1]),
                               False)) == 1:
                is_crossed = True
                break
        if not is_crossed:
            lst.append(mod_helper_3(left_idem, gen, s1, s2))
    # left below right
    l_below_r = types[5]
    for s1, s2 in l_below_r:
        is_crossed = False
        left_pair = (tuple(np.subtract(s2[0], (0.5, 0))), s1[0])
        mid_pair = (s2[0], s1[1])
        right_pair = (tuple(np.add(s1[1], (0.5, 0))), s2[1])
        for tangle in t_l:  #left half tangles
            if mod_between(tangle, left_pair, mid_pair, True) == -1:
                is_crossed = True
                break
        for tangle in t_r:  # right half tangles
            if -2 < mod_between(tangle, mid_pair, right_pair, False) < 1:
                is_crossed = True
                break
        if not is_crossed:
            lst.append(mod_helper_3(left_idem, gen, s1, s2))
    # left above right strands
    l_above_r = types[6]
    for s1, s2 in l_above_r:
        is_crossed = False
        left_pair = (tuple(np.subtract(s2[0], (0.5, 0))), s1[0])
        mid_pair = (s2[0], s1[1])
        right_pair = (tuple(np.add(s1[1], (0.5, 0))), s2[1])
        for tangle in t_l:  # left half tangle
            if mod_between(tangle, left_pair, mid_pair, True) == 1:
                is_crossed = True
                break
        for tangle in t_r:  # right half tangle
            if mod_between(tangle, mid_pair, right_pair, False) > -1:
                is_crossed = True
                break
        if not is_crossed:
            lst.append(mod_helper_3(left_idem, gen, s1, s2))
    return lst
Beispiel #9
0
def d_m_raw_B(gen): # checked
    ''' dm map that picks two pair of points along Bj.
    Exchanges two ends of the corresponding pair of black strands of generator
    `gen` in CT(Ti)
        Returns a list of elements of the form ((s1, s2), d_m_raw_term), where
    s1 < s2 are pairs of strands that d_m is applied, and
        diff_term is a generator in d_plus() obtained by uncrossing or  crossing
        these two strands. Together they specify all terms in d_m(). '''
    lst = []
    l_strands = list(gen.strands.left_converted.items())
    r_strands = list(gen.strands.right_converted.items())
    types = mod_helper(l_strands, r_strands)
    t_l = list(gen.tangle.l_pairs_wc.items())
    t_r = list(gen.tangle.r_pairs_wc.items())
    # right no cross strands
    r_horizontals = types[3]
    print("\n Right no cross strands:{0} \n".format(r_horizontals))
    for s1,s2 in r_horizontals:
        is_crossed = False
        for tangle in t_r: # right half tangles
            if abs(mod_between(tangle, (s1[0],s2[0]),(s1[1],s2[1]),False)) == 1:
                is_crossed = True
                break
        for tangle in t_l: #left half tangles
            x = (tuple(np.subtract(s1[1],(1,0))), tuple(np.subtract(s2[1],(1,0))))
            if mod_between(tangle, x,(s1[0],s2[0]), True) != -2:
                is_crossed = True
                break
        if not is_crossed:
            lst.append(mod_helper_2(gen, s1, s2))
    # left cross strands
    l_cross = types[2]
    print("\n left cross strands:{0} \n".format(l_cross))
    for s1,s2 in l_cross:
        is_crossed = False
        for tangle in t_l: #left half tangles
            if abs(mod_between(tangle, (s1[0],s2[0]),(s1[1],s2[1]),True)) == 1:
                is_crossed = True
                break
        for tangle in t_r: # right half tangles
            x = (tuple(np.add(s1[0],(1,0))), tuple(np.add(s2[0],(1,0))))
            if mod_between(tangle,(s1[1],s2[1]),x, False) != -2:
                is_crossed = True 
                break
        if not is_crossed:
            lst.append(mod_helper_2(gen, s1, s2))
    # left above right strands
    l_above_r = types[6]
    print("\n left above right strands:{0} \n".format(l_above_r))
    print(len(l_above_r))
    for s1, s2 in l_above_r:
        is_crossed = False
        left_pair = (tuple(np.subtract(s2[0],(0.5,0))), s1[0])
        mid_pair = (s2[0],s1[1])
        right_pair = (tuple(np.add(s1[1],(0.5,0))),s2[1])
        for tangle in t_l: # left half tangles
            if -2 < mod_between(tangle, left_pair, mid_pair, True) < 1:
                is_crossed = True
                break
        for tangle in t_r: # right_half tangles
            if mod_between(tangle, mid_pair, right_pair, False) == -1:
                is_crossed = True
                break
        if not is_crossed:
            lst.append(mod_helper_2(gen, s1, s2))
    # left below  right strands
    l_below_r = types[5]      
    print("\n left below right strands:{0} \n".format(l_below_r))
    print(len(l_below_r))
    for s1,s2 in l_below_r: #s1 on the left, s2 on the right
        is_crossed = False
        left_pair = (tuple(np.subtract(s2[0],(0.5,0))), s1[0])
        mid_pair = (s2[0],s1[1])
        right_pair = (tuple(np.add(s1[1],(0.5,0))),s2[1])
        for tangle in t_l: # left half tangles
            if mod_between(tangle, left_pair, mid_pair, True) > -1 :
                is_crossed = True
                break
        for tangle in t_r:
            if mod_between(tangle, mid_pair, right_pair, False) == 1:
                is_crossed = True
                break
        if not is_crossed:
            lst.append(mod_helper_2(gen, s1, s2))
    return lst
Beispiel #10
0
def d_m_raw_A(left_idem, gen):
    '''dm map that picks two pair of points along  A_j, between x and algebra element
    E_L_D(x), a left idempotent of generator x.
    Exchanges two ends of the corresponding pair of black strands.
    if `alg_left` == True, A(-dLT_i) * CT(T_ii)
    Returns a list of elements of the form ((s1, s2), new_alg_element, new_gen), where
    s1 < s2 are pairs of strands that d_m is applied, and
        diff_term is a generator in d_plus() obtained by uncrossing or  crossing
        these two strands. Together they specify all terms in d_m()'''
     # So far only implemented for A(-dLT_i) * CT(T_ii) 
    if not isinstance(left_idem, Simple_Strand):
        raise TypeError("The left element, must be an idempotent in the form of Strand Algebra Element")
    lst =  []  # CB
    l_strands = list(left_idem.strands.right_converted.items())
    r_strands = list(gen.strands.left_converted.items())
    t_l = list(left_idem.tangle.r_pairs_wc.items())
    t_r = list(gen.tangle.l_pairs_wc.items())
    types = mod_helper(l_strands, r_strands)
    # left no cross strands 
    l_horizontals = types[1]
    for s1, s2 in l_horizontals:
        is_crossed = False
        for tangle in t_l: # left half tangles
            if abs(mod_between(tangle, (s1[0],s2[0]),(s1[1],s2[1]), True)) == 1:
                is_crossed = True
                break
        for tangle in t_r: # right half tangles
            x = (tuple(np.add(s1[0],(1,0))), tuple(np.add(s2[0],(1,0))))
            if mod_between(tangle, (s1[1], s2[1]),x, False ) != -2:
                is_crossed = True
                break
        if not is_crossed:
            lst.append(mod_helper_3(left_idem, gen, s1, s2))
    # right cross strands
    r_cross = types[4]
    for s1, s2 in r_cross:
        is_crossed = False
        for tangle in t_l: # left half tangles
            x = (tuple(np.subtract(s1[1],(1,0))), tuple(np.subtract(s2[1],(1,0))))
            if mod_between(x,(s1[0],s2[0]),True) != -2:
                is_crossed = True
                break
        for tangle in t_r: # right half tangles
            if abs(mod_between(tangle, (s1[0],s2[0]),(s1[1],s2[1]),False)) == 1:
                is_crossed = True
                break
        if not is_crossed:
            lst.append(mod_helper_3(left_idem, gen, s1, s2))
    # left below right
    l_below_r = types[5]
    for s1, s2 in l_below_r:
        is_crossed = False
        left_pair = (tuple(np.subtract(s2[0],(0.5,0))), s1[0])
        mid_pair = (s2[0],s1[1])
        right_pair = (tuple(np.add(s1[1],(0.5,0))),s2[1])
        for tangle in t_l: #left half tangles
            if mod_between(tangle, left_pair, mid_pair, True) == -1:
                is_crossed = True
                break
        for tangle in t_r: # right half tangles
            if -2 < mod_between(tangle, mid_pair, right_pair, False) < 1:
                is_crossed = True
                break    
        if not is_crossed:
            lst.append(mod_helper_3(left_idem, gen, s1, s2))
    # left above right strands
    l_above_r = types[6]
    for s1, s2 in l_above_r:
        is_crossed = False
        left_pair = (tuple(np.subtract(s2[0],(0.5,0))), s1[0])
        mid_pair = (s2[0],s1[1])
        right_pair = (tuple(np.add(s1[1],(0.5,0))),s2[1])
        for tangle in t_l: # left half tangle
            if mod_between(tangle, left_pair, mid_pair, True) == 1:
                is_crossed = True
                break
        for tangle in t_r: # right half tangle
            if mod_between(tangle, mid_pair, right_pair, False) > -1:
                is_crossed = True
                break
        if not is_crossed:
            lst.append(mod_helper_3(left_idem, gen, s1, s2))  
    return lst