# error computing homology of a simplicial complex

I'm running code to first generate a simplicial complex that is just a 3 dimensional lattice. I'm then adding square plaquettes. However, I get an error sometimes when I try to calculate homology. Specifically, when I run the code below I get the error:

ValueError: The differentials d_{2} and d_{1} are not compatible: their composition is not zero.

This seems strange since a simplicial complex should always have homology. The error persists even when I specify the homology function to use different algorithms.

def grid(n1, n2=None, n3=None):
if n2 == None:
n2 = n1
if n3 == None:
n3 = n1
edges = []
for i in range(n1+1):
for j in range(n2+1):
for k in range(n3+1):
if i < n:
edges.append(((i,j,k),(i+1,j,k)))
if j < n:
edges.append(((i,j,k),(i,j+1,k)))
if k < n:
edges.append(((i,j,k),(i,j,k+1)))
return edges

t0 = SimplicialComplex(grid(2))
t0.homology()


The full text of the error is:

Traceback (most recent call last): File "<stdin>", line 1, in <module> File "_sage_input_8.py", line 10, in <module> exec compile(u'open("___code___.py","w").write("# -- coding: utf-8 --\n" + _support_.preparse_worksheet_cell(base64.b64decode("I2dpdmVzIGVycm9yIHNhdmUhISEKdDAgPSBTaW1wbGljaWFsQ29tcGxleChncmlkKDIpKQphZGRfcGxhcXVldHRlKHQwLCAoMCwwLDEsMCkpCmFkZF9wbGFxdWV0dGUodDAsICgwLDAsMSwxKSkKYWRkX3BsYXF1ZXR0ZSh0MCwgKDIsMiwwLDEpKQp0MC5ob21vbG9neSgp"),globals())+"\n"); execfile(os.path.abspath("___code___.py")) File "", line 1, in <module>

File "/tmp/tmpBNPSQ1/___code___.py", line 7, in <module> exec compile(u't0.homology() File "", line 1, in <module>

File "/home/sage/sage-5.9/local/lib/python2.7/site-packages/sage/homology/cell_complex.py", line 549, in homology return self._homology_(dim, *kwds) File "/home/sage/sage-5.9/local/lib/python2.7/site-packages/sage/homology/simplicial_complex.py", line 1925, in _homology_ cochain=cohomology, *kwds) File "/home/sage/sage-5.9/local/lib/python2.7/site-packages/sage/homology/simplicial_complex.py", line 1788, in chain_complex return ChainComplex(data=differentials, degree=-1, **kwds) File "/home/sage/sage-5.9/local/lib/python2.7/site-packages/sage/homology/chain_complex.py", line 462, in __init__ raise ValueError, "The differentials d_{%s} and d_{%s} are not compatible: their composition is not zero." % (n, n+degree) ValueError: The differentials d_{2} and d_{1} are not compatible: their composition is not zero.

edit retag close merge delete

Sort by ยป oldest newest most voted

Confirmed, this is now Trac #14578

PS: Your grid() method refers to the undeclared n, this is a bug in your code. But not the reason for the ValueError.

more

There is now a patch up. With the patch in place, the code runs without error, and the homology of t0 is ZZ^25 in dimension 1, 0 otherwise.

( 2013-05-14 15:15:06 +0200 )edit

Hello,

The method which fails is delta_complex which is inderectly called with homology. As a quick workaround (I did not completely debug) it seems that simplical complexes do not like vertices other than 0, 1, 2, ...

In particular, the following version of your code does work

def t2i(i,j,k,n=2):
return i+n*(j+n*k)

def grid(n=2):
edges = []
for i in range(n+1):
for j in range(n+1):
for k in range(n+1):
if i < n:
edges.append([t2i(i,j,k,n),t2i(i+1,j,k,n)])
if j < n:
edges.append([t2i(i,j,k,n),t2i(i,j+1,k,n)])
if k < n:
edges.append([t2i(i,j,k,n),t2i(i,j,k+1,n)])
return edges

F1 = ((a1,a2,b),(a1+1,a2,b),(a1,a2+1,b))
F2 = ((a1+1,a2+1,b),(a1+1,a2,b),(a1,a2+1,b))
F1 = ((a1,b,a2),(a1+1,b,a2),(a1,b,a2+1))
F2 = ((a1+1,b,a2+1),(a1+1,b,a2),(a1,b,a2+1))
F1 = ((b,a1,a2),(b,a1+1,a2),(b,a1,a2+1))
F2 = ((b,a1+1,a2+1),(b,a1+1,a2),(b,a1,a2+1))


 {0: 0, 1: Z^18, 2: 0}

more

It has something to do with the ordering for sure, but its not as easy as you make it. The testcase in #14578 fails with integer vertex labels, too.

( 2013-05-14 08:15:18 +0200 )edit

Then, it is a real mystery ! (I do not want to bet on the trueness of Sage's answer in my code)

( 2013-05-14 15:01:25 +0200 )edit

I don't think that delta_complex is involved here.

( 2013-05-14 15:22:59 +0200 )edit

Perhaps not, but calling t0.delta_complex() fails (and I guess that it is inside that function that the condition on the derivation is tested).

( 2013-05-14 16:41:38 +0200 )edit

I think that t0.delta_complex() fails because of the inconsistent ordering of the vertices in the facets. When defining a Delta complex, you need to be very careful about such orderings, so it is not that surprising that this fails. Sorting the facets as they are added seems to fix both problems.

( 2013-05-14 16:53:36 +0200 )edit

I think the problem is the add_face method. If you define the same complex, specifying all of the facets at once, then it ought to work, so a workaround: once you've defined t0 as above:

sage: t0_fixed = SimplicialComplex(t0.facets())

more

add_face has been fixed in the patch at http://trac.sagemath.org/sage_trac/ticket/14578.

( 2013-05-14 15:17:05 +0200 )edit

This bug is fixed in sage 5.10 (trac ticket 14578), and you will now get the following answer :

{0: 0, 1: Z^25, 2: 0}


But a previous answer of @vdelecroix suggests that the answer could be:

{0: 0, 1: Z^18, 2: 0}


Perhaps there is a problem somewhere, what should be the right result ?

more

The cell count is sage: [len(t0.cells()[i]) for i in range(3)] [54, 84, 6] so the Euler characteristic is -24. Only the former answer can be correct. Note that it is reduced homology, hence the offset by one.

( 2013-06-27 17:15:43 +0200 )edit