saving results to file

This commit is contained in:
maria 2021-07-22 23:24:13 +02:00
parent e125b72ef2
commit 10c79cb47c
8 changed files with 573 additions and 268431 deletions

View File

@ -6,27 +6,33 @@ r"""calculations of signature function and sigma invariant of generalized algebr
The package was used to prove Lemma 3.2 from a paper
'On the slice genus of generalized algebraic knots' Maria Marchwicka and Wojciech Politarczyk).
It contains the following submodules.
1) signature.sage - contains SignatureFunction class;
1) main.sage - with function prove_lemma
2) signature.sage - contains SignatureFunction class;
it encodes twisted and untwisted signature functions
of knots and allows to perform algebraic operations on them.
2) cable_signature.sage - contains the following classes:
3) cable_signature.sage - contains the following classes:
a) CableSummand - it represents a single cable knot,
b) CableSum - it represents a cable sum, i. e. linear combination of single cable knots;
since the signature function and sigma invariant are additive under connected sum,
the class use calculations from CableSummand objects,
c) CableTemplate - it represents schema for a cable sums.
3) main.sage - module that encodes interesting schemas for cable and perform calculations,
e.g. a proof for Lemma 3.2 from the paper.
c) CableTemplate - it represents a scheme for a cable sums.
"""
#
# 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 .
#
from .utility import import_sage
import os
package = __name__.split('.')[0]
dirname = os.path.dirname
path = dirname(dirname(__file__))
import_sage('signature', package=package, path=path)
import_sage('cable_signature', package=package, path=path)
import_sage('main', package=package, path=path)
from .main import prove_lemma
# EXAMPLES::
#
# sage: eval_cable_for_null_signature([[1, 3], [2], [-1, -2], [-3]])
@ -56,13 +62,3 @@ It contains the following submodules.
# 2) set each q_i all or choose range in which q_i should varry
# 3) choose vector v / theta vector.
#
from .utility import import_sage
import os
package = __name__.split('.')[0]
dirname = os.path.dirname
path = dirname(dirname(__file__))
import_sage('signature', package=package, path=path)
import_sage('cable_signature', package=package, path=path)
import_sage('main', package=package, path=path)

View File

@ -3,7 +3,9 @@
import numpy as np
import itertools as it
import warnings
import logging
import re
import ast
from typing import Iterable
from collections import Counter
from sage.arith.functions import LCM_list
@ -487,8 +489,11 @@ class CableSum:
return result.is_integer()
def is_function_big_in_ranges(self, ranges_list, invariant=SIGMA,
verbose=None):
verbose=None, details=False,
p_part_order=None):
verbose = verbose or self.verbose
p_part_order = p_part_order or self.q_order
if invariant == SIGNATURE:
get_invariant = self.get_sign_ext_for_theta
name = "signature (extremum)"
@ -496,21 +501,25 @@ class CableSum:
get_invariant = self.sigma_as_function_of_theta
name = "sigma value"
if verbose:
msg = "\nCalculating {}-primary part.".format(p_part_order)
print(msg)
logging.info(str(ranges_list))
for thetas in it.product(*ranges_list):
# Check only non-zero metabolizers.
if not self.is_metabolizer(thetas) or not any(thetas):
continue
#
# cond1 = thetas[0] and thetas[3] and not thetas[1] and not thetas[2]
# cond = thetas[0] and thetas[3] and not thetas[1] and not thetas[2]
function_is_small = True
# Check if any element generated by thetas vector
# has a large signature or sigma.
for shift in range(1, self.q_order):
shifted_thetas = [shift * th for th in thetas]
for shift in range(1, p_part_order):
shifted_thetas = \
[(shift * th) % p_part_order for th in thetas]
limit = 5 + np.count_nonzero(shifted_thetas)
inv_value = get_invariant(shifted_thetas, limit=limit)
abs_value = abs(inv_value)
@ -518,17 +527,22 @@ class CableSum:
if verbose:
if shift == 1:
print("\n" + "*" * 10)
print("Knot sum:\n" + self.knot_description)
print("[ characters ] " + name)
print("[ character ] " + name)
print(shifted_thetas, end=" ")
print(inv_value)
if abs_value > limit:
function_is_small = False
if invariant == SIGMA and verbose:
if details:
self.print_calculations_for_sigma(*shifted_thetas)
break
if function_is_small:
if verbose and invariant == SIGMA:
msg = "For an element x = " + str(thetas)
msg += " there does not exist any shift such that "
msg += "|sigma(K, shift * x)| > {}.\n".format(limit)
msg += "We can not give any lower bound for 4-genus."
print(msg)
return False
return True
@ -569,34 +583,63 @@ class CableSum:
print("Sigma = {} ~ {}\n".format(sigma[2], int(sigma[2])))
# function that proves the main lemma
def is_function_big_for_all_metabolizers(self, invariant=SIGMA):
def is_function_big_for_all_metabolizers(self, invariant=SIGMA,
verbose=False, details=False):
logging.info("start of is_function_big_for_all_metabolizers")
if invariant == SIGNATURE:
name = "signature (extremum)"
else:
name = "sigma value"
num_of_summands = len(self.knot_sum_as_k_valus)
if num_of_summands % 4:
f_name = self.is_signature_big_for_all_metabolizers.__name__
msg = "Function {}".format(f_name) + " is implemented only for " +\
"knots that are direct sums of 4n direct summands."
raise ValueError(msg)
# check each p-primary part separately
logging.info("number of summands is {}".format(num_of_summands))
for shift in range(0, num_of_summands, 4):
# set character (twist) to be zero for all summands
ranges_list = num_of_summands * [range(0, 1)]
logging.info("shift is {}".format(shift))
p_part_order = 2 * self.patt_k_list[shift] + 1
logging.info("set character (twist) to be zero for all summands")
ranges_list = num_of_summands * [range(1)]
logging.info(str(ranges_list))
# change ranges for all but one character for current p-primary part
ranges_list[shift : shift + 3] = \
[range(0, i + 1) for i in self.patt_k_list[shift: shift + 3]]
# change range for last character in current p-primary part
ranges_list[shift + 1 : shift + 4] = 3 * [range(p_part_order)]
# change range for first character in current p-primary part
# this one is consider to be 0 or 1
# For any characters combinations (vectors) [a_1, a_2, a_3, a_4] where a_4 != 0
# exists such as k < p that k * a_4 % p == 1.
ranges_list[shift + 3] = range(0, 2)
if not self.is_function_big_in_ranges(ranges_list, invariant):
# For any characters combinations (vectors) [a_1, a_2, a_3, a_4]
# where a_4 != 0 exists such a k < p that k * a_1 % p == 1.
ranges_list[shift] = range(0, 2)
logging.info("\n\ncall is_function_big_in_ranges with values")
logging.info(str(ranges_list))
if not self.is_function_big_in_ranges(ranges_list, invariant,
p_part_order=p_part_order,
verbose=verbose,
details=details):
logging.info("Not proven.")
return False
if verbose and invariant == SIGMA:
msg = "For each p-primery part for each vector x there exist "
msg += "a number 0 < shift < p such that "
msg += "sigma(K, shift * x) > 5 + eta(K, shift * x)."
print(msg)
print("q.e.d.")
return True
class CableTemplate:
def __init__(self, knot_formula, q_vector=None, k_vector=None,
generate_q_vector=True, slice=True, verbose=False):
generate_q_vector=True, algebraic=True, verbose=False):
self.verbose = verbose
self._knot_formula = knot_formula
# q_i = 2 * k_i + 1
@ -605,7 +648,27 @@ class CableTemplate:
elif q_vector is not None:
self.q_vector = q_vector
elif generate_q_vector:
self.q_vector = self.get_q_vector(slice=slice)
self.q_vector = self.get_q_vector(algebraic=slice)
self.templete_description = self.get_template_descrption()
def __str__(self):
return self.templete_description
def get_template_descrption(self):
k_indices = re.sub(r'[k ]', '', self.knot_formula)
k_indices = re.sub(r'\[\d+\]', lambda x: x.group()[1:-1], k_indices)
k_indices = ast.literal_eval(k_indices)
description = ""
for summand in k_indices :
part = ""
if summand[0] < 0:
part += "-"
part += "T("
for k in summand:
part += "2, q_" + str(abs(k)) + "; "
description += part[:-2] + ") # "
return description[:-3]
@property
def cable(self):
@ -616,7 +679,7 @@ class CableTemplate:
self.fill_q_vector()
return self._cable
def fill_q_vector(self, q_vector=None, slice=True, lowest_number=2):
def fill_q_vector(self, q_vector=None, algebraic=True, lowest_number=2):
self.q_vector = q_vector or self.get_q_vector(slice, lowest_number)
@property
@ -631,6 +694,7 @@ class CableTemplate:
self._k_vector = k
if self.extract_max(self.knot_formula) > len(k) - 1:
msg = "The vector for knot_formula evaluation is to short!"
msg += "Note that we count from 0 (not 1)."
msg += "\nk_vector " + str(k) + " \nknot_formula " \
+ str(self.knot_formula)
raise IndexError(msg)
@ -652,19 +716,28 @@ class CableTemplate:
numbers = map(int, numbers)
return max(numbers)
def get_q_vector(self, slice=True, lowest_number=2):
def get_q_vector(self, algebraic=True, lowest_number=2):
r"""
Returns q-vector with certain properties.
If slice a specific relation for each cabling-level is preserved.
Consider a cable T(2, q_0; 2, q_1; ...; 2, q_n).
Then for every q_i, q_(i + 1): q_(i + 1) > q_i * 4
"""
knot_formula = self.knot_formula
q_vector = [0] * (self.extract_max(knot_formula) + 1)
P = Primes()
for layer in self.get_layers_from_formula(knot_formula)[::-1]:
for layer in self._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
if slice:
lowest_number *= 4
return q_vector
@staticmethod
def get_layers_from_formula(knot_formula):
def _get_layers_from_formula(knot_formula):
r"""helper method for get_q_vector"""
k_indices = re.sub(r'[k-]', '', knot_formula)
k_indices = re.sub(r'\[\d+\]', lambda x: x.group()[1:-1], k_indices)
k_indices = eval(k_indices)

View File

@ -1,6 +1,9 @@
#!/usr/bin/env sage -python
# TBD: read about Factory Method, variable in docstring, sage documentation,
# TBD
# print scheme and knot nicely
# read about Factory Method, variable in docstring, sage documentation,
# print calc. to output file
# decide about printing option
# make __main__?
@ -13,6 +16,9 @@ import re
import numpy as np
import importlib
# constants - which invariants should be calculate
SIGMA = 0
SIGNATURE = 1
if __name__ == '__main__':
from utility import import_sage
@ -33,41 +39,62 @@ cs = import_sage('cable_signature', package=package, path=path)
# def __init__(self):
# self.f_results = os.path.join(os.getcwd(), "results.out")
class Schemas:
class Schema:
r"""This class stores inreresting schema of cable sums.
Cable knots sum can be given as a scheme, e.g. a scheme from the paper:
K(p_1 , p_2 , q_1 , q_2 , q_3 ) =
T(2, q_1; 2, p_1) # -T(2, q_2; 2, p_1) # T(2, p_1) # -T(2, q_3; 2, p_1) +
T(2, q_2; 2, p_2) # -T(2, p_2) # T(2, q_3; 2, p_2) # -T(2, q_1; 2, p_2).
We can represent it as nested list:
lemma_scheme = "[[ k[5], k[3]], " + \
"[ -k[1], -k[3]], " + \
"[ k[3]], " + \
"[ -k[6], -k[3]], " + \
"[ k[1], k[7]], " + \
"[ -k[7]], " + \
"[ k[6], k[7]], " + \
"[ -k[5], -k[7]]]",
where each k[i] corresponds to some q_i or p_i.
This expression will be later evaluated with k_vector.
See k_vector setter in class CableTemplate in cable_signature.sage module.
# knot_formula = "[[k[0], k[1], k[2]],\
# [ k[3], k[4]],\
# [-k[0], -k[3], -k[4]],\
# [ -k[1], -k[2]]]"
#
# knot_formula = "[[k[0], k[1], k[2]],\
# [ k[3]],\
# [-k[0], -k[1], -k[3]],\
# [ -k[2]]]"
Remark 1
In the paper we used p_i and q_i to describe torus knots and cables.
It was convinient for writing, but in all the code and documentation
only 'q' letter is used to encode torus knots or cables.
Remark 2
There are two ways to set k[i] values for a scheme:
via q_vector or via k_vector.
Both should be lists and the relation is q[i] = 2 * k[i] + 1,
i.e. q should be an odd prime and k should be an even number such that
2 * k + 1 is prime.
To fill the scheme listed above we shoud use a list of lenght 8,
and k[0] will be ommited as it is not used in the scheme.
short_3_layers_a = "[[ k[5], k[3]], " + \
"[ -k[1], -k[3]], " + \
"[ k[3]], " + \
"[ -k[4], -k[6], -k[3]]]"
Remark 3
Except for development purposes, q_vector was computed with
a methode CableTemplate.get_q_vector and flag slice=True.
The reason for that is that we were interested only in cases
where a specific relation for each cabling-level is preserved.
Consider a cable T(2, q_0; 2, q_1; ...; 2, q_n).
Then for every q_i, q_(i + 1): q_(i + 1) > q_i * 4.
short_3_layers_b = "[[k[4], k[1], k[7]], " + \
"[ -k[7]], " + \
"[ k[6], k[7]], " + \
"[ -k[5], -k[7]]]"
"""
schema_short1 = "[ [k[5], k[3]], " + \
"[ -k[1], -k[3]], " + \
"[ k[3]], " + \
"[ -k[6], -k[3]]]"
# scheme that is used in the paper
lemma_scheme_a = "[ [k[5], k[3]], " + \
"[ -k[1], -k[3]], " + \
"[ k[3]], " + \
"[ -k[6], -k[3]]]"
schema_short2 = "[[ k[1], k[7]], " + \
"[ -k[7]], " + \
"[ k[6], k[7]], " + \
"[ -k[5], -k[7]]]"
lemma_scheme_b = "[[ k[1], k[7]], " + \
"[ -k[7]], " + \
"[ k[6], k[7]], " + \
"[ -k[5], -k[7]]]"
schema_short = "[[ k[5], k[3]], " + \
lemma_scheme = "[[ k[5], k[3]], " + \
"[ -k[1], -k[3]], " + \
"[ k[3]], " + \
"[ -k[6], -k[3]], " + \
@ -76,40 +103,76 @@ class Schemas:
"[ k[6], k[7]], " + \
"[ -k[5], -k[7]]]"
# two_summands_schema = "[ [k[0], k[1], k[4]], [-k[1], -k[3]],\
# [k[2], k[3]], [-k[0], -k[2], -k[4]] ]"
# two_small_summands_schema = "[[k[3]], [-k[3]],\
# [k[3]], [-k[3]] ]"
#
# four_summands_schema = "[[k[3], k[2], k[0]],\
# [ -k[2], -k[0]],\
# [ k[1], k[0]],\
# [-k[3], -k[1], -k[0]]]"
# formula_long = "[[k[0], k[5], k[3]], " + \
# "[ -k[5], -k[3]], " + \
# "[ k[2], k[3]], " + \
# "[-k[4], -k[2], -k[3]]" + \
# "[ k[4], k[1], k[7]], " + \
# "[ -k[1], -k[7]], " + \
# "[ k[6], k[7]], " + \
# "[-k[0], -k[6], -k[7]]]"
#
four_summands_schema = "[[ k[0], k[1], k[3]]," + \
"[ -k[1], -k[3]]," + \
"[ k[2], k[3]]," + \
"[ -k[0], -k[2], -k[3]]]"
# formula_1 = "[[ k[0], k[5], k[3]], " + \
# formula_a = "[[k[0], k[5], k[3]], " + \
# "[ -k[1], -k[3]], " + \
# "[ k[3]], " + \
# "[-k[4], -k[6], -k[3]]]"
#
# formula_b = "[[k[4], k[1], k[7]], " + \
# "[ -k[7]], " + \
# "[ k[6], k[7]], " + \
# "[-k[0], -k[5], -k[7]]]"
#
# formula_a = "[[ k[0], k[5], k[3]], " + \
# "[ -k[1], -k[3]], " + \
# "[ k[2], k[3]], " + \
# "[ -k[0], -k[2], -k[3]]]"
#
# formula_2 = "[[ k[4], k[1], k[7]], " + \
# formula_b = "[[ k[4], k[1], k[7]], " + \
# "[ -k[5], -k[7]], " + \
# "[ k[6], k[7]], " + \
# "[ -k[4], -k[6], -k[7]]]"
#
# formula_1 = "[[ k[0], k[5], k[3]], " + \
# formula_a = "[[ k[0], k[5], k[3]], " + \
# "[ -k[5], -k[3]], " + \
# "[ k[2], k[3]], " + \
# "[-k[4], -k[2], -k[3]]]"
#
# formula_2 = "[[ k[4], k[1], k[7]], " + \
# formula_b = "[[ k[4], k[1], k[7]], " + \
# "[ -k[1], -k[7]], " + \
# "[ k[6], k[7]], " + \
# "[-k[0], -k[6], -k[7]]]"
#
#
# three_layers_formula_a = "[[k[0], k[1], k[2]],\
# [ k[3], k[4]],\
# [-k[0], -k[3], -k[4]],\
# [ -k[1], -k[2]]]"
#
# three_layers_formula_b = "[[k[0], k[1], k[2]],\
# [ k[3]],\
# [-k[0], -k[1], -k[3]],\
# [ -k[2]]]"
#
# short_3_layers_b = "[[ k[5], k[3]], " + \
# "[ -k[1], -k[3]], " + \
# "[ k[3]], " + \
# "[ -k[4], -k[6], -k[3]]]"
#
# short_3_layers_b = "[[k[4], k[1], k[7]], " + \
# "[ -k[7]], " + \
# "[ k[6], k[7]], " + \
# "[ -k[5], -k[7]]]"
#
# four_summands_scheme = "[[ k[0], k[1], k[3]]," + \
# "[ -k[1], -k[3]]," + \
# "[ k[2], k[3]]," + \
# "[ -k[0], -k[2], -k[3]]]"
#
# two_summands_scheme = "[ [k[0], k[1], k[4]], [-k[1], -k[3]],\
# [k[2], k[3]], [-k[0], -k[2], -k[4]] ]"
# two_small_summands_scheme = "[[k[3]], [-k[3]],\
# [k[3]], [-k[3]] ]"
def main(arg=None):
@ -120,43 +183,69 @@ def main(arg=None):
conf = Config()
cable_loop_with_details(conf)
def prove_lemma(verbose=True, details=False):
def print_sigma_for_cable(verbose=True, Schemas=None):
if verbose:
msg = "CALCULATIONS OF THE SIGMA INVARIANT\n"
msg += "Proof of main lemma from "
msg += "ON THE SLICE GENUS OF GENERALIZED ALGEBRAIC KNOTS\n\n"
print(msg)
schema_short1 = Schemas.schema_short1
schema_short2 = Schemas.schema_short2
schema_short = Schemas.schema_short
schema_four = Schemas.four_summands_schema
lemma_scheme = Schema.lemma_scheme
cable_template = cs.CableTemplate(knot_formula=schema_short)
cable_template = cs.CableTemplate(knot_formula=lemma_scheme,
verbose=verbose)
cable_template.fill_q_vector()
q_v = cable_template.q_vector
cable = cable_template.cable
if verbose:
msg = "Let us consider a cable knot: \nK = "
msg += cable.knot_description + ".\n"
msg += "It is an example of cable knots of a scheme:\n"
msg += str(cable_template) + "."
print(msg)
cable.is_function_big_for_all_metabolizers(invariant=SIGMA,
verbose=verbose,
details=details)
def print_sigma_for_cable(verbose=True):
lemma_scheme_a = Schema.lemma_scheme_a
lemma_scheme_b = Schema.lemma_scheme_b
lemma_scheme = Schema.lemma_scheme
scheme_four = Schema.four_summands_scheme
cable_template = cs.CableTemplate(knot_formula=lemma_scheme)
cable_template.fill_q_vector()
q_v = cable_template.q_vector
print(q_v)
print(cable_template.cable.knot_description)
cable1 = cs.CableTemplate(knot_formula=schema_short1,
cable_a = cs.CableTemplate(knot_formula=lemma_scheme_a,
verbose=verbose,
q_vector=q_v
).cable
cable2 = cs.CableTemplate(knot_formula=schema_short2,
cable_b = cs.CableTemplate(knot_formula=lemma_scheme_b,
verbose=verbose,
q_vector=q_v
).cable
cable = cs.CableTemplate(knot_formula=schema_short1,
cable = cs.CableTemplate(knot_formula=lemma_scheme_a,
verbose=verbose,
q_vector=q_v
).cable
cable.plot_sigma_for_summands()
# cable1.plot_sigma_for_summands()
# cable2.plot_sigma_for_summands()
# cable_a.plot_sigma_for_summands()
# cable_b.plot_sigma_for_summands()
def cable_loop_with_details(verbose=True):
# verbose = False
schema_short1 = Schemas.schema_short1
schema_short2 = Schemas.schema_short2
schema_short = Schemas.schema_short
cable_template = cs.CableTemplate(knot_formula=schema_short)
lemma_scheme_a = Schema.lemma_scheme_a
lemma_scheme_b = Schema.lemma_scheme_b
lemma_scheme = Schema.lemma_scheme
cable_template = cs.CableTemplate(knot_formula=lemma_scheme)
list_of_q_vectors = []
# for el in [2, 3, 5, 7, 11, 13]:
@ -165,19 +254,23 @@ def cable_loop_with_details(verbose=True):
q_v = cable_template.q_vector
print(q_v)
print(cable_template.cable.knot_description)
cable1 = cs.CableTemplate(knot_formula=schema_short1,
cable_a = cs.CableTemplate(knot_formula=lemma_scheme_a,
verbose=verbose,
q_vector=q_v
).cable
cable2 = cs.CableTemplate(knot_formula=schema_short2,
cable_b = cs.CableTemplate(knot_formula=lemma_scheme_b,
verbose=verbose,
q_vector=q_v
).cable
# print("\n")
# print(cable1.knot_description)
is_1 = cable1.is_function_big_for_all_metabolizers(invariant=cs.SIGMA)
is_2 = cable2.is_function_big_for_all_metabolizers(invariant=cs.SIGMA)
if is_1 and is_2:
# print(cable_a.knot_description)
is_a = cable_a.is_function_big_for_all_metabolizers(invariant=cs.SIGMA,
verbose=True,
details=True)
is_b = cable_b.is_function_big_for_all_metabolizers(invariant=cs.SIGMA,
verbose=True,
details=True)
if is_a and is_b:
print("sigma is big for all metabolizers")
else:
print("sigma is not big for all metabolizers")
@ -186,11 +279,11 @@ def cable_loop_with_details(verbose=True):
def few_cable_without_calc(verbose=False):
schema_short1 = Schemas.schema_short1
schema_short2 = Schemas.schema_short2
schema_short = Schemas.schema_short
lemma_scheme_a = Schema.lemma_scheme_a
lemma_scheme_b = Schema.lemma_scheme_b
lemma_scheme = Schema.lemma_scheme
cable_template = cs.CableTemplate(knot_formula=schema_short)
cable_template = cs.CableTemplate(knot_formula=lemma_scheme)
list_of_q_vectors = []
for el in [2, 3, 5, 7, 11, 13]:
@ -198,43 +291,23 @@ def few_cable_without_calc(verbose=False):
q_v = cable_template.q_vector
print(q_v)
print(cable_template.cable.knot_description)
cable1 = cs.CableTemplate(knot_formula=schema_short1,
cable_a = cs.CableTemplate(knot_formula=lemma_scheme_a,
verbose=verbose,
q_vector=q_v
).cable
cable2 = cs.CableTemplate(knot_formula=schema_short2,
cable_b = cs.CableTemplate(knot_formula=lemma_scheme_b,
verbose=verbose,
q_vector=q_v
).cable
is_1 = cable1.is_function_big_for_all_metabolizers(invariant=sigma)
is_2 = cable2.is_function_big_for_all_metabolizers(invariant=sigma)
if is_1 and is_2:
is_a = cable_a.is_function_big_for_all_metabolizers(invariant=sigma)
is_b = cable_b.is_function_big_for_all_metabolizers(invariant=sigma)
if is_a and is_b:
print("sigma is big for all metabolizers")
else:
print("sigma is not big for all metabolizers")
print("\n" * 3)
def smallest_cable(verbose=True):
schema_short1 = Schemas.schema_short1
schema_short2 = Schemas.schema_short2
schema_short = Schemas.schema_short
cable_template = cs.CableTemplate(knot_formula=schema_short)
q_v = cable_template.q_vector
print(q_v)
cable1 = cs.CableTemplate(knot_formula=schema_short1,
verbose=verbose,
q_vector=q_v).cable
cable2 = cs.CableTemplate(knot_formula=schema_short2,
verbose=verbose,
q_vector=q_v).cable
cable1.is_function_big_for_all_metabolizers(invariant=sigma)
cable2.is_function_big_for_all_metabolizers(invariant=sigma)
def plot_many_untwisted_signature_functions(range_tuple=(1, 10)):
P = Primes()
for i in range(*range_tuple):
@ -250,26 +323,3 @@ if __name__ == '__main__':
else:
pass
# main()
# formula_long = "[[k[0], k[5], k[3]], " + \
# "[-k[5], -k[3]], " + \
# "[k[2], k[3]], " + \
# "[-k[4], -k[2], -k[3]]" + \
# "[k[4], k[1], k[7]], " + \
# "[-k[1], -k[7]], " + \
# "[k[6], k[7]], " + \
# "[-k[0], -k[6], -k[7]]]"
#
#
# formula_1 = "[[k[0], k[5], k[3]], " + \
# "[-k[1], -k[3]], " + \
# "[ k[3]], " + \
# "[-k[4], -k[6], -k[3]]]"
#
# formula_2 = "[[k[4], k[1], k[7]], " + \
# "[ -k[7]], " + \
# "[k[6], k[7]], " + \
# "[-k[0], -k[5], -k[7]]]"
#
#

View File

@ -32,7 +32,14 @@ ipython_info = get_ipython_info()
class SignatureFunction:
r"""signature function is entirely encoded by its signature
jump, the class stores only information about signature jumps
in a dictionary self.jumps_counter
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, plot_title=''):
# counter of signature jumps
@ -367,16 +374,3 @@ class SignaturePloter:
\end{document}
"""
f.write(tail)
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.jumps_counter.
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).
"""

View File

@ -27,7 +27,7 @@ def import_sage(module_name, package=None, path=''):
r"""Import or reload SageMath modules with preparse if the sage file exist.
Arguments:
module_name - name of the module (without extension!)
module_name - name of the module (without file extension!)
package - use only if module is used as a part of a package
Return:
module
@ -37,8 +37,6 @@ def import_sage(module_name, package=None, path=''):
# equivalent to import module_name as my_prefered_shortcut}
my_prefered_shortcut = import_sage('module_name')
"""
sage_name = module_name + ".sage"
python_name = module_name + ".sage.py"

99
notebooks/lemma.ipynb Normal file
View File

@ -0,0 +1,99 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import path\n",
"import logging\n",
"from contextlib import redirect_stdout\n",
"# logging.basicConfig(level=logging.INFO)\n",
"import gaknot"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Lemma "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"gaknot.prove_lemma()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Details to file"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"with open('very_detailed_calculations.txt', 'w') as f:\n",
" with redirect_stdout(f):\n",
" gaknot.prove_lemma(details=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Calculations to file"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"with open('calculations.txt', 'w') as f:\n",
" with redirect_stdout(f):\n",
" gaknot.prove_lemma(details=False)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "SageMath 9.0",
"language": "sage",
"name": "sagemath"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

File diff suppressed because one or more lines are too long

View File

@ -12,7 +12,9 @@
"# display full output, not only last result, except ended with semicolon\n",
"from IPython.core.interactiveshell import InteractiveShell\n",
"InteractiveShell.ast_node_interactivity = 'all';\n",
"from IPython.display import Image, SVG"
"from IPython.display import Image, SVG\n",
"import logging\n",
"logging.basicConfig(level=logging.INFO)"
]
},
{
@ -28,6 +30,17 @@
"m = import_sage('main', package='gaknot', path=path.module_path)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"m.prove_lemma(verbose=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
@ -43,17 +56,17 @@
},
"outputs": [],
"source": [
"knot_formula = \"[[k[0], k[1], k[3]],\" + \\\n",
" \" [-k[1], -k[3]],\" + \\\n",
" \" [k[2], k[3]],\" + \\\n",
" \" [-k[0], -k[2], -k[3]]]\"\n",
"# q_vector = (3, 5, 7, 13)\n",
"q_vector = (3, 5, 7, 11)\n",
"# knot_formula = \"[[k[0], k[1], k[3]],\" + \\\n",
"# \" [-k[1], -k[3]],\" + \\\n",
"# \" [k[2], k[3]],\" + \\\n",
"# \" [-k[0], -k[2], -k[3]]]\"\n",
"# # q_vector = (3, 5, 7, 13)\n",
"# q_vector = (3, 5, 7, 11)\n",
"\n",
"template = cs.CableTemplate(knot_formula, q_vector=q_vector, verbose=True)\n",
"cable = template.cable\n",
"# cable.plot_all_summands()\n",
"cable.is_function_big_for_all_metabolizers(invariant=cs.SIGMA)"
"# template = cs.CableTemplate(knot_formula, q_vector=q_vector, verbose=True)\n",
"# cable = template.cable\n",
"# # cable.plot_all_summands()\n",
"# cable.is_function_big_for_all_metabolizers(invariant=cs.SIGMA)"
]
},
{
@ -80,11 +93,27 @@
"\n",
"\n",
"\n",
"cable_template_1 = cs.CableTemplate(knot_formula=formula_1)\n",
"cable_template_2 = cs.CableTemplate(knot_formula=formula_2)\n",
"cable_template = cable_template_1 + cable_template_2"
"# cable_template_1 = cs.CableTemplate(knot_formula=formula_1)\n",
"# cable_template_2 = cs.CableTemplate(knot_formula=formula_2)\n",
"# cable_template = cable_template_1 + cable_template_2"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# cable_template.knot_formula"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
@ -98,17 +127,17 @@
"metadata": {},
"outputs": [],
"source": [
"q_vector = (5, 13, 19, 41,\\\n",
" 7, 17, 23, 43)\n",
"cable_template.fill_q_vector(q_vector=q_vector)\n",
"cable = cable_template.cable\n",
"print(cable.knot_description)\n",
"# q_vector = (5, 13, 19, 41,\\\n",
"# 7, 17, 23, 43)\n",
"# cable_template.fill_q_vector(q_vector=q_vector)\n",
"# cable = cable_template.cable\n",
"# print(cable.knot_description)\n",
"\n",
"q_vector_small = (3, 7, 13, 19,\\\n",
" 5, 11, 17, 23)\n",
"cable_template.fill_q_vector(q_vector=q_vector)\n",
"cable = cable_template.cable\n",
"print(cable.knot_description)"
"# q_vector_small = (3, 7, 13, 19,\\\n",
"# 5, 11, 17, 23)\n",
"# cable_template.fill_q_vector(q_vector=q_vector)\n",
"# cable = cable_template.cable\n",
"# print(cable.knot_description)"
]
},
{
@ -136,14 +165,14 @@
"outputs": [],
"source": [
"\n",
"cable_template.fill_q_vector()\n",
"# print(cable_template.q_vector)\n",
"# print(cable_template.knot_formula)\n",
"# cable_template.fill_q_vector()\n",
"# # print(cable_template.q_vector)\n",
"# # print(cable_template.knot_formula)\n",
"\n",
"slice_canidate = cable_template.cable\n",
"print(slice_canidate.knot_description)\n",
"sf = slice_canidate(4,4,4,4,0,0,0,0)\n",
"sf = slice_canidate(4,1,1,4,0,0,0,0)\n",
"# slice_canidate = cable_template.cable\n",
"# print(slice_canidate.knot_description)\n",
"# sf = slice_canidate(4,4,4,4,0,0,0,0)\n",
"# sf = slice_canidate(4,1,1,4,0,0,0,0)\n",
"\n",
"\n",
"# cable.is_signature_big_for_all_metabolizers()\n"
@ -190,22 +219,22 @@
"\n",
"\n",
"\n",
"cable_template_1 = cs.CableTemplate(knot_formula=formula_1)\n",
"cable_template_2 = cs.CableTemplate(knot_formula=formula_2)\n",
"cable_template = cable_template_1 + cable_template_2\n",
"# cable_template_1 = cs.CableTemplate(knot_formula=formula_1)\n",
"# cable_template_2 = cs.CableTemplate(knot_formula=formula_2)\n",
"# cable_template = cable_template_1 + cable_template_2\n",
"\n",
"cable_template.fill_q_vector()\n",
"# print(cable_template.q_vector)\n",
"# print(cable_template.knot_formula)\n",
"# cable_template.fill_q_vector()\n",
"# # print(cable_template.q_vector)\n",
"# # print(cable_template.knot_formula)\n",
"\n",
"slice_canidate = cable_template.cable\n",
"print(slice_canidate.knot_description)\n",
"sf = slice_canidate(4,4,4,4,0,0,0,0)\n",
"sf = slice_canidate(4,1,1,4,0,0,0,0)\n",
"# slice_canidate = cable_template.cable\n",
"# print(slice_canidate.knot_description)\n",
"# sf = slice_canidate(4,4,4,4,0,0,0,0)\n",
"# sf = slice_canidate(4,1,1,4,0,0,0,0)\n",
"\n",
"\n",
"slice_canidate.q_order\n",
"# slice_canidate.is_signature_big_for_all_metabolizers()"
"# slice_canidate.q_order\n",
"# # slice_canidate.is_signature_big_for_all_metabolizers()"
]
},
{
@ -226,20 +255,20 @@
"\n",
"\n",
"\n",
"cable_template_1 = cs.CableTemplate(knot_formula=formula_1)\n",
"cable_template_2 = cs.CableTemplate(knot_formula=formula_2)\n",
"cable_template = cable_template_1 + cable_template_2\n",
"cable_template.fill_q_vector()\n",
"# cable_template_1 = cs.CableTemplate(knot_formula=formula_1)\n",
"# cable_template_2 = cs.CableTemplate(knot_formula=formula_2)\n",
"# cable_template = cable_template_1 + cable_template_2\n",
"# cable_template.fill_q_vector()\n",
"\n",
"slice_canidate = cable_template.cable\n",
"print(slice_canidate.knot_description)\n",
"# slice_canidate = cable_template.cable\n",
"# print(slice_canidate.knot_description)\n",
"\n",
"slice_canidate.q_order\n",
"# slice_canidate.is_signature_big_for_all_metabolizers()\n",
"sigma = slice_canidate.get_sigma_as_function_of_theta()\n",
"# sigma((0, 6, 6, 0, 0,0,0,0))\n",
"# 13450/83\n",
"sigma((9, 9, 9, 9, 0,0,0,0))"
"# slice_canidate.q_order\n",
"# # slice_canidate.is_signature_big_for_all_metabolizers()\n",
"# sigma = slice_canidate.get_sigma_as_function_of_theta()\n",
"# # sigma((0, 6, 6, 0, 0,0,0,0))\n",
"# # 13450/83\n",
"# sigma((9, 9, 9, 9, 0,0,0,0))"
]
},
{
@ -275,18 +304,18 @@
"\n",
"\n",
"\n",
"cable_template_1 = cs.CableTemplate(knot_formula=formula_1)\n",
"cable_template_2 = cs.CableTemplate(knot_formula=formula_2)\n",
"cable_template = cable_template_1 + cable_template_2\n",
"# cable_template_1 = cs.CableTemplate(knot_formula=formula_1)\n",
"# cable_template_2 = cs.CableTemplate(knot_formula=formula_2)\n",
"# cable_template = cable_template_1 + cable_template_2\n",
"\n",
"cable_template.fill_q_vector()\n",
"# print(cable_template.q_vector)\n",
"# print(cable_template.knot_formula)\n",
"# cable_template.fill_q_vector()\n",
"# # print(cable_template.q_vector)\n",
"# # print(cable_template.knot_formula)\n",
"\n",
"slice_canidate = cable_template.cable\n",
"print(slice_canidate.knot_description)\n",
"sf = slice_canidate(4,4,4,4,0,0,0,0)\n",
"sf = slice_canidate(4,1,1,4,0,0,0,0)\n",
"# slice_canidate = cable_template.cable\n",
"# print(slice_canidate.knot_description)\n",
"# sf = slice_canidate(4,4,4,4,0,0,0,0)\n",
"# sf = slice_canidate(4,1,1,4,0,0,0,0)\n",
"# slice_canidate.is_signature_big_for_all_metabolizers()"
]
},
@ -311,20 +340,20 @@
"\n",
"\n",
"\n",
"cable_template_1 = cs.CableTemplate(knot_formula=formula_1)\n",
"cable_template_2 = cs.CableTemplate(knot_formula=formula_2)\n",
"cable_template = cable_template_1 + cable_template_2\n",
"# cable_template_1 = cs.CableTemplate(knot_formula=formula_1)\n",
"# cable_template_2 = cs.CableTemplate(knot_formula=formula_2)\n",
"# cable_template = cable_template_1 + cable_template_2\n",
"\n",
"cable_template.fill_q_vector()\n",
"# print(cable_template.q_vector)\n",
"# print(cable_template.knot_formula)\n",
"# cable_template.fill_q_vector()\n",
"# # print(cable_template.q_vector)\n",
"# # print(cable_template.knot_formula)\n",
"\n",
"slice_canidate = cable_template.cable\n",
"print(slice_canidate.knot_description)\n",
"sf = slice_canidate(4,4,4,4,0,0,0,0)\n",
"sf = slice_canidate(4,1,1,4,0,0,0,0)\n",
"slice_canidate.q_order\n",
"# slice_canidate.is_signature_big_for_all_metabolizers()\n"
"# slice_canidate = cable_template.cable\n",
"# print(slice_canidate.knot_description)\n",
"# sf = slice_canidate(4,4,4,4,0,0,0,0)\n",
"# sf = slice_canidate(4,1,1,4,0,0,0,0)\n",
"# slice_canidate.q_order\n",
"# # slice_canidate.is_signature_big_for_all_metabolizers()\n"
]
},
{
@ -333,8 +362,8 @@
"metadata": {},
"outputs": [],
"source": [
"sf = slice_canidate()\n",
"sf = sf[2]"
"# sf = slice_canidate()\n",
"# sf = sf[2]"
]
},
{
@ -343,7 +372,7 @@
"metadata": {},
"outputs": [],
"source": [
"sf.plot()"
"# sf.plot()"
]
},
{
@ -360,24 +389,62 @@
"formula_2 = \"[[ k[1], k[7]], \" + \\\n",
" \"[ -k[7]], \" + \\\n",
" \"[ k[6], k[7]], \" + \\\n",
" \"[ -k[5], -k[7]]]\"\n",
"\n",
"\n",
"\n",
"\n",
"cable_template_1 = cs.CableTemplate(knot_formula=formula_1)\n",
"cable_template_2 = cs.CableTemplate(knot_formula=formula_2)\n",
"cable_template = cable_template_1 + cable_template_2\n",
"\n",
"cable_template.fill_q_vector()\n",
" \"[ -k[5], -k[7]]]\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# cable_template_1 = cs.CableTemplate(knot_formula=formula_1)\n",
"# cable_template_2 = cs.CableTemplate(knot_formula=formula_2)\n",
"# cable_template = cable_template_1 + cable_template_2"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# cable_template.knot_formula"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# cable_template.fill_q_vector()\n",
"# print(cable_template.q_vector)\n",
"# print(cable_template.knot_formula)\n",
"\n",
"slice_canidate = cable_template.cable\n",
"print(slice_canidate.knot_description)\n",
"sf = slice_canidate(4,4,4,4,0,0,0,0)\n",
"sf = slice_canidate(4,1,1,4,0,0,0,0)\n",
"slice_canidate.q_order"
"# print(cable_template.knot_formula)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# cable_template.fill_q_vector()\n",
"# print(cable_template.q_vector)\n",
"# print(cable_template.knot_formula)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# slice_canidate = cable_template.cable\n",
"# print(slice_canidate.knot_description)\n",
"# sf = slice_canidate(4,4,4,4,0,0,0,0)\n",
"# sf = slice_canidate(4,1,1,4,0,0,0,0)\n",
"# slice_canidate.q_order"
]
},
{
@ -399,7 +466,7 @@
},
"outputs": [],
"source": [
"slice_canidate.is_function_big_for_all_metabolizers(invariant=cs.SIGMA)"
"# slice_canidate.is_function_big_for_all_metabolizers(invariant=cs.SIGMA)"
]
},
{
@ -410,7 +477,7 @@
},
"outputs": [],
"source": [
"slice_canidate.is_function_big_for_all_metabolizers(invariant=cs.SIGNATURE)"
"# slice_canidate.is_function_big_for_all_metabolizers(invariant=cs.SIGNATURE)"
]
},
{
@ -419,10 +486,10 @@
"metadata": {},
"outputs": [],
"source": [
"sigma = slice_canidate.get_sigma_as_function_of_theta()\n",
"sigma((0, 6, 6, 0, 0,0,0,0))\n",
"# 13450/83\n",
"sigma((9, 0, 0, 9, 0,0,0,0))"
"# sigma = slice_canidate.get_sigma_as_function_of_theta()\n",
"# sigma((0, 6, 6, 0, 0,0,0,0))\n",
"# # 13450/83\n",
"# sigma((9, 0, 0, 9, 0,0,0,0))"
]
},
{
@ -431,8 +498,8 @@
"metadata": {},
"outputs": [],
"source": [
"_, _, sf = slice_canidate((1, 1, 0, 0, 0,0,0,0))\n",
"sf"
"# _, _, sf = slice_canidate((1, 1, 0, 0, 0,0,0,0))\n",
"# sf"
]
},
{
@ -441,7 +508,7 @@
"metadata": {},
"outputs": [],
"source": [
"sg.SignaturePloter.plot(sf)"
"# sg.SignaturePloter.plot(sf)"
]
},
{
@ -453,7 +520,7 @@
"outputs": [],
"source": [
"\n",
"slice_canidate.plot_sum_for_theta_vector([0r,4r,0r,4r,0r,0r,0r,0r], save_to_dir=True)"
"# slice_canidate.plot_sum_for_theta_vector([0r,4r,0r,4r,0r,0r,0r,0r], save_to_dir=True)"
]
},
{
@ -462,7 +529,7 @@
"metadata": {},
"outputs": [],
"source": [
"sf.plot()\n"
"# sf.plot()\n"
]
},
{
@ -470,7 +537,9 @@
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
"source": [
"# help(cs.CableTemplate.get_q_vector)"
]
},
{
"cell_type": "code",