Interface to CHomP¶
CHomP stands for “Computation Homology Program”, and is good at computing homology of simplicial complexes, cubical complexes, and chain complexes. It can also compute homomorphisms induced on homology by maps. See the CHomP web page http://chomp.rutgers.edu/ for more information.
AUTHOR:
John H. Palmieri

class
sage.interfaces.chomp.
CHomP
¶ Bases:
object
Interface to the CHomP package.
 Parameters
program (string) – which CHomP program to use
complex – a simplicial or cubical complex
subcomplex – a subcomplex of
complex
or None (the default)base_ring (ring; optional, default \(\ZZ\)) – ring over which to perform computations – must be \(\ZZ\) or \(\GF{p}\).
generators (boolean; optional, default False) – if True, also return list of generators
verbose (boolean; optional, default False) – if True, print helpful messages as the computation progresses
extra_opts (string) – options passed directly to
program
 Returns
homology groups as a dictionary indexed by dimension
The programs
homsimpl
,homcubes
, andhomchain
are available through this interface.homsimpl
computes the relative or absolute homology groups of simplicial complexes.homcubes
computes the relative or absolute homology groups of cubical complexes.homchain
computes the homology groups of chain complexes. For consistency with Sage’s other homology computations, the answers produced byhomsimpl
andhomcubes
in the absolute case are converted to reduced homology.Note also that CHomP can only compute over the integers or \(\GF{p}\). CHomP is fast enough, though, that if you want rational information, you should consider using CHomP with integer coefficients, or with mod \(p\) coefficients for a sufficiently large \(p\), rather than using Sage’s builtin homology algorithms.
See also the documentation for the functions
homchain()
,homcubes()
, andhomsimpl()
for more examples, including illustrations of some of the optional parameters.EXAMPLES:
sage: from sage.interfaces.chomp import CHomP sage: T = cubical_complexes.Torus() sage: CHomP()('homcubes', T) # optional  CHomP {0: 0, 1: Z x Z, 2: Z}
Relative homology of a segment relative to its endpoints:
sage: edge = simplicial_complexes.Simplex(1) sage: ends = edge.n_skeleton(0) sage: CHomP()('homsimpl', edge) # optional  CHomP {0: 0} sage: CHomP()('homsimpl', edge, ends) # optional  CHomP {0: 0, 1: Z}
Homology of a chain complex:
sage: C = ChainComplex({3: 2 * identity_matrix(ZZ, 2)}, degree=1) sage: CHomP()('homchain', C) # optional  CHomP {2: C2 x C2}

help
(program)¶ Print a help message for
program
, a program from the CHomP suite. Parameters
program (string) – which CHomP program to use
 Returns
nothing – just print a message
EXAMPLES:
sage: from sage.interfaces.chomp import CHomP sage: CHomP().help('homcubes') # optional  CHomP HOMCUBES, ver. ... Copyright (C) ... by Pawel Pilarczyk...

sage.interfaces.chomp.
have_chomp
(program='homsimpl')¶ Return True if this computer has
program
installed.The first time it is run, this function caches its result in the variable
_have_chomp
– a dictionary indexed by program name – and any subsequent time, it just checks the value of the variable.This program is used in the routine CHomP.__call__.
If this computer doesn’t have CHomP installed, you may obtain it from http://chomp.rutgers.edu/.
EXAMPLES:
sage: from sage.interfaces.chomp import have_chomp sage: have_chomp() # random  depends on whether CHomP is installed True sage: 'homsimpl' in sage.interfaces.chomp._have_chomp True sage: sage.interfaces.chomp._have_chomp['homsimpl'] == have_chomp() True

sage.interfaces.chomp.
homchain
(complex=None, **kwds)¶ Compute the homology of a chain complex using the CHomP program
homchain
. Parameters
complex – a chain complex
generators (boolean; optional, default False) – if True, also return list of generators
verbose (boolean; optional, default False) – if True, print helpful messages as the computation progresses
help (boolean; optional, default False) – if True, just print a help message and exit
extra_opts (string) – options passed directly to
homchain
 Returns
homology groups as a dictionary indexed by dimension
EXAMPLES:
sage: from sage.interfaces.chomp import homchain sage: C = cubical_complexes.Sphere(3).chain_complex() sage: homchain(C)[3] # optional  CHomP Z
Generators: these are given as a list after the homology group. Each generator is specified as a cycle, an element in the appropriate free module over the base ring:
sage: C2 = delta_complexes.Sphere(2).chain_complex() sage: homchain(C2, generators=True)[2] # optional  CHomP (Z, [(1, 1)]) sage: homchain(C2, generators=True, base_ring=GF(2))[2] # optional  CHomP (Vector space of dimension 1 over Finite Field of size 2, [(1, 1)])

sage.interfaces.chomp.
homcubes
(complex=None, subcomplex=None, **kwds)¶ Compute the homology of a cubical complex using the CHomP program
homcubes
. If the argumentsubcomplex
is present, compute homology ofcomplex
relative tosubcomplex
. Parameters
complex – a cubical complex
subcomplex – a subcomplex of
complex
or None (the default)base_ring (ring; optional, default \(\ZZ\)) – ring over which to perform computations – must be \(\ZZ\) or \(\GF{p}\).
generators (boolean; optional, default False) – if True, also return list of generators
verbose (boolean; optional, default False) – if True, print helpful messages as the computation progresses
help (boolean; optional, default False) – if True, just print a help message and exit
extra_opts (string) – options passed directly to
homcubes
 Returns
homology groups as a dictionary indexed by dimension
EXAMPLES:
sage: from sage.interfaces.chomp import homcubes sage: S = cubical_complexes.Sphere(3) sage: homcubes(S)[3] # optional  CHomP Z
Relative homology:
sage: C3 = cubical_complexes.Cube(3) sage: bdry = C3.n_skeleton(2) sage: homcubes(C3, bdry) # optional  CHomP {0: 0, 1: 0, 2: 0, 3: Z}
Generators: these are given as a list after the homology group. Each generator is specified as a linear combination of cubes:
sage: homcubes(cubical_complexes.Sphere(1), generators=True, base_ring=GF(2))[1][1] # optional  CHomP [[[1,1] x [0,1]] + [[0,1] x [1,1]] + [[0,1] x [0,0]] + [[0,0] x [0,1]]]

sage.interfaces.chomp.
homsimpl
(complex=None, subcomplex=None, **kwds)¶ Compute the homology of a simplicial complex using the CHomP program
homsimpl
. If the argumentsubcomplex
is present, compute homology ofcomplex
relative tosubcomplex
. Parameters
complex – a simplicial complex
subcomplex – a subcomplex of
complex
or None (the default)base_ring (ring; optional, default \(\ZZ\)) – ring over which to perform computations – must be \(\ZZ\) or \(\GF{p}\).
generators (boolean; optional, default False) – if True, also return list of generators
verbose (boolean; optional, default False) – if True, print helpful messages as the computation progresses
help (boolean; optional, default False) – if True, just print a help message and exit
extra_opts (string) – options passed directly to
program
 Returns
homology groups as a dictionary indexed by dimension
EXAMPLES:
sage: from sage.interfaces.chomp import homsimpl sage: T = simplicial_complexes.Torus() sage: M8 = simplicial_complexes.MooreSpace(8) sage: M4 = simplicial_complexes.MooreSpace(4) sage: X = T.disjoint_union(T).disjoint_union(T).disjoint_union(M8).disjoint_union(M4) sage: homsimpl(X)[1] # optional  CHomP Z^6 x C4 x C8
Relative homology:
sage: S = simplicial_complexes.Simplex(3) sage: bdry = S.n_skeleton(2) sage: homsimpl(S, bdry)[3] # optional  CHomP Z
Generators: these are given as a list after the homology group. Each generator is specified as a linear combination of simplices:
sage: homsimpl(S, bdry, generators=True)[3] # optional  CHomP (Z, [(0, 1, 2, 3)]) sage: homsimpl(simplicial_complexes.Sphere(1), generators=True) # optional  CHomP {0: 0, 1: (Z, [(0, 1)  (0, 2) + (1, 2)])}

sage.interfaces.chomp.
process_generators_chain
(gen_string, dim, base_ring=None)¶ Process CHomP generator information for simplicial complexes.
 Parameters
gen_string (string) – generator output from CHomP
dim (integer) – dimension in which to find generators
base_ring (optional, default ZZ) – base ring over which to do the computations
 Returns
list of generators in each dimension, as described below
gen_string
has the form[H_0] a1 [H_1] a2 a3 [H_2] a1  a2
For each homology group, each line lists a homology generator as a linear combination of generators
ai
of the group of chains in the appropriate dimension. The elementsai
are indexed starting with \(i=1\). Each generator is converted, using regular expressions, from a string to a vector (an element in the free module overbase_ring
), withai
representing the unit vector in coordinate \(i1\). For example, the stringa1  a2
gets converted to the vector(1, 1)
.Therefore the return value is a list of vectors.
EXAMPLES:
sage: from sage.interfaces.chomp import process_generators_chain sage: s = "[H_0]\na1\n\n[H_1]\na2\na3\n" sage: process_generators_chain(s, 1) [(0, 1), (0, 0, 1)] sage: s = "[H_0]\na1\n\n[H_1]\n5 * a2  a1\na3\n" sage: process_generators_chain(s, 1, base_ring=ZZ) [(1, 5), (0, 0, 1)] sage: process_generators_chain(s, 1, base_ring=GF(2)) [(1, 1), (0, 0, 1)]

sage.interfaces.chomp.
process_generators_cubical
(gen_string, dim)¶ Process CHomP generator information for cubical complexes.
 Parameters
gen_string (string) – generator output from CHomP
dim (integer) – dimension in which to find generators
 Returns
list of generators in each dimension, as described below
gen_string
has the formThe 2 generators of H_1 follow: generator 1 1 * [(0,0,0,0,0)(0,0,0,0,1)] 1 * [(0,0,0,0,0)(0,0,1,0,0)] ... generator 2 1 * [(0,1,0,1,1)(1,1,0,1,1)] 1 * [(0,1,0,0,1)(0,1,0,1,1)] ...
Each line consists of a coefficient multiplied by a cube; the cube is specified by its “bottom left” and “upper right” corners.
For technical reasons, we remove the first coordinate of each tuple, and using regular expressions, the remaining parts get converted from a string to a pair
(coefficient, Cube)
, with the cube represented as a product of tuples. For example, the first line in “generator 1” gets turned into(1, [0,0] x [0,0] x [0,0] x [0,1])
representing an element in the free abelian group with basis given by cubes. Each generator is a list of such pairs, representing the sum of such elements. These are reassembled in
CHomP.__call__()
to actual elements in the free module generated by the cubes of the cubical complex in the appropriate dimension.Therefore the return value is a list of lists of pairs, one list of pairs for each generator.
EXAMPLES:
sage: from sage.interfaces.chomp import process_generators_cubical sage: s = "The 2 generators of H_1 follow:\ngenerator 1:\n1 * [(0,0,0,0,0)(0,0,0,0,1)]\n1 * [(0,0,0,0,0)(0,0,1,0,0)]" sage: process_generators_cubical(s, 1) [[(1, [0,0] x [0,0] x [0,0] x [0,1]), (1, [0,0] x [0,1] x [0,0] x [0,0])]] sage: len(process_generators_cubical(s, 1)) # only one generator 1

sage.interfaces.chomp.
process_generators_simplicial
(gen_string, dim, complex)¶ Process CHomP generator information for simplicial complexes.
 Parameters
gen_string (string) – generator output from CHomP
dim (integer) – dimension in which to find generators
complex – simplicial complex under consideration
 Returns
list of generators in each dimension, as described below
gen_string
has the formThe 2 generators of H_1 follow: generator 1 1 * (1,6) 1 * (1,4) ... generator 2 1 * (1,6) 1 * (1,4) ...
where each line contains a coefficient and a simplex. Each line is converted, using regular expressions, from a string to a pair
(coefficient, Simplex)
, like(1, (1,6))
representing an element in the free abelian group with basis given by simplices. Each generator is a list of such pairs, representing the sum of such elements. These are reassembled in
CHomP.__call__()
to actual elements in the free module generated by the simplices of the simplicial complex in the appropriate dimension.Therefore the return value is a list of lists of pairs, one list of pairs for each generator.
EXAMPLES:
sage: from sage.interfaces.chomp import process_generators_simplicial sage: s = "The 2 generators of H_1 follow:\ngenerator 1:\n1 * (1,6)\n1 * (1,4)" sage: process_generators_simplicial(s, 1, simplicial_complexes.Torus()) [[(1, (1, 6)), (1, (1, 4))]]