# A list of variables d_1, ..., d_6 for the coefficients ds = [var("d%s"%i) for i in range(1,7)] # A list of variables E_1, ..., E_6 Es = [var("E%s"%i) for i in range(1,7)] # A list of variables F_12, ..., F_56 Fs = [var("F%s%s"%(i,j)) for i in range(1,7) for j in range(1,7) if i < j] # A list of variables E_1, ..., E_6 Gs = [var("G%s"%i) for i in range(1,7)] # A list of variables X_12, ..., X_65 Xs = [var("X%s%s"%(i,j)) for i in range(1,7) for j in range(1,7) if i != j] # A list of variables Yoshida_0, ..., Yoshida_39 Yoshidas = [var("Yoshida%s"%i) for i in range(0,40)] YM = load("../../Yoshida/Output/Yoshida_matrix.sobj") #Yoshidas = [VectorToYoshida(YM[i]) for i in range(0,40)] YRing = PolynomialRing(QQ, Yoshidas) YField = FractionField(YRing) def tropicalMult(terms): if Infinity in terms: return Infinity else: return sum(terms) # lins is a list of forms # returns where the min is achieved # def is_trop_zero(pt, lins): # evaluation = YRing.hom(list(pt), QQ) # evaluated = [evaluation(l) for l in lins] # m = min(evaluated) # return [i for i in range(0, len(evaluated)) if evaluated[i] == m] # lins is a list of forms # returns where the min is achieved def is_trop_zero(pt, lins): hom = YRing.hom(list(pt), QQ) def evaluation(l): if l != +Infinity: return hom(l) else: return Infinity evaluated = [evaluation(l) for l in lins] m = min(evaluated) return [i for i in range(0, len(evaluated)) if evaluated[i] == m] # The following function allows to check the existence of a singleton minimizer for some vertex to verify a tropical minor is singular. It is necessary and sufficient to check that the intersection of all the minimizers is a singleton. def intersect_all(list_of_minimizers): answer = Set(list_of_minimizers[0]) for minimizers in list_of_minimizers: answer = answer.intersection(Set(minimizers)) return answer ################################################################## # Remove all entries containing "+Infinity" for our calculations # ################################################################## #Inputs: # J = list of 3 rows in range(0,5) # cone is the data of a polyhedral cone giving valuations of our 6 parameters d1,...,d6 # M_without_nones corresponds to the 5x45 tropical matrix of expected valuations precomputed with input the cone and the original matrix of 5 boundary points. # M_with_nones corresponds to the 5x45 tropical matrix of true valuations precomputed with input the cone and the original matrix of 5 boundary points. def computeNonVanishingMinors(J, cone, M_with_nones, M_without_nones): """Return a list of triples [K] such that the 3x3 minor JxK of M is tropically non-vanishing on the interior of cone. """ # This will contain the final answer. nonVanishingMinors = [] lenM = len(M_without_nones[0]) lenM0 = len(M_without_nones) # For safety, we exclude infinities. infinities = {i:[x for x in range(0, lenM) if M_without_nones[i][x] == Infinity] for i in range(0, lenM0)} noninf = [x for x in range(0, lenM) if x not in infinities[J[0]]+infinities[J[1]]+infinities[J[2]]] # Go through all 3 element subsets of the columns without infinities, evaluate the minors, and check the ones that are nonzero. for s in Set(noninf).subsets(3): [i,j,k] = sorted(list(s)) # Extract the submatrix J x [i,j,k] sub_matrix = [[M_without_nones[J[0]][i], M_without_nones[J[0]][j], M_without_nones[J[0]][k]], [M_without_nones[J[1]][i], M_without_nones[J[1]][j], M_without_nones[J[1]][k]], [M_without_nones[J[2]][i], M_without_nones[J[2]][j], M_without_nones[J[2]][k]]] # Take the determinant of the submatrix G = list(SymmetricGroup(3)) # Product becomes + and + becomes min. But we don't actually take the min; we keep the whole list. det_sub_matrix = [sub_matrix[0][p(1)-1] + sub_matrix[1][p(2)-1] + sub_matrix[2][p(3)-1] for p in G] # Taking the min is done by is_trop_zero. # is_trop_zero(v, exp) will return a list [m] where the m th term in exp achieves the minimum at v. evaluated_minor = [is_trop_zero(vector(v), det_sub_matrix) for v in cone.rays()] # Now we intersect these minimizers intersection_of_minimizers = intersect_all(evaluated_minor) # If the intersection is singleton, then the minor is tropically non-zero on the interior. if len(intersection_of_minimizers) == 1: # Now we need to check that the winner does not have nones. minimizer = list(intersection_of_minimizers)[0] permutation = G[minimizer] sub_matrix_with_nones = [[M_with_nones[J[0]][i], M_with_nones[J[0]][j], M_with_nones[J[0]][k]], [M_with_nones[J[1]][i], M_with_nones[J[1]][j], M_with_nones[J[1]][k]], [M_with_nones[J[2]][i], M_with_nones[J[2]][ j], M_with_nones[J[2]][k]]] if sub_matrix_with_nones[0][permutation(1)-1] != None and sub_matrix_with_nones[1][permutation(2)-1] != None and sub_matrix_with_nones[2][permutation(3)-1] != None: nonVanishingMinors.append([i,j,k]) break return nonVanishingMinors ####################################### # Use "+Infinity" in all calculations # ####################################### # This function allows to use "+Infinity" entries to find tropical singular 3x3 minors. # Input is the same as the function "computeNonVanishingMinors" above. # Since we are only interested in finding a singular minor, we break as soon as we find one. If we want the full list of singular minors for a given J, we must remove the "break" line. def computeNonVanishingMinorsWithInfinities(J, cone, M_with_nones, M_without_nones): """Return a list of triples [K] such that the 3x3 minor JxK of M is tropically non-vanishing on the interior of cone. """ lenM = len(M_without_nones[0]) lenM0 = len(M_without_nones) # This will contain the final answer. nonVanishingMinors = [] # For safety, we exclude infinities. # infinities = {i:[x for x in range(0, lenM) if M_without_nones[i][x] == Infinity] for i in range(0, lenM0)} # noninf = [x for x in range(0, lenM) if x not in infinities[J[0]]+infinities[J[1]]+infinities[J[2]]] noninf = range(0, lenM) G = list(SymmetricGroup(3)) # Go through all 3 element subsets of the columns without infinities, evaluate the minors, and check the ones that are nonzero. for s in Set(noninf).subsets(3): [i,j,k] = sorted(list(s)) # Extract the submatrix J x [i,j,k] sub_matrix = [[M_without_nones[J[0]][i], M_without_nones[J[0]][j], M_without_nones[J[0]][k]], [M_without_nones[J[1]][i], M_without_nones[J[1]][j], M_without_nones[J[1]][k]], [M_without_nones[J[2]][i], M_without_nones[J[2]][j], M_without_nones[J[2]][k]]] # Take the determinant of the submatrix # Product becomes + and + becomes min. But we don't actually take the min; we keep the whole list. det_sub_matrix = [tropicalMult([sub_matrix[0][p(1)-1], sub_matrix[1][p(2)-1], sub_matrix[2][p(3)-1]]) for p in G] # print str(det_sub_matrix) # Taking the min is done by is_trop_zero. # is_trop_zero(v, exp) will return a list [m] where the m th term in exp achieves the minimum at v. evaluated_minor = [is_trop_zero(vector(v), det_sub_matrix) for v in cone.rays()] # print str(evaluated_minor) # Now we intersect these minimizers intersection_of_minimizers = intersect_all(evaluated_minor) # If the intersection is singleton, then the minor is tropically non-zero on the interior. if len(intersection_of_minimizers) == 1: # Now we need to check that the winner does not have nones. minimizer = list(intersection_of_minimizers)[0] permutation = G[minimizer] sub_matrix_with_nones = [[M_with_nones[J[0]][i], M_with_nones[J[0]][j], M_with_nones[J[0]][k]], [M_with_nones[J[1]][i], M_with_nones[J[1]][j], M_with_nones[J[1]][k]], [M_with_nones[J[2]][i], M_with_nones[J[2]][j], M_with_nones[J[2]][k]]] if sub_matrix_with_nones[0][permutation(1)-1] != None and sub_matrix_with_nones[1][permutation(2)-1] != None and sub_matrix_with_nones[2][permutation(3)-1] != None: nonVanishingMinors.append([i,j,k]) # since we are only interested in finding a singular minor, we break as soon as we find one. break return nonVanishingMinors ################################ # Computations with the origin # ################################ ####################################### # Use "+Infinity" in all calculations # ####################################### # This function allows to use "+Infinity" entries to find tropical singular 3x3 minors. # Input is the same as the function "computeNonVanishingMinors" above. # Since we are only interested in finding a singular minor, we break as soon as we find one. If we want the full list of singular minors for a given J, we must remove the "break" line. def computeNonVanishingMinorsWithInfinitiesOrigin(J, origin, M_with_nones, M_without_nones): """Return a list of triples [K] such that the 3x3 minor JxK of M is tropically non-vanishing on the interior of cone. """ lenM = len(M_without_nones[0]) lenM0 = len(M_without_nones) # This will contain the final answer. nonVanishingMinors = [] # For safety, we exclude infinities. # infinities = {i:[x for x in range(0, lenM) if M_without_nones[i][x] == Infinity] for i in range(0, lenM)} # noninf = [x for x in range(0, lenM) if x not in infinities[J[0]]+infinities[J[1]]+infinities[J[2]]] noninf = range(0, lenM) G = list(SymmetricGroup(3)) # Go through all 3 element subsets of the columns without infinities, evaluate the minors, and check the ones that are nonzero. for s in Set(noninf).subsets(3): [i,j,k] = sorted(list(s)) # Extract the submatrix J x [i,j,k] sub_matrix = [[M_without_nones[J[0]][i], M_without_nones[J[0]][j], M_without_nones[J[0]][k]], [M_without_nones[J[1]][i], M_without_nones[J[1]][j], M_without_nones[J[1]][k]], [M_without_nones[J[2]][i], M_without_nones[J[2]][j], M_without_nones[J[2]][k]]] # Take the determinant of the submatrix # Product becomes + and + becomes min. But we don't actually take the min; we keep the whole list. det_sub_matrix = [tropicalMult([sub_matrix[0][p(1)-1], sub_matrix[1][p(2)-1], sub_matrix[2][p(3)-1]]) for p in G] # Taking the min is done by is_trop_zero. # is_trop_zero(v, exp) will return a list [m] where the m th term in exp achieves the minimum at v. evaluated_minor = [is_trop_zero(vector(origin), det_sub_matrix)] # Now we intersect these minimizers intersection_of_minimizers = intersect_all(evaluated_minor) # If the intersection is singleton, then the minor is tropically non-zero on the interior. if len(intersection_of_minimizers) == 1: # Now we need to check that the winner does not have nones. minimizer = list(intersection_of_minimizers)[0] permutation = G[minimizer] sub_matrix_with_nones = [[M_with_nones[J[0]][i], M_with_nones[J[0]][j], M_with_nones[J[0]][k]], [M_with_nones[J[1]][i], M_with_nones[J[1]][j], M_with_nones[J[1]][k]], [M_with_nones[J[2]][i], M_with_nones[J[2]][j], M_with_nones[J[2]][k]]] if sub_matrix_with_nones[0][permutation(1)-1] != None and sub_matrix_with_nones[1][permutation(2)-1] != None and sub_matrix_with_nones[2][permutation(3)-1] != None: nonVanishingMinors.append([i,j,k]) # since we are only interested in finding a singular minor, we break as soon as we find one. break return nonVanishingMinors