two cases and to loops for last theta

This commit is contained in:
Maria Marchwicka 2020-08-23 13:23:51 +02:00
parent 949344193c
commit afbda34111

View File

@ -7,7 +7,7 @@ import os
import sys import sys
import collections import collections
import inspect # import inspect
import itertools as it import itertools as it
import numpy as np import numpy as np
import re import re
@ -32,34 +32,23 @@ class Config(object):
self.verbose = True self.verbose = True
self.verbose = False self.verbose = False
self.print_calculations_for_small_signature = True self.print_calculations_for_small_sigma = True
self.print_calculations_for_small_signature = False self.print_calculations_for_small_sigma = False
self.print_calculations_for_large_signature = True
self.print_calculations_for_large_signature = False
self.print_calculations_for_large_sigma = True
self.print_calculations_for_large_sigma = False
# is the ratio restriction for values in k_vector taken into account # is the ratio restriction for values in k_vector taken into account
# False flag is usefull to make quick script tests # False flag is usefull to make quick script tests
self.only_slice_candidates = True self.only_slice_candidates = True
self.only_slice_candidates = False self.only_slice_candidates = False
self.stop_after_firts_large_signature = True self.stop_after_firts_large_sigma = True
self.stop_after_firts_large_signature = False self.stop_after_firts_large_sigma = False
class SignatureFunction(object): class SignatureFunction(object):
"""
This simple class encodes twisted and untwisted signature functions
of knots. Since the signature function is entirely encoded by its signature
jump, the class stores only information about signature jumps
in a dictionary self.signature_jumps.
The dictionary stores data of the signature jump as a key/values pair,
where the key is the argument at which the functions jumps
and value encodes the value of the jump. Remember that we treat
signature functions as defined on the interval [0,1).
"""
def __init__(self, values=None, counter=None): def __init__(self, values=None, counter=None):
# set values of signature jumps # set values of signature jumps
if counter is None: if counter is None:
@ -74,29 +63,20 @@ class SignatureFunction(object):
self.signature_jumps = collections.defaultdict(int, counter) self.signature_jumps = collections.defaultdict(int, counter)
def sum_of_absolute_values(self): def sum_of_absolute_values(self):
result = sum([abs(i) for i in self.signature_jumps.values()])
test = sum([abs(i) for i in self.cnt_signature_jumps.values()])
assert test == result
return sum([abs(i) for i in self.cnt_signature_jumps.values()]) return sum([abs(i) for i in self.cnt_signature_jumps.values()])
def is_zero_everywhere(self): def is_zero_everywhere(self):
result = not any(self.signature_jumps.values()) return not any(self.signature_jumps.values())
assert result == (not any(self.cnt_signature_jumps.values()))
if self.sum_of_absolute_values():
assert result == False
else:
assert result == True
return result
def double_cover(self): def double_cover(self):
# to read values for t^2 # to read values for t^2
new_data = [] new_data = []
for jump_arg, jump in self.signature_jumps.items(): for jump_arg, jump in self.cnt_signature_jumps.items():
new_data.append((jump_arg/2, jump)) new_data.append((jump_arg/2, jump))
new_data.append((1/2 + jump_arg/2, jump)) new_data.append((1/2 + jump_arg/2, jump))
t_data = [] t_data = []
for jump_arg, jump in self.cnt_signature_jumps.items(): for jump_arg, jump in self.signature_jumps.items():
t_data.append((jump_arg/2, jump)) t_data.append((jump_arg/2, jump))
t_data.append((1/2 + jump_arg/2, jump)) t_data.append((1/2 + jump_arg/2, jump))
@ -138,12 +118,7 @@ class SignatureFunction(object):
a = SignatureFunction(values=t_data) a = SignatureFunction(values=t_data)
sf = SignatureFunction(values=new_data) sf = SignatureFunction(values=new_data)
sf2 = SignatureFunction(counter=counter) sf2 = SignatureFunction(counter=counter)
print(new_data)
print(counter.items())
assert a == sf assert a == sf
print("repr")
print(repr(sf2))
print(repr(a))
assert a == sf2 assert a == sf2
return sf return sf
@ -165,10 +140,6 @@ class SignatureFunction(object):
def __neg__(self): def __neg__(self):
new_data = [] new_data = []
print("neg")
print("start values sign and cnt")
print(self.signature_jumps.items())
print(self.cnt_signature_jumps.items())
for jump_arg, jump in self.signature_jumps.items(): for jump_arg, jump in self.signature_jumps.items():
new_data.append((jump_arg, -jump)) new_data.append((jump_arg, -jump))
a = SignatureFunction(values=new_data) a = SignatureFunction(values=new_data)
@ -229,31 +200,19 @@ class SignatureFunction(object):
arg = mod_one(arg) arg = mod_one(arg)
cnt = self.cnt_signature_jumps cnt = self.cnt_signature_jumps
before_arg = [jump for jump_arg, jump in cnt.items() if jump_arg < arg] before_arg = [jump for jump_arg, jump in cnt.items() if jump_arg < arg]
result = 2 * sum(before_arg) + cnt[arg] return 2 * sum(before_arg) + cnt[arg]
# TBD to delete
val = 0
for jump_arg, jump in self.signature_jumps.items():
if jump_arg < arg:
val += 2 * jump
elif jump_arg == arg:
val += jump
assert result == val
# end of to delete
return result
def main(arg): def main(arg):
try: if arg[1]:
new_limit = int(arg[1]) limit = int(arg[1])
except IndexError: else:
new_limit = None limit = None
search_for_large_signature_value(limit=new_limit) search_for_large_signature_value(limit=limit)
# search_for_null_signature_value(limit=new_limit) # search_for_null_signature_value(limit=limit)
# searching for signture > 5 + #(v_i != 0) over given knot schema # searching for sigma > 5 + #(v_i != 0) over given knot schema
def search_for_large_signature_value(knot_formula=None, def search_for_large_signature_value(knot_formula=None,
limit=None, limit=None,
verbose=None): verbose=None):
@ -272,6 +231,8 @@ def search_for_large_signature_value(knot_formula=None,
P = Primes() P = Primes()
good_knots = [] good_knots = []
# with open(config.f_results, 'w') as f_results: # with open(config.f_results, 'w') as f_results:
# iterate over q-vector
for c in combinations: for c in combinations:
k = [(P.unrank(i) - 1)/2 for i in c] k = [(P.unrank(i) - 1)/2 for i in c]
if config.only_slice_candidates: if config.only_slice_candidates:
@ -281,20 +242,20 @@ def search_for_large_signature_value(knot_formula=None,
if verbose: if verbose:
print("Ratio-condition does not hold") print("Ratio-condition does not hold")
continue continue
result = eval_cable_for_large_signature(k_vector=k, result = eval_cable_for_large_sigma(k_vector=k,
knot_formula=knot_formula, knot_formula=knot_formula,
print_results=False) print_results=False)
good_knots.append(result) good_knots.append(result)
return good_knots return good_knots
# searching for signture > 5 + #(v_i != 0) # searching for sigma > 5 + #(v_i != 0)
def eval_cable_for_large_signature(k_vector=None, def eval_cable_for_large_sigma(k_vector=None,
knot_formula=None, knot_formula=None,
print_results=True, print_results=True,
verbose=None, verbose=None,
q_vector=None): q_vector=None):
if knot_formula is None: if knot_formula is None:
knot_formula = config.knot_formula knot_formula = config.knot_formula
if verbose is None: if verbose is None:
@ -306,11 +267,22 @@ def eval_cable_for_large_signature(k_vector=None,
return None return None
else: else:
k_vector = [(i - 1)/2 for i in q_vector] k_vector = [(i - 1)/2 for i in q_vector]
k = k_vector k = k_vector
knot_sum = eval(knot_formula) knot_sum = eval(knot_formula)
if len(knot_sum) != 4:
print("Wrong number of cable direct summands!")
return None
knot_description = get_knot_descrption(*knot_sum) knot_description = get_knot_descrption(*knot_sum)
return _eval_cable_for_large_sigma(k_vector, knot_description,
print_results, verbose)
def _eval_cable_for_large_sigma(k, knot_description, print_results, verbose):
# k is a k_vector
print("\n" * 5)
print(knot_description)
k_1, k_2, k_3, k_4 = [abs(i) for i in k] k_1, k_2, k_3, k_4 = [abs(i) for i in k]
q_4 = 2 * k_4 + 1 q_4 = 2 * k_4 + 1
ksi = 1/q_4 ksi = 1/q_4
@ -321,120 +293,221 @@ def eval_cable_for_large_signature(k_vector=None,
print("Searching for a large signature values for the cable sum: ") print("Searching for a large signature values for the cable sum: ")
print(knot_description) print(knot_description)
if len(knot_sum) != 4:
print("Wrong number of cable direct summands!")
return None
large_sigma_for_all_v_comninations = True large_sigma_for_all_v_combinations = True
good_knots = [("nic")] bad_vectors = []
good_vectors = []
# iteration over all possible character combinations # iteration over all possible character combinations
ranges_list = [range(abs(knot[-1]) + 1) for knot in knot_sum] # T(2, q_1; 2, q_2; 2, q_4) # -T(2, q_2; 2, q_4) #
for v_theta in it.product(*ranges_list): # # T(2, q_3; 2, q_4) # -T(2, q_1; 2, q_3; 2, q_4)
theta_squers = [i^2 for i in v_theta]
condition = "(" + str(theta_squers[0]) \ sigma_q_1 = get_untwisted_signature_function(k_1)
+ " - " + str(theta_squers[1]) \ sigma_q_2 = get_untwisted_signature_function(k_2)
+ " + " + str(theta_squers[2]) \ sigma_q_3 = get_untwisted_signature_function(k_3)
+ " - " + str(theta_squers[3]) \
+ ") % " + str(q_4) # large_sigma_for_last_theta_non_zero = True
# if verbose: #!!!!!!!!!!!!!!!!
# print "\nChecking for characters: " + str(v_theta) # consider a_4 non-zero and zero
if (theta_squers[0] - theta_squers[1] + last_theta = 1
theta_squers[2] - theta_squers[3]) % q_4: large_sigma_for_last_theta_non_zero = True
if verbose: for vector in it.product(3 * [range(q_4)]):
print("The condition is not satisfied: " + \ v_theta = list(vector)
str(condition) + " != 0.") v_theta.append(last_theta)
a_1, a_2, a_3 = vector
a_4 = last_theta
assert [a_1, a_2, a_3, a_4] == v_theta
if a_1 == a_2 == a_3:
if a_3 == 0:
print("\na_1 == a_2 == a_3 == 0")
continue
elif a_3 == a_4:
print("\nall a_i == a != 0")
continue
if (a_1^2 - a_2^2 + a_3^2 - a_4^2) % q_4:
continue continue
if v_theta[0] == v_theta[1] == v_theta[2] == v_theta[3] == 0:
print("\nSkip") # print("\t\t\tMultiplication of the vector " + str(v_theta))
continue large_sigma_for_this_vector = False
if v_theta[0] == v_theta[1] == v_theta[2] == v_theta[3]: for shift in range(1, q_4):
print("\nall v == a") # print("shift = " + str(shift) + ", q_4 = " + str(q_4))
shifted_theta = [(shift * a) % q_4 for a in
[a_1, a_2, a_3, a_4]]
# T(2, q_1; 2, q_2; 2, q_4) # -T(2, q_2; 2, q_4) # # "untwisted" part (Levine-Tristram signatures)
# # T(2, q_3; 2, q_4) # -T(2, q_1; 2, q_3; 2, q_4) a_1, a_2, a_3, a_4 = shifted_theta
untwisted_part = 2 * (sigma_q_2(ksi * a_1) -
sigma_q_2(ksi * a_2) +
sigma_q_3(ksi * a_3) -
sigma_q_3(ksi * a_4) +
sigma_q_1(ksi * a_1 * 2) -
sigma_q_1(ksi * a_4 * 2))
# "untwisted" part (Levine-Tristram signatures) # "twisted" part
sigma_q_1 = get_untwisted_signature_function(k_1) tp = [0, 0, 0, 0]
sigma_q_2 = get_untwisted_signature_function(k_2) for i, a in enumerate(shifted_theta):
sigma_q_3 = get_untwisted_signature_function(k_3) if a:
a_1, a_2, a_3, a_4 = v_theta tp[i] = -q_4 + 2 * a - 2 * (a^2/q_4)
untwisted_part = 2 * (sigma_q_2(ksi * a_1) + twisted_part = tp[0] - tp[1] + tp[2] - tp[3]
sigma_q_1(ksi * a_1 * 2) - # assert twisted_part == int(twisted_part)
sigma_q_2(ksi * a_2) +
sigma_q_3(ksi * a_3) -
sigma_q_3(ksi * a_4) -
sigma_q_1(ksi * a_4 * 2))
# "twisted" part sigma_v = untwisted_part + twisted_part
tp = [0, 0, 0, 0] # print(knot_description + "\t" + str(shifted_theta) +\
for i, a in enumerate(v_theta): # "\t" + str(sigma_v))
if a: # + "\t" + str(2 * sigma_q_1(2 * ksi * a_4)))
tp[i] = -q_4 + 2 * a - 2 * (a^2/q_4)
twisted_part = tp[0] - tp[1] + tp[2] - tp[3]
assert twisted_part == int(twisted_part)
sigma_v = untwisted_part + twisted_part if abs(sigma_v) > 5 + np.count_nonzero(shifted_theta):
if abs(sigma_v) > 5 + np.count_nonzero(v_theta): large_sigma_for_this_vector = True
if config.print_calculations_for_large_signature:
print("*" * 100) if large_sigma_for_this_vector:
print("\n\nLarge signature value\n") good_vectors.append(shifted_theta)
print(knot_description) pass
print("\nv_theta: ", end="")
print(v_theta)
print("k values: ", end="")
print(str(k_1) + " " + str(k_2) + " " + \
str(k_3) + " " + str(k_4))
print(condition)
print("non zero value in v_theta: " + \
str(np.count_nonzero(v_theta)))
print("sigma_v: " + str(sigma_v))
print("\ntwisted_part: ", end="")
print(twisted_part)
print("untwisted_part: ", end="")
print(untwisted_part)
print("\n\nCALCULATIONS")
print("*" * 100)
print_results_LT(v_theta, knot_description,
ksi, untwisted_part,
k, sigma_q_1, sigma_q_2, sigma_q_3)
print_results_sigma(v_theta, knot_description, tp, q_4)
print("*" * 100 + "\n" * 5)
else:
print(knot_description + "\t" + str(v_theta) +\
"\t" + str(sigma_v) + "\t" + str(2 * sigma_q_1(2 * ksi * a_4)))
if config.stop_after_firts_large_signature:
break
else: else:
if config.print_calculations_for_small_signature: bad_vectors.append(shifted_theta)
print("\n" * 5 + "*" * 100) large_sigma_for_last_theta_non_zero = False
print("\nSmall signature value\n")
print(knot_description) last_theta = 0
print_results_LT(v_theta, knot_description, ksi, untwisted_part, large_sigma_for_last_theta_zero = True
k, sigma_q_1, sigma_q_2, sigma_q_3) for vector in it.product(3 * [range(q_4)]):
print_results_sigma(v_theta, knot_description, tp, q_4) v_theta = list(vector)
print("*" * 100 + "\n" * 5) v_theta.append(last_theta)
else: a_1, a_2, a_3 = vector
print(knot_description + "\t" + str(v_theta) +\ a_4 = last_theta
"\t" + str(sigma_v) + "\t" + str(2 * sigma_q_1(2 * ksi * a_4))) assert [a_1, a_2, a_3, a_4] == v_theta
if a_1 == a_2 == a_3:
if a_3 == 0:
print("\na_1 == a_2 == a_3 == 0")
continue
elif a_3 == a_4:
print("\nall a_i == a != 0")
continue
if (a_1^2 - a_2^2 + a_3^2 - a_4^2) % q_4:
continue
# print("\t\t\tMultiplication of the vector " + str(v_theta))
large_sigma_for_this_vector = False
for shift in range(1, q_4):
# print("shift = " + str(shift) + ", q_4 = " + str(q_4))
shifted_theta = [(shift * a) % q_4 for a in
[a_1, a_2, a_3, a_4]]
large_sigma_for_all_v_comninations = False # "untwisted" part (Levine-Tristram signatures)
print("ojojojoj") a_1, a_2, a_3, a_4 = shifted_theta
break untwisted_part = 2 * (sigma_q_2(ksi * a_1) -
sigma_q_2(ksi * a_2) +
sigma_q_3(ksi * a_3) -
sigma_q_3(ksi * a_4) +
sigma_q_1(ksi * a_1 * 2) -
sigma_q_1(ksi * a_4 * 2))
if large_sigma_for_all_v_comninations: # "twisted" part
print("\n\n\nHura hura") tp = [0, 0, 0, 0]
good_knots.append((knot_description, v_theta)) for i, a in enumerate(shifted_theta):
if a:
tp[i] = -q_4 + 2 * a - 2 * (a^2/q_4)
twisted_part = tp[0] - tp[1] + tp[2] - tp[3]
# assert twisted_part == int(twisted_part)
# else: sigma_v = untwisted_part + twisted_part
# print "\n\tSmall signature value" # print(knot_description + "\t" + str(shifted_theta) +\
# print knot_description # "\t" + str(sigma_v))
# print "v_theta: " + str(v_theta) # + "\t" + str(2 * sigma_q_1(2 * ksi * a_4)))
# print condition
# print "non zero value in v_theta: " + str(np.count_nonzero(v_theta)) if abs(sigma_v) > 5 + np.count_nonzero(shifted_theta):
# print "signature at 1/2: " + str(y) large_sigma_for_this_vector = True
return good_knots # break
# else:
# pass
# print(knot_description + "\t" + \
# str(shifted_theta) +\
# "\t" + str(sigma_v))
if large_sigma_for_this_vector:
good_vectors.append(shifted_theta)
pass
# print("large_sigma_for_this_vector\n\n\n\n")
# print("\n\nHURA HURA")
else:
# print(shifted_theta)
# if a_3 == a_4:
# print(sigma_q_1(ksi * a_4 * 2))
bad_vectors.append(shifted_theta)
large_sigma_for_last_theta_zero = False
# break
if large_sigma_for_last_theta_non_zero and large_sigma_for_last_theta_zero:
print(100 * "\n\nHURA HURA")
print(knot_description)
# # if config.print_calculations_for_large_sigma:
# # print("*" * 100)
# # print("\n\nLarge signature value\n")
# # print(knot_description)
# # print("\nv_theta: ", end="")
# # print(v_theta)
# # print("k values: ", end="")
# # print(str(k_1) + " " + str(k_2) + " " + \
# # str(k_3) + " " + str(k_4))
# # print(condition)
# # print("non zero value in v_theta: " + \
# # str(np.count_nonzero(v_theta)))
# # print("sigma_v: " + str(sigma_v))
# # print("\ntwisted_part: ", end="")
# # print(twisted_part)
# # print("untwisted_part: ", end="")
# # print(untwisted_part)
# # print("\n\nCALCULATIONS")
# # print("*" * 100)
# # sults_LT(v_theta, knot_description,
# # ksi, untwisted_part,
# # k, sigma_q_1, sigma_q_2, sigma_q_3)
# # sults_sigma(v_theta, knot_description, tp, q_4)
# # print("*" * 100 + "\n" * 5)
# # else:
# # print(knot_description + "\t" + str(v_theta) +\
# # "\t" + str(sigma_v) + "\t" + str(2 * sigma_q_1(2 * ksi * a_4)))
# # # if config.stop_after_firts_large_sigma:
# # # break
# # # sigma is small
# # else:
# # if config.print_calculations_for_small_sigma:
# # print("\n" * 5 + "*" * 100)
# # print("\nSmall signature value\n")
# # print(knot_description)
# # print_results_LT(v_theta, knot_description, ksi, untwisted_part,
# # k, sigma_q_1, sigma_q_2, sigma_q_3)
# # print_results_sigma(v_theta, knot_description, tp, q_4)
# # print("*" * 100 + "\n" * 5)
# # large_sigma_for_all_v_combinations = False
# #
# # if not config.print_calculations_for_small_sigma:
# # print(knot_description + "\t" + str(v_theta) +\
# # "\t" + str(sigma_v) + "\t" + str(2 * sigma_q_1(2 * ksi * a_4)))
# #
# #
# # # print("ojojojoj")
# # # break
#
# if large_sigma_for_all_v_combinations:
# print("\n\n\nHura hura")
# good_knots.append((knot_description, v_theta))
#
# # else:
# # print "\n\tSmall signature value"
# # print knot_description
# # print "v_theta: " + str(v_theta)
# # print condition
# # print "non zero value in v_theta: " + str(np.count_nonzero(v_theta))
# # print "signature at 1/2: " + str(y)
print("\ngood_vectors")
print(good_vectors)
print("\nbad_vectors")
print(bad_vectors)
return None
def print_results_LT(v_theta, knot_description, ksi, untwisted_part, def print_results_LT(v_theta, knot_description, ksi, untwisted_part,
@ -947,7 +1020,17 @@ get_signature_summand_as_theta_function.__doc__ = \
a function that returns SignatureFunction for this single cable a function that returns SignatureFunction for this single cable
and a theta given as an argument and a theta given as an argument
""" """
SignatureFunction.__doc__ = \
"""
This simple class encodes twisted and untwisted signature functions
of knots. Since the signature function is entirely encoded by its signature
jump, the class stores only information about signature jumps
in a dictionary self.signature_jumps.
The dictionary stores data of the signature jump as a key/values pair,
where the key is the argument at which the functions jumps
and value encodes the value of the jump. Remember that we treat
signature functions as defined on the interval [0,1).
"""
get_signture_function_docsting = \ get_signture_function_docsting = \
""" """
This function returns SignatureFunction for previously defined single This function returns SignatureFunction for previously defined single