{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from sage.structure.parent import Parent\n", "from sage.structure.element import Element\n", "#from sage.structure.unique_representation import UniqueRepresentation\n", "#from sage.categories.rings import Rings\n", "from sage.structure.richcmp import rich_to_bool, op_EQ, op_NE, op_LT, op_LE, op_GT, op_GE\n", "#from sage.categories.morphism import Morphism\n", "#from sage.rings.rational_field import QQ\n", "#from sage.algebras.commutative_dga import GradedCommutativeAlgebra\n", "#from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing\n", "#from sage.functions.other import factorial\n", "import itertools\n", "import copy\n", "import random" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Simplicial Complex" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "S1 = SimplicialComplex([[0,1,2],[0,1,3],[0,2,3],[1,2,3],[3,4],[3,5],[4,5]],is_mutable=False) " ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "S2 = SimplicialComplex([[0,1,2],[0,1,3],[0,2,3],[1,2,3],[3,4,5],[3,4,6],[3,5,6],[4,5,6]],is_mutable=False) " ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "def cohomology_gens(S,n):\n", " gens = {}\n", " basis = S.cohomology_ring().basis()\n", " for k in basis.keys():\n", " if k[0] == n:\n", " gens[k] = basis[k]\n", " return gens" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{(2, 0): h^{2,0}, (2, 1): h^{2,1}}" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gens = cohomology_gens(S2,2)\n", "gens" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "\\chi_(4, 5, 6)" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "v = gens[(2,1)]\n", "c = v.to_cycle()\n", "c" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "def lift_cohomology_generator(S, g):\n", " cycle = g.to_cycle()\n", " cochain = {}\n", " for n in range(S.dimension()+1):\n", " for simplex in S._n_cells_sorted(n):\n", " cochain[simplex.tuple()] = 0\n", " for i in cycle:\n", " #print(type(i[0].tuple()))\n", " cochain[i[0].tuple()] = i[1]\n", " return cochain" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{(0,): 0,\n", " (1,): 0,\n", " (2,): 0,\n", " (3,): 0,\n", " (4,): 0,\n", " (5,): 0,\n", " (6,): 0,\n", " (0, 1): 0,\n", " (0, 2): 0,\n", " (0, 3): 0,\n", " (1, 2): 0,\n", " (1, 3): 0,\n", " (2, 3): 0,\n", " (3, 4): 0,\n", " (3, 5): 0,\n", " (3, 6): 0,\n", " (4, 5): 0,\n", " (4, 6): 0,\n", " (5, 6): 0,\n", " (0, 1, 2): 0,\n", " (0, 1, 3): 0,\n", " (0, 2, 3): 0,\n", " (1, 2, 3): 0,\n", " (3, 4, 5): 0,\n", " (3, 4, 6): 0,\n", " (3, 5, 6): 0,\n", " (4, 5, 6): 1}" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "lift_cohomology_generator(S2,gens[(2,1)])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Apln" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "class Apln(UniqueRepresentation):\n", "\n", " def __init__(self,n):\n", " self.n = n\n", " self.algebras = []\n", " self.relations = []\n", " for i in range(n+1):\n", " [cdga, relations] = self._cdga(i)\n", " self.algebras.append(cdga)\n", " self.relations.append(relations)\n", " \n", " def _cdga(self,n):\n", " ts = ['t'+str(t) for t in range(n+1)]\n", " ys = ['y'+str(t) for t in range(n+1)]\n", " degrees = tuple((n+1)*[(0,2)])+tuple((n+1)*[(1,2)])\n", " gca = GradedCommutativeAlgebra(QQ, names=ts+ys, degrees=degrees)\n", " t_relation = -1\n", " y_relation = 0\n", " #t_relation = sum(self.gca.gens()[:n])-1\n", " #y_relation = sum(self.gca.gens()[n:])\n", " for i in range(n+1):\n", " t_relation += gca.gens()[i]\n", " y_relation += gca.gens()[n+1+i]\n", " #gca_with_relations = self.gca.quotient(self.gca.ideal(t_relation,y_relation),check=False)\n", " dfs = {gca.gens_dict()[ts[i]]:gca.gens_dict()[ys[i]] for i in range(n+1)}\n", " return [gca.cdg_algebra(dfs),[t_relation,y_relation]]\n", " \n", " def __repr__(self):\n", " return \"Simplicial algebra of dimension %s\" % self.n\n", " \n", " def inject_variables(self, n):\n", " self.algebras[n].inject_variables()\n", " \n", " def generators(self, n):\n", " return self.algebras[n].gens()\n", " \n", " def get_multidegree(self, p):\n", " a3 = p.parent()\n", " n = len(a3.gens())/2\n", " multidegrees = {}\n", " for k in p.dict().keys():\n", " multideg = vector(QQ,n*[0])\n", " for i in range(n):\n", " multideg[i] = k[i]+k[i+n]\n", " multidegrees[k] = multideg\n", " return multidegrees\n", " \n", " def face(self,i,n):\n", "\n", " if(self.n==0):\n", " return 0\n", " domain = self.algebras[n]\n", " codomain = self.algebras[n-1]\n", " tImages = []\n", " yImages = []\n", " n = len(domain.gens())//2\n", " for k in range(n):\n", " if(ki):\n", " tImages.append(codomain.gens()[k-1])\n", " yImages.append(codomain.gens()[n+k-2])\n", " images = tImages+yImages\n", " return domain.hom(codomain=codomain,im_gens=images)\n", "\n", " def reduce_polynomial(self,p):\n", " ## Input:\n", " # - p: polynomial in variables t_0,..t_n,y_0,...,y_n\n", " ## Output:\n", " # - The polynomial after applying the corresponding relations to reduce the variables t_0, y_0\n", " apl = p.parent()\n", " dim = len(apl.gens())//2-1\n", " return p.reduce(self.relations[dim])\n", " \n", " def _convert_integrable_polynomial(self,p):\n", " ## Input:\n", " # - p: polynomial in variables t_1,..t_n,y_1,...,y_n\n", " ## Output:\n", " # - A polynomial in the ring Q.\n", " # (After reducing the variables t_{0},y_{0} by the corresponding relations, \n", " # the algorithm removes the variables y_{1},..,y_{n}). \n", " \n", " apl = p.parent()\n", " n = len(apl.gens())//2\n", " pol = self.reduce_polynomial(p)\n", " relations = []\n", " for i in range(n): \n", " relations.append(apl.gens()[n+i]-1)\n", " return pol.reduce(relations)\n", " \n", " def integral(self,p):\n", " ## Input:\n", " # - p: polynomial in variables t_0,..t_n,y_0,...,y_n\n", " ## Output:\n", " # - the integral of the polynomial after reducing the variables t_0, y_0 by the corresponding relations \n", " #\n", " apl = p.parent()\n", " n = len(apl.gens())//2-1\n", " pol = self._convert_integrable_polynomial(p)\n", " result = 0\n", " for k in pol.dict().keys(): # k is a monomial\n", " numerator = 1\n", " denominator = n\n", " for e in k: # e is an exponents\n", " numerator *= factorial(e)\n", " denominator += e\n", " coef = pol.dict()[k]\n", " result += coef*numerator/factorial(denominator)\n", " return ((-1)**(n*(n-1)/2))*result\n", " \n", " def lift(self, value, n): \n", " apl = self.algebras[n]\n", " gens = apl.gens()\n", " return value*((-1)**(n*(n-1)/2))*factorial(n)*prod(gens[n+2:])\n", " \n", " def homogeneous_part(self,pol,degree):\n", " parts = [pol.homogeneous_parts()[k] for k in pol.homogeneous_parts() if list(k)[0]==degree]\n", " return sum(parts)\n", " \n", " def propagate(self, face_list, n):\n", " \"\"\"\n", " - face_list: indexes of the elements that form the face of the simplex we want to propagate\n", " - EXAMPLE: p = a.propagate([0,3,4],5)\n", " t4*y0*y3 - t3*y0*y4 + t0*y3*y4\n", " \"\"\"\n", " simplex_dim = len(face_list)-1\n", " indexes = list(range(simplex_dim+1))\n", " apl = self.algebras[n]\n", " y_gens = [apl.gens()[n+1+i] for i in face_list]\n", " t_gens = [apl.gens()[i] for i in face_list]\n", " result = apl(0)\n", " for i in reversed(indexes):\n", " t = t_gens[i]\n", " y_prod = copy.deepcopy(y_gens)\n", " del y_prod[i]\n", " y_prod = prod(y_prod)\n", " result += ((-1)**i)*t*y_prod#((-1)**(simplex_dim+i))*t*y_prod\n", " return result" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Defining t0, t1, t2, t3, y0, y1, y2, y3\n" ] }, { "data": { "text/plain": [ "0" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a = Apln(5)\n", "a.inject_variables(3)\n", "p = t2*y0*y1-t1*y0*y2+t0*y1*y2\n", "q = a.face(1,3)(p)\n", "ared = a.reduce_polynomial(q)\n", "ared" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Empiezan celdas de pruebas" ] }, { "cell_type": "code", "execution_count": 50, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{(0, 0, 2, 0, 1, 1, 0, 0): 5,\n", " (0, 1, 0, 0, 1, 0, 1, 0): -1,\n", " (1, 0, 0, 0, 0, 1, 1, 0): 1}" ] }, "execution_count": 50, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p = 5*t2^2*y0*y1-t1*y0*y2+t0*y1*y2\n", "p.dict()" ] }, { "cell_type": "code", "execution_count": 51, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/latex": [ "\\begin{math}\n", "\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{rrrrr}\n", "1 & 0 & 0 & -2 & -\\frac{1}{2} \\\\\n", "0 & 1 & 0 & -2 & -\\frac{1}{2} \\\\\n", "0 & 0 & 1 & -1 & 0 \\\\\n", "0 & 0 & 0 & 0 & 0 \\\\\n", "0 & 0 & 0 & 0 & 0 \\\\\n", "0 & 0 & 0 & 0 & 0\n", "\\end{array}\\right)\n", "\\end{math}" ], "text/plain": [ "[ 1 0 0 -2 -1/2]\n", "[ 0 1 0 -2 -1/2]\n", "[ 0 0 1 -1 0]\n", "[ 0 0 0 0 0]\n", "[ 0 0 0 0 0]\n", "[ 0 0 0 0 0]" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "M = Matrix(QQ,6,5,[[-2,2,0,0,0],[-1,0,2,0,1/2],[-1,0,0,2,1/2],[0,-1,2,0,1/2],[0,-1,0,2,1/2],[0,0,-1,1,0]])\n", "show(M.echelon_form())" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Defining t0, t1, t2, t3, y0, y1, y2, y3\n" ] }, { "data": { "text/plain": [ "True" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "apl = Apln(5)\n", "apl.inject_variables(3)\n", "d=1\n", "c=d\n", "b=2*d-1/2\n", "a=2*d-1/2\n", "w1=a*(t0*t1^2*t2*t3*y0)+b*(t0^2*t1*t2*t3*y1)+c*(t0^2*t1^2*t3*y2)+d*(t0^2*t1^2*t2*y3)\n", "d=5\n", "c=d\n", "b=2*d-1/2\n", "a=2*d-1/2\n", "w2=a*(t0*t1^2*t2*t3*y0)+b*(t0^2*t1*t2*t3*y1)+c*(t0^2*t1^2*t3*y2)+d*(t0^2*t1^2*t2*y3)\n", "w1.differential()==w2.differential()" ] }, { "cell_type": "code", "execution_count": 57, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[t2^2*y0*y1, t1*y0*y2, t0*y1*y2]" ] }, "execution_count": 57, "metadata": {}, "output_type": "execute_result" } ], "source": [ "m0 = p.monomials()\n", "m0" ] }, { "cell_type": "code", "execution_count": 67, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "5*t2^2*y0*y1 + 5*y0*y1" ] }, "execution_count": 67, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p = (5*t2^2 + 5)*y0*y1\n", "p" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Terminan celdas de pruebas" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "t4*y0*y1*y2*y3 - t3*y0*y1*y2*y4 + t2*y0*y1*y3*y4 - t1*y0*y2*y3*y4 + t0*y1*y2*y3*y4\n", "y1*y2*y3*y4\n" ] } ], "source": [ "p = a.propagate([0, 2, 3, 4, 5],5)\n", "q = a.face(1,5)(p)\n", "ared = a.reduce_polynomial(q)\n", "print(q)\n", "print(ared)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(y0, y1, y2)" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a.algebras[3].gens()[4:-1]" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Defining t0, t1, t2, t3, y0, y1, y2, y3\n" ] }, { "data": { "text/plain": [ "(y0, y1, y2)" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "n=3\n", "a = Apln(n)\n", "a.inject_variables(n)\n", "cdga = a.algebras[n]\n", "gens = cdga.gens()[n+1:-1]\n", "gens\n", "\n" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "n = 5\n", "n = 4\n", "n = 3\n", "n = 2\n", "n = 1\n" ] } ], "source": [ "N = 6\n", "for n in reversed(range(1,N)):\n", " print(\"n = \" + str(n))\n", " for face in range(n+1):\n", " idx = list(range(N))\n", " del idx[face]\n", " r = [perm for perm in itertools.permutations(idx,r=int(n)) if sorted(perm) == list(perm)]\n", " #print(r)\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Apl(K)" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [], "source": [ "class AplK(UniqueRepresentation, Parent):\n", " \n", " def __init__(self,K, category=None):\n", " self.K = K\n", " self.n = K.dimension()\n", " self.apln = Apln(K.dimension())\n", " Parent.__init__(self,category=category )\n", " f = MorphismFromQQToAplK(self)\n", " self.register_coercion(f)\n", " \n", " def _repr_(self):\n", " return \"Algebra AplK over %s\" % self.K\n", " \n", " def _element_constructor_(self,values):\n", " return self.element_class(self,values)\n", " \n", " def dimension(self):\n", " return self.K.dimension()\n", " \n", " def simplicialComplex(self):\n", " return self.K\n", " \n", " def _n_cells_sorted(self,n):\n", " return self.K._n_cells_sorted(n)\n", " \n", " def lift(self, cochain):\n", " \n", " # first we find polynomials compatible with the integration value\n", " values = {}\n", " max_n = 0\n", " for k in cochain.keys():\n", " n = len(k)-1\n", " if n > max_n:\n", " max_n = n\n", " apl = self.apln.algebras[n]\n", " if n>0:\n", " values[k] = self.apln.lift(cochain[k],n)\n", " else:\n", " values[k]= apl(cochain[k])\n", " \n", " # second, we propagate the simplicial information\n", " simplicial_structure = {}\n", " for n in reversed(range(max_n+1)):\n", " keys = [k for k in values.keys() if len(k) == n+1] # keys of the n-simplices\n", " for k in keys:\n", " simplicial_structure[k] = values[k] + self._propagate(cochain, k) \n", " #print(simplicial_structure)\n", " return AplKElement(self,simplicial_structure)\n", "\n", " def _faces_of_length(self, simplex, length):\n", " return [tuple(e) for e in powerset(simplex) if len(e)==length]\n", " \n", " def _propagate(self, cochain, simplex):\n", " \n", " dim = len(simplex)-1\n", " apl = self.apln.algebras[dim]\n", " propagation = apl(0)\n", " for n in reversed(range(dim+1)):\n", " faces = self._faces_of_length(simplex, n)\n", " for f in faces:\n", " if f in cochain.keys():\n", " dim_face = len(f)-1\n", " value = cochain[f]\n", " face_indexes = [simplex.index(i) for i in f]\n", " propagation += value*((-1)**(dim_face*(dim_face-1)/2))*factorial(dim_face)*self.apln.propagate(face_indexes, dim)\n", " return propagation\n", " " ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "ename": "NameError", "evalue": "name 'MorphismFromQQToAplK' is not defined", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m~/Documents/0-PhD/Code/sage-9.2/local/lib/python3.8/site-packages/sage/misc/cachefunc.pyx\u001b[0m in \u001b[0;36msage.misc.cachefunc.CachedFunction.__call__ (build/cythonized/sage/misc/cachefunc.c:5975)\u001b[0;34m()\u001b[0m\n\u001b[1;32m 995\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 996\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcache\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 997\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;31m# k is not hashable\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m~/Documents/0-PhD/Code/sage-9.2/local/lib/python3.8/site-packages/sage/misc/weak_dict.pyx\u001b[0m in \u001b[0;36msage.misc.weak_dict.WeakValueDictionary.__getitem__ (build/cythonized/sage/misc/weak_dict.c:3737)\u001b[0;34m()\u001b[0m\n\u001b[1;32m 703\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mwr\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0mNULL\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 704\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 705\u001b[0m \u001b[0mout\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mPyWeakref_GetObject\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mwr\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mKeyError\u001b[0m: ((, Simplicial complex with vertex set (0, 1, 2, 3) and facets {(1, 3), (2, 3), (0, 1, 2)}), ())", "\nDuring handling of the above exception, another exception occurred:\n", "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0mcochain\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mS\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mSimplicialComplex\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mis_mutable\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 4\u001b[0;31m \u001b[0mA\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mAplK\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mS\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 5\u001b[0m \u001b[0mp\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mA\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_propagate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcochain\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mp\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m~/Documents/0-PhD/Code/sage-9.2/local/lib/python3.8/site-packages/sage/misc/classcall_metaclass.pyx\u001b[0m in \u001b[0;36msage.misc.classcall_metaclass.ClasscallMetaclass.__call__ (build/cythonized/sage/misc/classcall_metaclass.c:1762)\u001b[0;34m()\u001b[0m\n\u001b[1;32m 320\u001b[0m \"\"\"\n\u001b[1;32m 321\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mcls\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mclasscall\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 322\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mcls\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mclasscall\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcls\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 323\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 324\u001b[0m \u001b[0;31m# Fast version of type.__call__(cls, *args, **kwds)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m~/Documents/0-PhD/Code/sage-9.2/local/lib/python3.8/site-packages/sage/misc/cachefunc.pyx\u001b[0m in \u001b[0;36msage.misc.cachefunc.CachedFunction.__call__ (build/cythonized/sage/misc/cachefunc.c:6101)\u001b[0;34m()\u001b[0m\n\u001b[1;32m 999\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcache\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1000\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1001\u001b[0;31m \u001b[0mw\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1002\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcache\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mw\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1003\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mw\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m~/Documents/0-PhD/Code/sage-9.2/local/lib/python3.8/site-packages/sage/structure/unique_representation.py\u001b[0m in \u001b[0;36m__classcall__\u001b[0;34m(cls, *args, **options)\u001b[0m\n\u001b[1;32m 1006\u001b[0m \u001b[0;32mTrue\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1007\u001b[0m \"\"\"\n\u001b[0;32m-> 1008\u001b[0;31m \u001b[0minstance\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtypecall\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcls\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0moptions\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1009\u001b[0m \u001b[0;32massert\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m \u001b[0minstance\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcls\u001b[0m \u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1010\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0minstance\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__class__\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__reduce__\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0mCachedRepresentation\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__reduce__\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m~/Documents/0-PhD/Code/sage-9.2/local/lib/python3.8/site-packages/sage/misc/classcall_metaclass.pyx\u001b[0m in \u001b[0;36msage.misc.classcall_metaclass.typecall (build/cythonized/sage/misc/classcall_metaclass.c:2224)\u001b[0;34m()\u001b[0m\n\u001b[1;32m 484\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mArgument\u001b[0m \u001b[0;34m'cls'\u001b[0m \u001b[0mhas\u001b[0m \u001b[0mincorrect\u001b[0m \u001b[0mtype\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mexpected\u001b[0m \u001b[0mtype\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mgot\u001b[0m \u001b[0mclassobj\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 485\u001b[0m \"\"\"\n\u001b[0;32m--> 486\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0;34m<\u001b[0m\u001b[0mPyTypeObject\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0;34m>\u001b[0m\u001b[0mtype\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtp_call\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcls\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkwds\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 487\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 488\u001b[0m \u001b[0;31m# Class for timing::\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, K, category)\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mapln\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mApln\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mK\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdimension\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[0mParent\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__init__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mcategory\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mcategory\u001b[0m \u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 8\u001b[0;31m \u001b[0mf\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mMorphismFromQQToAplK\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 9\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mregister_coercion\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mf\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 10\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mNameError\u001b[0m: name 'MorphismFromQQToAplK' is not defined" ] } ], "source": [ "# AplK._propagate TEST\n", "cochain = {(0,): 0, (1,): 0, (2,):0, (3,): 0, (0,1): 0, (0,2): 0, (1,2): 1, (1,3): 0, (2,3): 0, (0,1,2):0}\n", "S = SimplicialComplex([[0,1,2],[1,3],[2,3]],is_mutable=False) \n", "A = AplK(S)\n", "p = A._propagate(cochain,(0,1,2))\n", "print(p)\n", "a = Apln(5)\n", "q = a.face(0,2)(p)\n", "print(q)\n", "ared = a.reduce_polynomial(q)\n", "print(ared)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "S = SimplicialComplex([[0,1,2],[1,3],[2,3]],is_mutable=False) \n", "A = AplK(S)\n", "cochain = {(0,): 2, (1,): 3, (2,):0, (3,): 0, (0,1): 1, (0,2): 5, (1,2): 1, (1,3): 0, (2,3): 0, (0,1,2):10}\n", "p = A.lift(cochain)\n", "p" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "A.lift(cochain).integral()==cochain" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "A.lift(p.integral())==p" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Apl(K) Element" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [], "source": [ "class AplKElement(Element):\n", "\n", " def __init__(self, parent, values):\n", " Element.__init__(self,parent)\n", " self.apln = Apln(parent.dimension())\n", " self.elements = self.reduce(values) \n", " self.check()\n", " \n", " def reduce(self, values):\n", " reduced_values = {}\n", " for k in values.keys():\n", " n = len(k)-1\n", " apl = self.apln.algebras[n]\n", " reduced_values[k] = self.apln.reduce_polynomial(apl(values[k]))\n", " return reduced_values\n", " \n", " def _repr_(self):\n", " return str(self.elements)\n", " \n", " def dimension(self):\n", " return self.parent().dimension()\n", " \n", " def nullElement(self):\n", " C = self.__class__\n", " values = {}\n", " for k in self.elements.keys():\n", " values[k]=0\n", " return C(self.parent(),values) \n", " \n", " def _add_(self,other):\n", " C = self.__class__\n", " if(self.elements.keys()!=other.elements.keys()):\n", " raise ValueError(\"error: keys do not match\")\n", " newValues = {}\n", " for k in self.elements.keys():\n", " newValues[k] = self.elements[k]+other.elements[k]\n", " return C(self.parent(),newValues)\n", " \n", " def _sub_(self,other):\n", "\n", " C = self.__class__\n", " if(self.elements.keys()!=other.elements.keys()):\n", " raise ValueError(\"error: keys do not match\")\n", " newValues = {}\n", " for k in self.elements.keys():\n", " newValues[k] = self.elements[k]-other.elements[k]\n", " return C(self.parent(),newValues)\n", " \n", " def _mul_(self,other):\n", "\n", " C = self.__class__\n", " if(self.elements.keys()!=other.elements.keys()):\n", " raise ValueError(\"error: keys do not match\")\n", " newValues = {}\n", " for k in self.elements.keys():\n", " newValues[k] = self.elements[k]*other.elements[k]\n", " return C(self.parent(),newValues)\n", " \n", " def _richcmp_(self, other, op):\n", "\n", " if(op==op_EQ):\n", " if(self.elements.keys()!=other.elements.keys()):\n", " return False\n", " for k in self.elements.keys():\n", " if(self.elements[k]!=other.elements[k]):\n", " return False\n", " return True\n", " elif(op==op_NE):\n", " return not self._richcmp_(other,op_EQ)\n", " else:\n", " raise NotImplementedError(\"operation not implemented for this element class\")\n", " \n", " def differential(self):\n", " C = self.__class__\n", " newValues = {}\n", " for k in self.elements.keys():\n", " newValues[k] = self.elements[k].differential()\n", " return C(self.parent(),newValues)\n", " \n", " def check(self):\n", "\n", " S = self.parent().simplicialComplex()\n", " dim = S.dimension()\n", " for n in range(1,dim+1):\n", " #print(\"Checking dimension \" + str(n))\n", " for simplex in S._n_cells_sorted(n):\n", " for f in range(n+1):\n", " sFace = tuple(S.face(simplex,f))\n", " aFace = self.apln.face(f,n)(self.elements[simplex.tuple()])\n", " aFace = self.apln.reduce_polynomial(aFace)\n", " #print(\"face: \" + str(f),\"simplex: \" + str(simplex),\"sFace: \" + str(self.elements[sFace]), \"aFace: \" + str(aFace))\n", " if(self.elements[sFace] != aFace):\n", " raise ValueError(\"the assignation is not valid\")\n", " \n", " def homogeneous_part(self,degree):\n", " C = self.__class__\n", " part = {}\n", " for k in self.elements.keys():\n", " part[k] = self.apln.homogeneous_part(self.elements[k],degree)\n", " return C(self.parent(),part)\n", " \n", " def homogeneous_parts(self):\n", " parts = {}\n", " for n in range(self.dimension()+1):\n", " parts[n] = self.homogeneous_part(n)\n", " return parts\n", " \n", " def is_homogeneous(self):\n", " isHomogeneous = True\n", " for k in self.elements.keys():\n", " isHomogeneous = isHomogeneous and self.elements[k].is_homogeneous()\n", " return isHomogeneous\n", " \n", " def is_closed(self):\n", " diff = self.differential()\n", " if(diff == self.nullElement()):\n", " return True\n", " else:\n", " return False\n", " \n", " def _integrable_component(self):\n", " C = self.__class__\n", " component = {}\n", " for k in self.elements.keys():\n", " degree = len(k)-1\n", " component[k] = self.apln.homogeneous_part(self.elements[k],degree)\n", " #component[k] = self.homogeneous_component(dim).elements[k]\n", " return component\n", " \n", " def integral(self):\n", " component = self._integrable_component()\n", " cochain = {}\n", " #integration of each polynomial\n", " for k in component.keys():\n", " n = len(k)-1\n", " apl = self.apln.algebras[n]\n", " cochain[k] = self.apln.integral(apl(component[k]))\n", " return cochain\n", " \n", "#####################################################################\n", "\n", "class MorphismFromQQToAplK(Morphism):\n", "\n", " def __init__(self, codomain):\n", " self.simplicialComplex= codomain.K\n", " Morphism.__init__(self, QQ, codomain)\n", "\n", " def _call_(self, x):\n", " S = self.simplicialComplex\n", " params1 = {}\n", " for d in range(S.dimension()+1):\n", " for c in S._n_cells_sorted(d):\n", " params1[tuple(c)]=x\n", " A = AplK(S)\n", " return AplKElement(A, params1)" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [], "source": [ "S = SimplicialComplex([[0, 1, 2]], is_mutable=False) \n", "apl = Apln(S.dimension())\n", "A = AplK(S)\n", "cochain = {(0,): 0, (1,): 0, (2,):0, (0,1): 0,(0,2): 0, (1,2): 0, (0,1,2): 1}\n", "#A.lift(apl, cochain)\n" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{(0, 1, 2): -2*y1*y2, (0, 1): 0, (0, 2): 0, (1, 2): 0, (0,): 0, (1,): 0, (2,): 0}" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "q = A.lift(cochain)\n", "q" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "2*q" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# All together" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "S1 = SimplicialComplex([[0,1,2],[0,1,3],[0,2,3],[1,2,3],[3,4],[3,5],[4,5]],is_mutable=False) \n", "S2 = SimplicialComplex([[0,1,2],[0,1,3],[0,2,3],[1,2,3],[3,4,5],[3,4,6],[3,5,6],[4,5,6]],is_mutable=False) \n", "S3 = SimplicialComplex([[0,1,2],[1,3],[2,3]],is_mutable=False) \n", "S4 = SimplicialComplex([[0,1,3],[1,2,4],[3,4,5]],is_mutable=False) \n", "S5 = simplicial_complexes.Sphere(5)\n", "S = S5\n", "apl = Apln(S.dimension())\n", "A = AplK(S)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "n = 5\n", "gens = cohomology_gens(S,n)\n", "cochain = lift_cohomology_generator(S,gens[(n,0)])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "gens" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "p = A.lift(cochain)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "p.integral()==cochain" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Test lift == integral" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [], "source": [ "def sublist(lst1, lst2):\n", " return set(lst1) <= set(lst2)\n", "\n", "def sublist_of_lists(list1,list_of_lists):\n", " is_sublist = False\n", " for list2 in list_of_lists:\n", " if sublist(list1,list2):\n", " is_sublist = True\n", " break\n", " return is_sublist\n", "\n", "def random_simplicial_complex(num_vertices,max_num_facets):\n", " vertices = list(range(num_vertices))\n", " simplices = []\n", " partitions = []\n", " for length in range(num_vertices):\n", " partitions += [tuple(e) for e in powerset(vertices) if len(e)==length and e]\n", " for i in range(max_num_facets+1):\n", " r = randint(0,len(partitions)-1)\n", " candidate = partitions[r]\n", " if not sublist_of_lists(candidate,simplices):\n", " simplices.append(candidate)\n", " return SimplicialComplex(simplices,is_mutable=False)\n", "\n", "def random_cochain(S):\n", " dim = S.dimension()\n", " cochain = {}\n", " for n in range(dim+1):\n", " for s in S._n_cells_sorted(n):\n", " cochain[s.tuple()] = randint(-100,100)\n", " return cochain" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{(0, 1, 4), (0, 1, 3), (0, 1, 2)}" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "S = random_simplicial_complex(5,4)\n", "S.facets()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [], "source": [ "def test(max_vertices, verbose=False):\n", " success = True\n", " data = []\n", " for i in range(10):\n", " v = randint(2,max_vertices)\n", " f = randint(1,v)\n", " S = random_simplicial_complex(num_vertices=v,max_num_facets=f)\n", " A = AplK(S)\n", " cochain = random_cochain(S)\n", " #print(cochain)\n", " data = [S, cochain]\n", " if verbose:\n", " print(\"iteration: \" + str(i), \"num_vertices: \" + str(v), \"max_num_facets: \" + str(f), \"facets: \" + str(S.facets()))\n", " p = A.lift(cochain)\n", " if verbose:\n", " print(p)\n", " if not p.integral()==cochain:\n", " success = False\n", " print(\"Error\")\n", " break\n", " if success:\n", " print(\"success: \" + str(success))" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "iteration: 0 num_vertices: 5 max_num_facets: 1 facets: {(1, 3, 4), (0, 4)}\n", "{(1, 3, 4): -168*y1*y2 - 65*t2*y1 + 65*t1*y2 - 71*y1 - 94*y2 - 150*t1 + t2 + 87, (0, 4): -80*y1 + 60*t1 + 28, (1, 3): -71*y1 - 150*t1 + 87, (1, 4): -94*y1 + t1 + 87, (3, 4): 42*y1 + 151*t1 - 63, (0,): 28, (1,): 87, (3,): -63, (4,): 88}\n", "iteration: 1 num_vertices: 4 max_num_facets: 1 facets: {(0, 2, 3), (0, 1, 2)}\n", "{(0, 1, 2): -52*y1*y2 - 65*t2*y1 + 65*t1*y2 + 54*y1 + 81*y2 - 64*t1 - 58*t2 + 70, (0, 2, 3): 82*y1*y2 + 45*t2*y1 - 45*t1*y2 + 81*y1 + 71*y2 - 58*t1 - 95*t2 + 70, (0, 1): 54*y1 - 64*t1 + 70, (0, 2): 81*y1 - 58*t1 + 70, (0, 3): 71*y1 - 95*t1 + 70, (1, 2): 92*y1 + 6*t1 + 6, (2, 3): -55*y1 - 37*t1 + 12, (0,): 70, (1,): 6, (2,): 12, (3,): -25}\n", "iteration: 2 num_vertices: 4 max_num_facets: 3 facets: {(0, 1, 3), (0, 2, 3), (1, 2)}\n", "{(0, 1, 3): -12*y1*y2 + 47*t2*y1 - 47*t1*y2 - 59*y1 + 22*y2 - 95*t1 - 132*t2 + 67, (0, 2, 3): -178*y1*y2 - 29*t2*y1 + 29*t1*y2 - 15*y1 + 22*y2 - 7*t1 - 132*t2 + 67, (0, 1): -59*y1 - 95*t1 + 67, (0, 2): -15*y1 - 7*t1 + 67, (0, 3): 22*y1 - 132*t1 + 67, (1, 2): -5*y1 + 88*t1 - 28, (1, 3): 34*y1 - 37*t1 - 28, (2, 3): 66*y1 - 125*t1 + 60, (0,): 67, (1,): -28, (2,): 60, (3,): -65}\n", "iteration: 3 num_vertices: 6 max_num_facets: 2 facets: {(2, 3, 4), (0, 1, 3, 4)}\n", "{(0, 1, 3, 4): -36*y1*y2*y3 + 444*t3*y1*y2 - 444*t2*y1*y3 + 444*t1*y2*y3 - 22*y1*y2 + 120*y1*y3 - 130*y2*y3 - 51*t2*y1 - 129*t3*y1 + 51*t1*y2 - 118*t3*y2 + 129*t1*y3 + 118*t2*y3 + 22*y1 + 67*y2 - 93*y3 - 57*t1 - 8*t2 + 112*t3 - 22, (0, 1, 3): -22*y1*y2 - 51*t2*y1 + 51*t1*y2 + 22*y1 + 67*y2 - 57*t1 - 8*t2 - 22, (0, 1, 4): 120*y1*y2 - 129*t2*y1 + 129*t1*y2 + 22*y1 - 93*y2 - 57*t1 + 112*t2 - 22, (0, 3, 4): -130*y1*y2 - 118*t2*y1 + 118*t1*y2 + 67*y1 - 93*y2 - 8*t1 + 112*t2 - 22, (1, 3, 4): 172*y1*y2 - 40*t2*y1 + 40*t1*y2 + 96*y1 + 14*y2 + 49*t1 + 169*t2 - 79, (2, 3, 4): -96*y1*y2 + 92*t2*y1 - 92*t1*y2 + 35*y1 + 85*y2 - 35*t1 + 85*t2 + 5, (0, 1): 22*y1 - 57*t1 - 22, (0, 3): 67*y1 - 8*t1 - 22, (0, 4): -93*y1 + 112*t1 - 22, (1, 3): 96*y1 + 49*t1 - 79, (1, 4): 14*y1 + 169*t1 - 79, (2, 3): 35*y1 - 35*t1 + 5, (2, 4): 85*y1 + 85*t1 + 5, (3, 4): -42*y1 + 120*t1 - 30, (0,): -22, (1,): -79, (2,): 5, (3,): -30, (4,): 90}\n", "iteration: 4 num_vertices: 2 max_num_facets: 2 facets: {(1,), (0,)}\n", "{(0,): -2, (1,): 97}\n", "iteration: 5 num_vertices: 5 max_num_facets: 5 facets: {(0, 2, 3, 4), (0, 1, 2, 4), (1, 2, 3)}\n", "{(0, 1, 2, 4): -384*y1*y2*y3 + 212*t3*y1*y2 - 212*t2*y1*y3 + 212*t1*y2*y3 - 76*y1*y2 - 44*y1*y3 - 128*y2*y3 + 8*t2*y1 + 28*t3*y1 - 8*t1*y2 - 103*t3*y2 - 28*t1*y3 + 103*t2*y3 - 6*y1 + 51*y2 - 46*y3 - 37*t1 + 119*t2 + 147*t3 - 63, (0, 2, 3, 4): -150*y1*y2*y3 - 254*t3*y1*y2 + 254*t2*y1*y3 - 254*t1*y2*y3 + 142*y1*y2 - 128*y1*y3 + 74*y2*y3 + 61*t2*y1 - 103*t3*y1 - 61*t1*y2 + t3*y2 + 103*t1*y3 - t2*y3 + 51*y1 + 53*y2 - 46*y3 + 119*t1 + 125*t2 + 147*t3 - 63, (0, 1, 2): -76*y1*y2 + 8*t2*y1 - 8*t1*y2 - 6*y1 + 51*y2 - 37*t1 + 119*t2 - 63, (0, 1, 4): -44*y1*y2 + 28*t2*y1 - 28*t1*y2 - 6*y1 - 46*y2 - 37*t1 + 147*t2 - 63, (0, 2, 3): 142*y1*y2 + 61*t2*y1 - 61*t1*y2 + 51*y1 + 53*y2 + 119*t1 + 125*t2 - 63, (0, 2, 4): -128*y1*y2 - 103*t2*y1 + 103*t1*y2 + 51*y1 - 46*y2 + 119*t1 + 147*t2 - 63, (0, 3, 4): 74*y1*y2 + t2*y1 - t1*y2 + 53*y1 - 46*y2 + 125*t1 + 147*t2 - 63, (1, 2, 3): 148*y1*y2 - 55*t2*y1 + 55*t1*y2 + 49*y1 - 65*y2 + 156*t1 + 162*t2 - 100, (1, 2, 4): 52*y1*y2 - 123*t2*y1 + 123*t1*y2 + 49*y1 - 68*y2 + 156*t1 + 184*t2 - 100, (2, 3, 4): 90*y1*y2 + 165*t2*y1 - 165*t1*y2 - 59*y1 + 6*y2 + 6*t1 + 28*t2 + 56, (0, 1): -6*y1 - 37*t1 - 63, (0, 2): 51*y1 + 119*t1 - 63, (0, 3): 53*y1 + 125*t1 - 63, (0, 4): -46*y1 + 147*t1 - 63, (1, 2): 49*y1 + 156*t1 - 100, (1, 3): -65*y1 + 162*t1 - 100, (1, 4): -68*y1 + 184*t1 - 100, (2, 3): -59*y1 + 6*t1 + 56, (2, 4): 6*y1 + 28*t1 + 56, (3, 4): -100*y1 + 22*t1 + 62, (0,): -63, (1,): -100, (2,): 56, (3,): 62, (4,): 84}\n", "iteration: 6 num_vertices: 2 max_num_facets: 1 facets: {(1,), (0,)}\n", "{(0,): -95, (1,): 1}\n", "iteration: 7 num_vertices: 4 max_num_facets: 3 facets: {(1, 3), (0, 2, 3)}\n", "{(0, 2, 3): -182*y1*y2 - 93*t2*y1 + 93*t1*y2 - 53*y1 - 66*y2 - 25*t1 - 26*t2 - 52, (0, 2): -53*y1 - 25*t1 - 52, (0, 3): -66*y1 - 26*t1 - 52, (1, 3): -35*y1 + 16*t1 - 94, (2, 3): 80*y1 - t1 - 77, (0,): -52, (1,): -94, (2,): -77, (3,): -78}\n", "iteration: 8 num_vertices: 5 max_num_facets: 4 facets: {(2, 3, 4), (1, 2), (0, 1, 3, 4)}\n", "{(0, 1, 3, 4): 36*y1*y2*y3 - 74*t3*y1*y2 + 74*t2*y1*y3 - 74*t1*y2*y3 + 190*y1*y2 - 138*y1*y3 - 172*y2*y3 - 6*t3*y1 - 16*t3*y2 + 6*t1*y3 + 16*t2*y3 + 44*y1 - 3*y2 - 13*y3 + 90*t1 - 8*t2 + 136*t3 - 46, (0, 1, 3): 190*y1*y2 + 44*y1 - 3*y2 + 90*t1 - 8*t2 - 46, (0, 1, 4): -138*y1*y2 - 6*t2*y1 + 6*t1*y2 + 44*y1 - 13*y2 + 90*t1 + 136*t2 - 46, (0, 3, 4): -172*y1*y2 - 16*t2*y1 + 16*t1*y2 - 3*y1 - 13*y2 - 8*t1 + 136*t2 - 46, (1, 3, 4): 82*y1*y2 - 10*t2*y1 + 10*t1*y2 - 47*y1 - 51*y2 - 98*t1 + 46*t2 + 44, (2, 3, 4): 6*y1*y2 + 85*t2*y1 - 85*t1*y2 - 72*y1 + 19*y2 + 17*t1 + 161*t2 - 71, (0, 1): 44*y1 + 90*t1 - 46, (0, 3): -3*y1 - 8*t1 - 46, (0, 4): -13*y1 + 136*t1 - 46, (1, 2): -27*y1 - 115*t1 + 44, (1, 3): -47*y1 - 98*t1 + 44, (1, 4): -51*y1 + 46*t1 + 44, (2, 3): -72*y1 + 17*t1 - 71, (2, 4): 19*y1 + 161*t1 - 71, (3, 4): 6*y1 + 144*t1 - 54, (0,): -46, (1,): 44, (2,): -71, (3,): -54, (4,): 90}\n", "iteration: 9 num_vertices: 5 max_num_facets: 3 facets: {(1, 3), (1, 2)}\n", "{(1, 2): 91*y1 - 78*t1 + 81, (1, 3): 100*y1 + 5*t1 + 81, (1,): 81, (2,): 3, (3,): 86}\n", "success: True\n" ] } ], "source": [ "test(max_vertices=6, verbose=True)" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [], "source": [ "S = random_simplicial_complex(5,4)\n", "A = AplK(S)" ] }, { "cell_type": "code", "execution_count": 34, "metadata": {}, "outputs": [], "source": [ "c1 = random_cochain(S)\n", "p1 = A.lift(c1)\n", "c2 = random_cochain(S)\n", "p2 = A.lift(c2)" ] }, { "cell_type": "code", "execution_count": 40, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Object `differential` not found.\n" ] } ], "source": [ "(p2*p1).differential" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "a = apl.algebras[2]" ] }, { "cell_type": "code", "execution_count": 50, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Commutative Differential Graded Algebra with generators ('t0', 't1', 't2', 'y0', 'y1', 'y2') in degrees ((0, 2), (0, 2), (0, 2), (1, 2), (1, 2), (1, 2)) over Rational Field with differential:\n", " t0 --> y0\n", " t1 --> y1\n", " t2 --> y2\n", " y0 --> 0\n", " y1 --> 0\n", " y2 --> 0" ] }, "execution_count": 50, "metadata": {}, "output_type": "execute_result" } ], "source": [] }, { "cell_type": "code", "execution_count": 45, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Minimal model $S^2 \\wedge S^1$" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "S1 = SimplicialComplex([[0,1,2],[0,1,3],[0,2,3],[1,2,3],[3,4],[3,5],[4,5]],is_mutable=False) \n", "S2 = SimplicialComplex([[0,1,2],[0,1,3],[0,2,3],[1,2,3],[3,4,5],[3,4,6],[3,5,6],[4,5,6]],is_mutable=False)\n", "S = S1\n", "apl = Apln(S.dimension())\n", "A = AplK(S)\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# busco el primer grupo de cohomología no trivial\n", "gens = cohomology_gens(S,1)\n", "gens" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "c10 = lift_cohomology_generator(S,gens[(1,0)])\n", "a10 = A.lift(c10)\n", "a10" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# compruebo que la diferencial es cero\n", "a10.is_closed()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# pasamos al sigiente grado\n", "gens = cohomology_gens(S,2)\n", "gens" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "c20 = lift_cohomology_generator(S,gens[(2,0)])\n", "a20 = A.lift(c20)\n", "a20" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "c20.keys()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "a20.is_closed()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "a10*a20" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Minimal model $S^2 \\wedge S^2$" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "S2 = SimplicialComplex([[0,1,2],[0,1,3],[0,2,3],[1,2,3],[3,4,5],[3,4,6],[3,5,6],[4,5,6]],is_mutable=False)\n", "S = S2\n", "apl = Apln(S.dimension())\n", "A = AplK(S)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# busco el primer grupo de cohomología no trivial\n", "gens = cohomology_gens(S,2)\n", "gens" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "c20 = lift_cohomology_generator(S,gens[(2,0)])\n", "a20 = A.lift(c20)\n", "c21 = lift_cohomology_generator(S,gens[(2,1)])\n", "a21 = A.lift(c21)\n", "a20*a21 == a20.nullElement()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "a31 = a20.nullElement()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "for k in gens.keys():\n", " print(k[0])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Minimal model" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "class MinimalModel():\n", "\n", " def __init__(self, S):\n", " self.K = S\n", " self.Phi = {}\n", " self.AplK = AplK(S)\n", " self.Apln = Apln(S.dimension())\n", " gens = self.first_non_trivial_cohomology_group()\n", " [self.cdga, self.cohomology_dict] = self.createModel(gens)\n", " \n", " def first_non_trivial_cohomology_group(self, max_iter=20):\n", " # busco el primer grupo de cohomología no trivial\n", " i=1\n", " gens = self.cohomology_gens(i)\n", " while(len(gens)==0 and i