183 lines
6.3 KiB
Python
183 lines
6.3 KiB
Python
from sage.all import *
|
|
import itertools
|
|
load('aplK.py')
|
|
load("minimalModel_parallel.py")
|
|
|
|
"""
|
|
S = simplicial_complexes.K3Surface()
|
|
S.set_immutable()
|
|
cochainComplex = S.chain_complex(base_ring=QQ).dual()
|
|
A = AlgebraAplK(S)
|
|
smodel = load("sullivan_model_K3_deg3.sobj")
|
|
smorphism = load("model_morphism_K3_deg3.sobj")
|
|
"""
|
|
######### RUN MINIMAL MODEL ALGORITHM
|
|
"""
|
|
[sullivan_model, model_morphism, cohomology_correspondence] = minimal_model(S, max_depth=12000, max_dim=3)
|
|
print(sullivan_model, flush=True)
|
|
save(sullivan_model, "sullivan_model_K3_deg3")
|
|
save(model_morphism,"model_morphism_K3_deg3")
|
|
save(cohomology_correspondence,"cohomology_correspondence_K3_deg3")
|
|
"""
|
|
######### TEST APLK STRUCTURE
|
|
"""
|
|
@parallel(ncpus=Integer(24))
|
|
def check(gen, aplk):
|
|
print("Checking the aplk element " + str(gen), flush=True)
|
|
aplk.check()
|
|
return 0
|
|
|
|
for k in smorphism.keys():
|
|
elements = list(smorphism[k].items())
|
|
print("Start parallel check", flush=True)
|
|
results = [i[1] for i in check(elements)]
|
|
"""
|
|
########## TEST DIFFERENTIAL/PHI COMMUTING
|
|
"""
|
|
for degree in range(2,4):
|
|
for g in smodel.basis(degree):
|
|
phi_g = smorphism[degree][str(g)]
|
|
d_phi_g = phi_g.differential()
|
|
dg = g.differential()
|
|
phi_d_g = phi_polinomial(dg, smorphism, A)
|
|
equal = phi_d_g == d_phi_g
|
|
if not equal:
|
|
raise ValueError("(phi o dif)(" + str(g) + ") != (dif o phi)(" + str(g) + ")")
|
|
else:
|
|
print("(phi o dif)(" + str(g) + ") == (dif o phi)(" + str(g) + ")", flush=True)
|
|
"""
|
|
######### TEST LIFTING/INTEGRAL RANDOM COCHAINS
|
|
"""
|
|
def zip_with_constants(a, b, l):
|
|
return [(a, b, i) for i in l]
|
|
|
|
@parallel(ncpus=Integer(24))
|
|
def check_lifting(A, dim, v):
|
|
print("Lift random cochain to Apl(K)", flush=True)
|
|
a = A.lift_cochain(A.vector_to_cochain(v,dim))
|
|
print("Checking Apl(K) structure of the random element ", flush=True)
|
|
a.check()
|
|
print("Checking if the integral is equal to the original cochain", flush=True)
|
|
equal = A.cochain_to_vector(a.integral(), dim) == v
|
|
if not equal:
|
|
raise ValueError("the cochains are not equal")
|
|
return -1
|
|
else:
|
|
print("OK", flush=True)
|
|
return 0
|
|
|
|
N = 100
|
|
for dim in range(5):
|
|
random_cochains = [random_vector(QQ, len(S.n_cells(dim))) for i in range(N)]
|
|
data = zip_with_constants(A, dim, random_cochains)
|
|
print("Start parallel lifting at dimension " + str(dim), flush=True)
|
|
results = [i[1] for i in check_lifting(data)]
|
|
print("Finished battery test", flush=True)
|
|
"""
|
|
|
|
######### TEST DIFFERENTIAL/INTEGRAL COMMUTATION APLn
|
|
"""
|
|
def random_pol(apln):
|
|
n = apln.n
|
|
coef = randint(1,10)
|
|
exp = tuple([randint(0,5) for i in range(n)] + [0]*n)
|
|
gens = apln.gens()
|
|
return apln.get_term(apln, coef, exp, gens)
|
|
|
|
n = 5
|
|
s = SimplicialAlgebraplN(n)
|
|
s.inject_variables()
|
|
#cofaces = [x for x in list(powerset(range(n+1)) if len(x) == n]
|
|
|
|
dp = random_pol(s)*prod(s.gens()[s.n+2:])
|
|
print("dp: ",dp, flush=True)
|
|
p = dp.solve_primitive().reduce()
|
|
fd = sum([((-1)**f)*p.face(f).integral() for f in range(n+1)])
|
|
print("sum([((-1)**f)*p.face(f).integral() for f in range(n+1)])== dp.integral(): ", fd == dp.integral(), flush=True)
|
|
|
|
for f in range(n+1):
|
|
coface = list(range(n+2))
|
|
coface.remove(f)
|
|
q = dp.propagate(coface,n+1)
|
|
dq = q.differential().reduce()
|
|
#p = dp.solve_primitive().reduce()
|
|
#print("p.differential().reduce() == dp.reduce()", p.differential().reduce() == dp.reduce(), flush=True)
|
|
#print("q.face("+str(f)+") == p", flush=True)
|
|
#print(q.face(f).reduce() == p, flush=True)
|
|
print("(-1)**"+str(f)+")*p.face().integral() == dq.integral(): ", ((-1)**f)*dp.integral() == dq.integral(), flush=True)
|
|
#print(p.integral() == dq.integral(), flush=True)
|
|
"""
|
|
######### TEST DIFFERENTIAL/INTEGRAL COMMUTATION APL(K)
|
|
"""
|
|
def zip_with_constants(a, l):
|
|
return [(a, i) for i in l]
|
|
|
|
@parallel(ncpus=Integer(24))
|
|
def check(A,S):
|
|
"""
|
|
|
|
#S = simplicial_complexes.Sphere(6)
|
|
S = simplicial_complexes.K3Surface()
|
|
S.set_immutable()
|
|
cochainComplex = S.chain_complex(base_ring=QQ).dual()
|
|
A = AlgebraAplK(S)
|
|
for dim in range(4):
|
|
for i in range(1):
|
|
v = random_vector(QQ, len(S.n_cells(dim)))
|
|
print("Lifting random cochain dim ", dim, flush=True)
|
|
a = A.lift_cochain(A.vector_to_cochain(v,dim))
|
|
print("Check Apl(K) structure of the lifted element: ",a.check(), flush=True)
|
|
da = a.differential()
|
|
Diff = cochainComplex.differential(dim)
|
|
cda = A.cochain_to_vector(da.integral(),dim+1)
|
|
equal = Diff*v == cda
|
|
print("Diff*v == cda.integral()", equal, flush=True)
|
|
if not equal:
|
|
raise Exception("the integrals are not equal ", flush=True)
|
|
|
|
for cell in S.n_cells(dim+1):
|
|
d = da.elements[cell.tuple()]
|
|
#s = (-1)**(dim*(dim-1)//2) # [FHT, RHT, p.129]
|
|
di = sum([((-1)**(f))*a.elements[cell.face(f).tuple()].integral() for f in range(cell.dimension()+1)])
|
|
equal = di == d.integral()
|
|
if equal:
|
|
print("di == d.integral(): ", equal, flush=True)
|
|
else:
|
|
raise Exception("the integrals are not equal ", flush=True)
|
|
|
|
|
|
|
|
######### TEST DIFFERENTIAL/INTEGRAL COMMUTATION WITH RANDOM COCHAINS
|
|
"""
|
|
def zip_with_constants(a, b, c, l):
|
|
return [(a, b, c, i) for i in l]
|
|
|
|
@parallel(ncpus=Integer(24))
|
|
def check(A, Diff, degree, cochain):
|
|
#PARAMS:
|
|
# - Diff: Differential at dimension "dim"
|
|
# - f: tuple (str,Apl(K))
|
|
# -
|
|
f = A.lift_cochain(A.vector_to_cochain(cochain,degree))
|
|
#print("Checking (DoI)f == (IoD)f ", flush=True)
|
|
cf = A.cochain_to_vector(f.integral(), degree)
|
|
df = f.differential()
|
|
cdf = A.cochain_to_vector(df.integral(), degree + 1)
|
|
equal = Diff*cf == cdf
|
|
if not equal:
|
|
#raise ValueError("the cochains are not equal at degree " + str(degree))
|
|
print("the cochains are not equal at degree " + str(degree))
|
|
return -1
|
|
#else:
|
|
# print("OK", flush=True)
|
|
return 0
|
|
|
|
N = 10
|
|
for degree in range(5):
|
|
random_cochains = [random_vector(QQ, len(S.n_cells(degree))) for i in range(N)]
|
|
Diff = cochainComplex.differential(degree)
|
|
data = zip_with_constants(A, Diff, degree, random_cochains)
|
|
print("Start parallel DIFF/INTEGRAL at degree " + str(degree), flush=True)
|
|
results = [i[1] for i in check(data)]
|
|
print("Finished battery test", flush=True)
|
|
""" |