<p>HAP uses implementations of chain complexes of free <span class="SimpleMath">\(\mathbb K\)</span>-modules for each of the rings <span class="SimpleMath">\(\mathbb K = \mathbb Z\)</span>, <span class="SimpleMath">\(\mathbb K = \mathbb Q\)</span>, <span class="SimpleMath">\(\mathbb K = \mathbb F_p\)</span> with <span class="SimpleMath">\(p\)</span> a prime number, <span class="SimpleMath">\(\mathbb K = \mathbb ZG\)</span>, <span class="SimpleMath">\(\mathbb K = \mathbb F_pG\)</span> with <span class="SimpleMath">\(G\)</span> a group. The implemented chain complexes have the form</p>
<p>Such a complex is said to have <em>length</em> <span class="SimpleMath">\(n\)</span> and the rank of the free <span class="SimpleMath">\(\mathbb K\)</span>-module <span class="SimpleMath">\(C_k\)</span> is referred to as the <em>dimenion</em> of the complex in degree <span class="SimpleMath">\(k\)</span>.</p>
<p>For the case <span class="SimpleMath">\(\mathbb K = \mathbb ZG\)</span> (resp. <span class="SimpleMath">\(\mathbb K = \mathbb F_pG\)</span>) the main focus is on free chain complexes that are exact at each degree <span class="SimpleMath">\(k\)</span>, i.e. <span class="SimpleMath">\({\rm im}(d_{k+1})={\rm ker}(d_k)\)</span>, for <span class="SimpleMath">\(0 < k < n\)</span> and with <spanclass="SimpleMath">\(C_0/{\rm im}(d_1) \cong \mathbb Z\)</span> (resp. <span class="SimpleMath">\(C_0/{\rm im}(d_1) \cong \mathbb F_p\)</span>). We refer to such a chain complex as a <em>resolution of length </em> <span class="SimpleMath">\(n\)</span> even though <span class="SimpleMath">\(d_n\)</span> will typically not be injective. More correct terminology would refer to such a chain complex as the first <span class="SimpleMath">\(n\)</span> degrees of a free resolution.</p>
<p>The following sections illustrate some constructions of chain complexes. Constructions for resolutions are described in the next chapter <a href="chap11_mj.html#X7C0B125E7D5415B4"><span class="RefLink">11</span></a>.</p>
<h4>10.1 <span class="Heading">Chain complex of a simplicial complex and simplicial pair</span></h4>
<p>The following example constructs the Quillen simplicial complex <span class="SimpleMath">\(Q={\mathcal A}_p(G)\)</span> for <span class="SimpleMath">\(p=2\)</span> and <span class="SimpleMath">\(G=A_8\)</span>; this is the order complex of the poset of non-trivial elementary <span class="SimpleMath">\(2\)</span>-subgroups of <span class="SimpleMath">\(G\)</span>. The chain complex <span class="SimpleMath">\(C_\ast = C_\ast(Q)\)</span> is then computed and seen to have the same number of free generators as <span class="SimpleMath">\(Q\)</span> has simplices. (To ensure indexing of subcomplexes is consistent with that of the large complex it is best to work with vertices represented as integers.)</p>
<p>Next the simplicial complex <span class="SimpleMath">\(Q\)</span> is converted to one whose vertices are represented by integers and a contactible subcomplex <span class="SimpleMath">\(L < Q\)</span> is computed. The chain complex <span class="SimpleMath">\(D_\ast=C_\ast(Q,L)\)</span> of the simplicial pair <span class="SimpleMath">\((Q,L)\)</span> is constructed and seen to have the correct size.</p>
<p>The next commands produce a smalled chain complex <span class="SimpleMath">\(B_\ast\)</span> chain homotopy equivalent to <span class="SimpleMath">\(D_\ast\)</span> and compute the homology <span class="SimpleMath">\(H_k(Q,\mathbb Z) \cong H_k(B_\ast)\)</span> for <span class="SimpleMath">\(k=1,2,3\)</span>.</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">B:=ContractedComplex(D);</span>
Chain complex of length 3 in characteristic 0 .
<h4>10.2 <span class="Heading">Chain complex of a cubical complex and cubical pair</span></h4>
<p>The following example reads in the digital image</p>
<p><img src="images/bw_image.bmp" align="center" height="300" alt="a digital image"/></p>
<p>as a <span class="SimpleMath">\(2\)</span>-dimensional pure cubical complex <span class="SimpleMath">\(M\)</span> and constructs the chain complex <span class="SimpleMath">\(C_\ast=C_\ast(M)\)</span>.</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">K:=ReadImageAsPureCubicalComplex(file,400);</span>
Pure cubical complex of dimension 2.
<span class="GAPprompt">gap></span> <span class="GAPinput">C:=ChainComplex(K);</span>
Chain complex of length 2 in characteristic 0 .
<p>Next an acyclic pure cubical subcomplex <span class="SimpleMath">\(L < M\)</span> is computed and the chain complex <span class="SimpleMath">\(D_\ast=C_\ast(M,L)\)</span> of the pair is constructed.</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">L:=AcyclicSubcomplexOfPureCubicalComplex(K);</span>
Pure cubical complex of dimension 2.
<span class="GAPprompt">gap></span> <span class="GAPinput">D:=ChainComplexOfPair(K,L);</span>
Chain complex of length 2 in characteristic 0 .
<p>Finally the chain complex <span class="SimpleMath">\(D_\ast\)</span> is simplified to a homotopy equivalent chain complex <span class="SimpleMath">\(B_\ast\)</span> and the homology <span class="SimpleMath">\(H_1(M,\mathbb Z) \cong H_1(B_\ast)\)</span> is computed.</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">B:=ContractedComplex(D);</span>
Chain complex of length 2 in characteristic 0 .
<h4>10.3 <span class="Heading">Chain complex of a regular CW-complex</span></h4>
<p>The next example constructs a <span class="SimpleMath">\(15\)</span>-dimensional regular CW-complex <span class="SimpleMath">\(Y\)</span> that is homotopy equivalent to the <span class="SimpleMath">\(2\)</span>-dimensional torus.</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">Circle:=PureCubicalComplex([[1,1,1,1,1],[1,1,0,1,1],[1,1,1,1,1]]);</span>
Pure cubical complex of dimension 2.
<span class="GAPprompt">gap></span> <span class="GAPinput">Torus:=DirectProductOfPureCubicalComplexes(Circle,Circle);</span>
Pure cubical complex of dimension 4.
<span class="GAPprompt">gap></span> <span class="GAPinput">CTorus:=CechComplexOfPureCubicalComplex(Torus);</span>
Simplicial complex of dimension 15.
<span class="GAPprompt">gap></span> <span class="GAPinput">Y:=RegularCWComplex(CTorus);</span>
Regular CW-complex of dimension 15
</pre></div>
<p>Next the cellular chain complex <span class="SimpleMath">\(C_\ast=C_\ast(Y)\)</span> is constructed. Also, a minimally generated chain complex <span class="SimpleMath">\(D_\ast=C_\ast(Y')\) of a non-regular CW-complex \(Y'\simeq Y\)</span> is constructed.</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">C:=ChainComplexOfRegularCWComplex(Y);</span>
Chain complex of length 15 in characteristic 0 .
<h4>10.4 <span class="Heading">Chain Maps of simplicial and regular CW maps</span></h4>
<p>The next example realizes the complement of the first prime knot on <span class="SimpleMath">\(11\)</span> crossings as a pure permutahedral complex. The complement is converted to a regular CW-complex <span class="SimpleMath">\(Y\)</span> and the boundary inclusion <span class="SimpleMath">\(f\colon \partial Y \hookrightarrow Y\)</span> is constructed as a map of regular CW-complexes. Then the induced chain map <span class="SimpleMath">\(F\colon C_\ast(\partial Y) \hookrightarrow C_\ast(Y)\)</span> is constructed. Finally the homology homomorphism <span class="SimpleMath">\(H_1(F)\colon H_1(C_\ast(\partial Y)) \rightarrow H_1(C_\ast(Y))\)</span> is computed.</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">K:=PurePermutahedralKnot(11,1);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">M:=PureComplexComplement(K);</span>
Pure permutahedral complex of dimension 3.
<span class="GAPprompt">gap></span> <span class="GAPinput">Y:=RegularCWComplex(M);</span>
Regular CW-complex of dimension 3
<span class="GAPprompt">gap></span> <span class="GAPinput">f:=BoundaryMap(Y);</span> Map of regular CW-complexes
<span class="GAPprompt">gap></span> <span class="GAPinput">F:=ChainMap(f);</span>
Chain Map between complexes of length 2 .
<span class="GAPprompt">gap></span> <span class="GAPinput">Kernel(H);</span>
Pcp-group with orders [ 0 ]
</pre></div>
<p>The command <code class="code">ChainMap(f)</code> can be used to construct the chain map <span class="SimpleMath">\(C_\ast(K) \rightarrow C_\ast(K')\) induced by a map \(f\colon K\rightarrow K'\)</span> of simplicial complexes.</p>
<p>A sequence of inclusions of chain complexes <span class="SimpleMath">\(C_{0,\ast} \le C_{1,\ast} \le \cdots \le C_{T-1,\ast} \le C_{T,\ast}\)</span> in which the preferred basis of <span class="SimpleMath">\(C_{k-1,\ell}\)</span> is the beginning of the preferred basis of <span class="SimpleMath">\(C_{k,\ell}\)</span> is referred to as a <em>filtered chain complex</em>. Filtered chain complexes give rise to spectral sequences such as the <em>equivariant spectral sequence</em> of a <span class="SimpleMath">\(G-CW\)</span>-complex with subgroup <span class="SimpleMath">\(H < G\)</span>. A particular case is the Lyndon-Hochschild-Serre spectral sequence for the homology of a group extension <span class="SimpleMath">\(N \rightarrowtail G \twoheadrightarrow Q\)</span> with <span class="SimpleMath">\(E^2_{p,q}=H_p(Q,H_q(N, \mathbb Z))\)</span>.</p>
<p>The following commands construct the filtered chain complex underlying the Lyndon-Hochschild-Serre spectral sequence for the dihedral group <span class="SimpleMath">\(G=D_{32}\)</span> of order 64 and its centre <span class="SimpleMath">\(N=Z(G)\)</span>.</p>
<p>The differentials <span class="SimpleMath">\(d^r_{p,q}\)</span> in a given page <span class="SimpleMath">\(E^r\)</span> of the spectral sequence arise from the induced homology homomorphisms <span class="SimpleMath">\(\iota^{s,t}_\ell\colon H_{\ell}(C_{s,\ast}) \rightarrow H_{\ell}(C_{t,\ast})\)</span> for <span class="SimpleMath">\(s\le t\)</span>. Textbooks traditionally picture the differential in <span class="SimpleMath">\(E^r\)</span> as an array of sloping arrows with non-zero groups <span class="SimpleMath">\(E^r_{p,q}\neq 0\)</span> represented by dots. An alternative representation of this information is as a barcode (of the sort used in Topological Data Analysis). The homomorphisms <span class="SimpleMath">\(\iota^{\ast,\ast}_2\)</span> in the example, with coefficients converted to mod <span class="SimpleMath">\(2\)</span>, are pictured by the bar code</p>
<p><img src="images/lhsbc.png" align="center" height="150" alt="a bar code for the LHS spectral sequence"/></p>
<p>which was produced by the following commands.</p>
<p>Boundary homomorphisms in all of the above examples of chain complexes are represented by matrices. In cases where the matrices are large and have many zero entries it is better to use sparse matrices.</p>
<p>The following commands demonstrate the conversion of the matrix</p>
<p>To illustrate the use of sparse chain complexes we consider the data points represented in the following digital image.</p>
<p><img src="images/data500.png" align="center" height="200" alt="data points samples from an annulus"/></p>
<p>The following commands read in this image as a <span class="SimpleMath">\(2\)</span>-dimensional pure cubical complex and store the Euclidean coordinates of the black pixels in a list. Then 200 points are selected at random from this list and used to construct a <span class="SimpleMath">\(200\times 200\)</span> symmetric matrix <span class="SimpleMath">\(S\)</span> whose entries are the Euclidean distance between the sample data points.</p>
<p>The symmetric distance matrix <span class="SimpleMath">\(S\)</span> is next converted to a filtered chain complex arising from a filtered simplicial complex (using the standard <em>persistent homology</em> pipeline).</p>