We have a good knot with a big signature! Function to assigne q-values with wanted proportion between layers for a given knot formula.

This commit is contained in:
Maria Marchwicka 2020-10-17 20:15:48 +02:00
parent 58986ff162
commit d0505ee366
3 changed files with 88 additions and 146 deletions

View File

@ -188,12 +188,12 @@ class TorusCable(object):
elif q_vector is not None: elif q_vector is not None:
self.q_vector = q_vector self.q_vector = q_vector
else: else:
msg = "Please give a list of k (k_vector) or q values (q_vector)." self.q_vector = self.get_q_vector(self.knot_formula)
raise ValueError(msg)
self._sigma_function = None self._sigma_function = None
self._signature_as_function_of_theta = None self._signature_as_function_of_theta = None
@property @property
def signature_as_function_of_theta(self): def signature_as_function_of_theta(self):
if self._signature_as_function_of_theta is None: if self._signature_as_function_of_theta is None:
@ -346,6 +346,18 @@ class TorusCable(object):
# print(self.q_vector) # print(self.q_vector)
return cable return cable
def get_q_vector(knot_formula, slice=True):
lowest_number = 2
q_vector = [0] * (TorusCable.extract_max(knot_formula) + 1)
P = Primes()
for layer in TorusCable.get_layers_from_formula(knot_formula)[::-1]:
for el in layer:
q_vector[el] = P.next(lowest_number)
lowest_number = q_vector[el]
lowest_number *= 4
return q_vector
@staticmethod @staticmethod
def extract_max(string): def extract_max(string):
numbers = re.findall(r'\d+', string) numbers = re.findall(r'\d+', string)
@ -431,6 +443,25 @@ class TorusCable(object):
description = description[:-2] + ") # " description = description[:-2] + ") # "
return description[:-3] return description[:-3]
@staticmethod
def get_layers_from_formula(knot_formula):
layers = []
k_indices = re.sub(r'k', '', knot_formula)
k_indices = re.sub(r'-', '', k_indices)
k_indices = re.sub(r'\n', '', k_indices)
k_indices = re.sub(r'\[\d+\]', lambda x: x.group()[1:-1], k_indices)
k_indices = eval(k_indices)
number_of_layers = max(len(lst) for lst in k_indices)
print(k_indices)
layers = []
for i in range(1, number_of_layers + 1):
layer = set()
for lst in k_indices:
if len(lst) >= i:
layer.add(lst[-i])
layers.append(layer)
return layers
def get_signature_as_function_of_theta(self, **key_args): def get_signature_as_function_of_theta(self, **key_args):
if 'verbose' in key_args: if 'verbose' in key_args:
@ -565,11 +596,9 @@ class TorusCable(object):
def is_signature_big_in_ranges(self, ranges_list): def is_signature_big_in_ranges(self, ranges_list):
is_big = True
for theta in it.product(*ranges_list): for theta in it.product(*ranges_list):
if not any(theta): if not any(theta):
continue continue
we_have_a_problem = True we_have_a_problem = True
if self.is_metabolizer(theta): if self.is_metabolizer(theta):
for shift in range(1, self.q_order): for shift in range(1, self.q_order):
@ -591,11 +620,9 @@ class TorusCable(object):
print(shifted_theta, end=" ") print(shifted_theta, end=" ")
print(extremum) print(extremum)
if we_have_a_problem: if we_have_a_problem:
is_big = False print("\n" * 10 + "!" * 1000)
break return False
if not is_big: return True
print("we have a big problem")
return is_big
def is_signature_big_for_all_metabolizers(self): def is_signature_big_for_all_metabolizers(self):
if len(self.knot_sum) == 8: if len(self.knot_sum) == 8:

View File

@ -78,47 +78,24 @@ def main(arg=None):
# cab_to_add = TorusCable(knot_formula=knot_formula, q_vector=q_vector) # cab_to_add = TorusCable(knot_formula=knot_formula, q_vector=q_vector)
# cab_shifted = cab_to_update.add_with_shift(cab_to_add) # cab_shifted = cab_to_update.add_with_shift(cab_to_add)
q_vector = (5, 13, 19, 41,\ # q_vector = (5, 13, 19, 41,\
5, 17, 23, 43) # 5, 17, 23, 43)
knot_formula = "[[k[0], k[5], k[3]], " + \ formula_1 = "[[k[0], k[5], k[3]], " + \
"[-k[1], -k[3]], " + \ "[-k[1], -k[3]], " + \
"[k[2], k[3]], " + \ "[k[2], k[3]], " + \
"[-k[0], -k[2], -k[3]]]" "[-k[0], -k[2], -k[3]]]"
cab_1 = TorusCable(knot_formula=knot_formula, q_vector=q_vector) formula_2 = "[[k[4], k[1], k[7]], " + \
knot_formula = "[[k[4], k[1], k[7]], " + \
"[-k[5], -k[7]], " + \ "[-k[5], -k[7]], " + \
"[k[6], k[7]], " + \ "[k[6], k[7]], " + \
"[-k[4], -k[6], -k[7]]]" "[-k[4], -k[6], -k[7]]]"
cab_2 = TorusCable(knot_formula=knot_formula, q_vector=q_vector) q_vector = TorusCable.get_q_vector(formula_1[:-1] + ", " + formula_2[1:])
cab_1 = TorusCable(knot_formula=formula_1, q_vector=q_vector)
cab_2 = TorusCable(knot_formula=formula_2, q_vector=q_vector)
cable = cab_1 + cab_2 cable = cab_1 + cab_2
joined_formula = cable.knot_formula joined_formula = cable.knot_formula
print(cable.is_signature_big_for_all_metabolizers()) # print(cable.is_signature_big_for_all_metabolizers())
def get_q_vector(q_vector_size, lowest_number=1):
q = [lowest_number] * q_vector_size
P = Primes()
next_number = P.next(lowest_number)
for i in range(q_vector_size):
q[i] = next_number
next_number = P.next(4 * next_number)
return q
next_number = P.next(lowest_number)
for i, q in enumerate(q_vector):
q[i] = next_number
next_number = P.next(lowest_number)
q = [P.unrank(i) for i in c]
ratio = q[3] > 4 * q[2] and q[2] > 4 * q[1] and q[1] > 4 * q[0]
if not ratio:
# print("Ratio-condition does not hold")
continue
print("q = ", q)
if __name__ == '__main__': if __name__ == '__main__':
global config global config
@ -129,3 +106,46 @@ if __name__ == '__main__':
else: else:
pass pass
# main() # main()
"""
This script calculates signature functions for knots (cable sums).
The script can be run as a sage script from the terminal
or used in interactive mode.
A knot (cable sum) is encoded as a list where each element (also a list)
corresponds to a cable knot, e.g. a list
[[1, 3], [2], [-1, -2], [-3]] encodes
T(2, 3; 2, 7) # T(2, 5) # -T(2, 3; 2, 5) # -T(2, 7).
To calculate the number of characters for which signature function vanish use
the function eval_cable_for_null_signature as shown below.
sage: eval_cable_for_null_signature([[1, 3], [2], [-1, -2], [-3]])
T(2, 3; 2, 7) # T(2, 5) # -T(2, 3; 2, 5) # -T(2, 7)
Zero cases: 1
All cases: 1225
Zero theta combinations:
(0, 0, 0, 0)
sage:
The numbers given to the function eval_cable_for_null_signature are k-values
for each component/cable in a direct sum.
To calculate signature function for a knot and a theta value, use function
get_signature_as_function_of_theta (see help/docstring for details).
About notation:
Cables that we work with follow a schema:
T(2, q_1; 2, q_2; 2, q_4) # -T(2, q_2; 2, q_4) #
# T(2, q_3; 2, q_4) # -T(2, q_1; 2, q_3; 2, q_4)
In knot_formula each k[i] is related with some q_i value, where
q_i = 2*k[i] + 1.
So we can work in the following steps:
1) choose a schema/formula by changing the value of knot_formula
2) set each q_i all or choose range in which q_i should varry
3) choose vector v / theata vector.
"""

View File

@ -1,105 +0,0 @@
#!/usr/bin/python
# if not os.path.isfile('cable_signature.py'):
# os.system('sage --preparse cable_signature.sage')
# os.system('mv cable_signature.sage.py cable_signature.py')
# from cable_signature import SignatureFunction, TorusCable, SIGNATURE, SIGMA
# searching for signature > 5 + #(v_i != 0) over given knot schema
def search_for_large_signature_value(knot_formula=None, limit=None,
verbose=None, print_results=None):
if limit is None:
limit = config.limit
if knot_formula is None:
knot_formula = config.knot_formula
if verbose is None:
verbose = config.verbose
if print_results is None:
print_results = config.print_results
k_vector_size = extract_max(knot_formula) + 1
combinations = it.combinations(range(1, limit + 1), k_vector_size)
P = Primes()
good_knots = []
# iterate over q-vector
for c in combinations:
q = [P.unrank(i + config.start_shift) for i in c]
if config.only_slice_candidates:
ratio = q[3] > 4 * q[2] and q[2] > 4 * q[1] and q[1] > 4 * q[0]
if not ratio:
if verbose:
print("Ratio-condition does not hold")
continue
cable = TorusCable(knot_formula=knot_formula, q_vector=q)
is_big = cable.is_signature_big_for_all_metabolizers()
print(is_big)
if is_big:
good_knots.append(cable.knot_description)
return good_knots
def extract_max(string):
numbers = re.findall(r'\d+', string)
numbers = map(int, numbers)
return max(numbers)
extract_max.__doc__ = \
"""
Return:
maximum of absolute values of numbers from given string
Examples:
sage: extract_max("([1, 3], [2], [-1, -2], [-10])")
10
sage: extract_max("3, 55, ewewe, -42, 3300, 50")
3300
"""
"""
This script calculates signature functions for knots (cable sums).
The script can be run as a sage script from the terminal
or used in interactive mode.
A knot (cable sum) is encoded as a list where each element (also a list)
corresponds to a cable knot, e.g. a list
[[1, 3], [2], [-1, -2], [-3]] encodes
T(2, 3; 2, 7) # T(2, 5) # -T(2, 3; 2, 5) # -T(2, 7).
To calculate the number of characters for which signature function vanish use
the function eval_cable_for_null_signature as shown below.
sage: eval_cable_for_null_signature([[1, 3], [2], [-1, -2], [-3]])
T(2, 3; 2, 7) # T(2, 5) # -T(2, 3; 2, 5) # -T(2, 7)
Zero cases: 1
All cases: 1225
Zero theta combinations:
(0, 0, 0, 0)
sage:
The numbers given to the function eval_cable_for_null_signature are k-values
for each component/cable in a direct sum.
To calculate signature function for a knot and a theta value, use function
get_signature_as_function_of_theta (see help/docstring for details).
About notation:
Cables that we work with follow a schema:
T(2, q_1; 2, q_2; 2, q_4) # -T(2, q_2; 2, q_4) #
# T(2, q_3; 2, q_4) # -T(2, q_1; 2, q_3; 2, q_4)
In knot_formula each k[i] is related with some q_i value, where
q_i = 2*k[i] + 1.
So we can work in the following steps:
1) choose a schema/formula by changing the value of knot_formula
2) set each q_i all or choose range in which q_i should varry
3) choose vector v / theata vector.
"""