fixed max_depth error at injectivity_step and other changes

This commit is contained in:
carlos alquezar 2023-08-20 00:55:01 +02:00
parent 95c017f3ce
commit c9885a03b7
4 changed files with 52 additions and 50 deletions

17
aplK.py
View File

@ -904,7 +904,7 @@ class AlgebraAplK(UniqueRepresentation, Parent):
def __init__(self, parent, values): def __init__(self, parent, values):
Element.__init__(self, parent) Element.__init__(self, parent)
self.elements = self._reduce(values) self.elements = self._reduce(values)
# self.check() #self.check()
def _repr_(self): def _repr_(self):
""" """
@ -1123,20 +1123,16 @@ class AlgebraAplK(UniqueRepresentation, Parent):
primitive_basis[simplex.tuple()] = [] primitive_basis[simplex.tuple()] = []
# add primitive elements related to the assigned polynomial # add primitive elements related to the assigned polynomial
pol = self.elements[simplex.tuple()] pol = self.elements[simplex.tuple()]
primitive_basis[simplex.tuple( primitive_basis[simplex.tuple()] += pol._get_primitive_basis()
)] += pol._get_primitive_basis() primitive_basis[simplex.tuple()] = list(set(primitive_basis[simplex.tuple()]))
primitive_basis[simplex.tuple()] = list(
set(primitive_basis[simplex.tuple()]))
primitive_basis[simplex.tuple()].sort(reverse=False) primitive_basis[simplex.tuple()].sort(reverse=False)
# propagate the primitive basis through its faces # propagate the primitive basis through its faces
for f in range(n+1): for f in range(n+1):
simplex_face = S.face(simplex, f).tuple() simplex_face = S.face(simplex, f).tuple()
if simplex_face not in primitive_basis.keys(): if simplex_face not in primitive_basis.keys():
primitive_basis[simplex_face] = [] primitive_basis[simplex_face] = []
primitive_basis[simplex_face] += self._face_basis( primitive_basis[simplex_face] += self._face_basis(primitive_basis[simplex.tuple()], f)
primitive_basis[simplex.tuple()], f) primitive_basis[simplex_face] = list(set(primitive_basis[simplex_face]))
primitive_basis[simplex_face] = list(
set(primitive_basis[simplex_face]))
primitive_basis[simplex_face].sort(reverse=False) primitive_basis[simplex_face].sort(reverse=False)
return primitive_basis return primitive_basis
@ -1162,8 +1158,7 @@ class AlgebraAplK(UniqueRepresentation, Parent):
for n in reversed(range(min_dim, dim+1)): for n in reversed(range(min_dim, dim+1)):
for simplex in S._n_cells_sorted(n): for simplex in S._n_cells_sorted(n):
prim_diff_basis = primitive_basis[simplex.tuple()] prim_diff_basis = primitive_basis[simplex.tuple()]
differential_basis[simplex.tuple()] = self._diff_basis( differential_basis[simplex.tuple()] = self._diff_basis(prim_diff_basis)
prim_diff_basis)
return differential_basis return differential_basis
def _get_differential_matrix(self, p_basis, d_basis): def _get_differential_matrix(self, p_basis, d_basis):

View File

@ -221,7 +221,7 @@ def minimal_model(S, max_depth=5, max_dim=5):
# Now we have an isomorphism in the first non-null cohomology group # Now we have an isomorphism in the first non-null cohomology group
# we check if phi is a monomorphism # we check if phi is a monomorphism
[M, phi, names, degrees, differentials, limit] = injectivity_step(M, phi, first_dim+1, names, [M, phi, names, degrees, differentials, limit] = injectivity_step(M, phi, first_dim+1, names,
degrees, differentials, A, index=0, depth=0, max_depth=5) degrees, differentials, A, index=0, depth=0, max_depth=max_depth)
if limit: if limit:
print( print(
"The algorithm has reach the injectivity depth-limit at dimension ", first_dim) "The algorithm has reach the injectivity depth-limit at dimension ", first_dim)
@ -234,10 +234,10 @@ def minimal_model(S, max_depth=5, max_dim=5):
[M, phi, names, degrees, cohomology_correspondence] = surjective_step(A, M, phi, i, names, degrees, [M, phi, names, degrees, cohomology_correspondence] = surjective_step(A, M, phi, i, names, degrees,
differentials, cohomology_correspondence) differentials, cohomology_correspondence)
[M, phi, names, degrees, differentials, limit] = injectivity_step(M, phi, i+1, names, [M, phi, names, degrees, differentials, limit] = injectivity_step(M, phi, i+1, names,
degrees, differentials, A, index=0, depth=0, max_depth=5) degrees, differentials, A, index=0, depth=0, max_depth=max_depth)
if limit: if limit:
print( print(
"The algorithm has reach the injectivity depth-limit at dimension", dim) "The algorithm has reach the injectivity depth-limit at dimension", i+1)
break break
return [M, phi, cohomology_correspondence] return [M, phi, cohomology_correspondence]

View File

@ -55,7 +55,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -135,7 +135,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -159,7 +159,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -189,7 +189,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -235,7 +235,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -253,7 +253,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -281,7 +281,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 7, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -309,7 +309,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 8, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -353,7 +353,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -392,7 +392,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 10, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -410,7 +410,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 11, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -445,7 +445,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 12, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -508,7 +508,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 13, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -526,7 +526,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 14, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -562,7 +562,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 15, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -586,7 +586,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 16, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -604,7 +604,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 17, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -625,7 +625,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 18, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -669,7 +669,7 @@
"- $p^i \\in \\mathbb{Q}[t_1, \\dots, t_n]$\n", "- $p^i \\in \\mathbb{Q}[t_1, \\dots, t_n]$\n",
"- $(k_{1}^{i}, \\dots , k_{n}^{i}) \\neq (k_{1}^{j}, \\dots, k_{n}^{j})$ if $i \\neq j$\n", "- $(k_{1}^{i}, \\dots , k_{n}^{i}) \\neq (k_{1}^{j}, \\dots, k_{n}^{j})$ if $i \\neq j$\n",
"\n", "\n",
"It is easy to see that $p$ will have as much as $2^n-1$ non-null terms in the variables $y_j$.\n", "It is easy to see that $p$ will have at most $2^n-1$ non-null terms in the variables $y_j$.\n",
"\n", "\n",
"As we have set the lexicographic monomial ordering, for every two consecutive non-null terms in a polynomial $p$\n", "As we have set the lexicographic monomial ordering, for every two consecutive non-null terms in a polynomial $p$\n",
"\n", "\n",
@ -796,7 +796,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 19, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -945,7 +945,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 20, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -963,7 +963,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 21, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -984,7 +984,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 22, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -1065,7 +1065,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 23, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -1214,7 +1214,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 24, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -1232,7 +1232,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 25, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -1253,7 +1253,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 26, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -1332,7 +1332,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 27, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -1388,7 +1388,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 28, "execution_count": 43,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -1406,7 +1406,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 29, "execution_count": 51,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -1427,7 +1427,14 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 30, "execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -1446,7 +1453,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 31, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -1485,7 +1492,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 32, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -5487,7 +5494,7 @@
], ],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "SageMath 9.5.beta2", "display_name": "SageMath 9.2",
"language": "sage", "language": "sage",
"name": "sagemath" "name": "sagemath"
}, },
@ -5501,7 +5508,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.8.10" "version": "3.8.5"
}, },
"toc-autonumbering": false, "toc-autonumbering": false,
"toc-showmarkdowntxt": false "toc-showmarkdowntxt": false

View File

@ -16,5 +16,5 @@ print(S.facets())
####################################################### #######################################################
# S = simplicial_complexes.ProjectivePlane().wedge(simplicial_complexes.Sphere(2), is_mutable=False) # S = simplicial_complexes.ProjectivePlane().wedge(simplicial_complexes.Sphere(2), is_mutable=False)
####################################################### #######################################################
[sullivan_model, model_morphism, cohomology_correspondence] = minimal_model(S, max_depth=5, max_dim=8) [sullivan_model, model_morphism, cohomology_correspondence] = minimal_model(S, max_depth=10, max_dim=12)
print(sullivan_model) print(sullivan_model)