# Obtaining symbolic generators from homology()

I need to compute the homology of a chain complex whose graded basis is a collection of formal symbols, say {a,b,c,…}. Does Sage have the capability to store a basis of symbols and express a homology class in terms of a symbolic class representative?

I have been able to able to create a ChainComplex instance using matrices for the boundary maps. For example,

TorusComplex = ChainComplex({0: matrix(Z_2,2,1,[0,0],sparse=True),1: matrix(Z_2,1,2,[0,0],sparse=True)})

"Chain complex with at most 3 nonzero terms over Ring of integers modulo 2"

TorusComplex.homology(generators=true)

"{0: (Vector space of dimension 1 over Ring of integers modulo 2, [(1)]), 1: (Vector space of dimension 2 over Ring of integers modulo 2, [(1, 0), (0, 1)]), 2: (Vector space of dimension 1 over Ring of integers modulo 2, [(1)])}"


However, I can't figure out how define symbols so that the resulting generators are symbols. Any ideas?

edit retag close merge delete

Sort by » oldest newest most voted

From your question it is not completely clear to me what you expect, since i guess you do not want to play with elements of the symbolic ring (which is what "symbol" usually refers to in Sage), so i suspect you want to give Python names to the elements of your graded basis. Here is a suggestion, please explicit more if it is not satisfactory.

When you write:

sage: H = TorusComplex.homology(generators=true) ; H
{0: [(Vector space of dimension 1 over Ring of integers modulo 2,
Chain(0:(1)))],
1: [(Vector space of dimension 1 over Ring of integers modulo 2,
Chain(1:(1, 0))),
(Vector space of dimension 1 over Ring of integers modulo 2,
Chain(1:(0, 1)))],
2: [(Vector space of dimension 1 over Ring of integers modulo 2,
Chain(2:(1)))]}


H is a dictionary that maps a dimension (an element of the set {0,1,2}) to a list of 2-uples (vector space, generator). So, you need to recover the list of generators that appear as second projection of the values of this dictionary. Here is a possible way:

sage: D = dict()

sage: for dim in H:
....:     for n in range(len(H[dim])):
....:         D[dim,n] = H[dim][n][1]

sage: D
{(0, 0): Chain(0:(1)),
(1, 0): Chain(1:(1, 0)),
(1, 1): Chain(1:(0, 1)),
(2, 0): Chain(2:(1))}


Now you can easily give Python names to those four chains, that form your graded basis:

sage: a,b,c,d = D[0,0], D[1,0], D[1,1], D[2,0]


Then you can play with them:

sage: a+a
Trivial chain

sage: a+b+a == b
True

sage: a+b
Chain with 2 nonzero terms over Ring of integers modulo 2

sage: b+c
Chain(1:(1, 1))

sage: (a+b+2*c+d)._vec
{0: (1), 1: (1, 0), 2: (1)}

sage: ascii_art(a+b+2*c+d)
d_2       d_1       d_0       d_-1
0 <---- [1] <---- [1] <---- [1] <----- 0
[0]


As you can see, an element of the homology is stored as dictionary that map each dimension to a vector in the corresponding vector space, which is somehow richer than flat names such as a,b,c,d since it keeps the graded information.

more

@tmonteil, thanks for the reply! Actually, it's not the generators that I wish to have symbolic names for, but instead the elements within the generators. For instance, if the torus had a cellular decomposition of a 2-cell u, two 1-cells, a,b and vertex v, I would like to obtain from TorusComplex.homology(generators=true) homology where the generators are [v], [(a,0),(0,b)] and [u], or whatever it should be. I want the generators, which form bases for the vector spaces, to be symbolic expressions. Does that make sense? I don't know how to enter symbolic representations of a chain complex, but only the incidence matrices.

( 2015-09-27 17:18:34 -0600 )edit

Perhaps I do want to "play with the Symbolic Ring" as you say. However, the homology() function says it only works for integer rings and fields. Would that be compatible?

( 2015-09-28 10:56:55 -0600 )edit