1 Introduction

In the past two decades, homology and cohomology theory have gained vivid attention outside of the mathematics community prompted by modern applications in sciences and engineering. The development of a computational approach to these theories is motivated, among others, by problems in dynamical systems [18], material science [5, 8], electromagnetism [9, 14], geometric modeling [10], image understanding and digital image processing [1, 3, 12, 16, 22]. Conversely, that development is enabled by progress in computer science. Although algebraic topology arose from applications and has been thought of as a computable tool since its early stage, practical implementations had to wait until the modern generation of powerful computers due to the complexity of the operations involved, especially in high-dimensional problems.

Until recently, progress has mainly been achieved in the computation of homology. The software libraries CHomP [4] and RedHom [24] provide systematic approach to computing homology of topological spaces in arbitrary dimension. There are also implementations of homology algorithms for some specialized tasks as, in particular, GAP [11] and Dionysus [19]. The abundance of various homology algorithms and implementations is, at least in part, a consequence of the fact that the optimization techniques depend crucially on the type of input as well as the data structure chosen to represent it. Simplicial complexes constitute a common and historically well justified method to represent topological spaces. However, in many applications, in particular in rigorous numerics of dynamical systems and in all types of raster graphics a union of unit cubes in a cubical lattice provides the most natural way to represent sets. This leads to the concepts of a cubical set, a combinatorial cubical complex and cubical homology as introduced in [15]. These concepts should not be confused neither with the singular cubical homology [17] nor with the notion of cubical set in the homotopy theory or algebra [2]. The cubical set in the sense of [15] may look as a very restrictive one from the point of view of the general theory but it is sufficiently broad in the context of applications and, most importantly, its rigidness allows for bitmap representations which are extremely efficient due to the natural optimization of processors to perform operation on bitmaps. In this paper, we shall work in the framework of [15] but extending the material on cubical homology to the dual cochain groups.

Cohomology theory, not less important than homology from the point of view of applications, but intrinsically more difficult, had to wait longer for computer implementations. Whenever a mathematical model made it possible as, for example, in the case of orientable manifolds, duality has been used to avoid explicitly working with cohomology. However, among features distinguishing cohomology from homology is the cup product, which renders a ring structure on cohomology. The cup product is a difficult concept, which has been more challenging to make explicit enough for computer programs than homology or cohomology groups. Some significant application-oriented work on computing the cohomology ring of simplicial complexes has been done by Real et al. [13].

The notion of the singular cubical homology and cohomology and a cubical cup product formula were first introduced in 1951 by Serre [25, Chap. 2]. However, we wish to emphasize that this pioneering approach is far from the combinatorial and application–driven spirit of our work; for three main reasons: of all, singular cubes are defined as equivalence classes of all continuous functions from the standard cube [0,1]d to a given topological space. Secondly, because Serre, in his original work, does not directly derive algebraic properties of the singular cubical cohomology ring by arguments within his theory: he only refers to the isomorphism between singular and simplicial (co)homology. Finally, because Serre’s result on this topic is hidden as part of a highly theoretical work addressed to readers with a deep background in pure mathematics and beyond the reach of most of the computer engineering community for instance. This is why authors working on applications of cohomology to 3D digital images e.g. [12, 13] in the framework of 3D cellular cubical complexes tend to derive the needed cubical formulas from the simplicial theory rather than from Serre’s work. Our philosophy is based on the observation that the combinatorial cubical complexes presented in [15] are a more friendly framework than the simplicial or singular setting, to directly derive explicit formulas, such as, for instance, the cup product formula, and to implement them in dimension-independent algorithms.

Let us recall the general definition of the cup product used in the standard literature on homological algebra [23].

Definition 1.1

The cup product ⌣:H p(XH q(X)→H p+q(X) is defined on cohomology classes of cocycles z p and z q as follows:

$$ \bigl[z^p\bigr]\smile \bigl[z^q \bigr]:= \operatorname {diag}^*\bigl(\bigl[z^p\bigr] \times \bigl[z^q \bigr]\bigr), $$
(1)

where [z p]×[z q] is the cohomology cross product and \(\operatorname {diag}^{*}\) is the homomorphism induced by the diagonal map \(\operatorname {diag}: X \to X\times X\) given by \(\operatorname {diag}(x):=(x,x)\).

An algorithm for cup product based on formula (1) would require an implementation of cross product and \(\operatorname {diag}^{*}\) homomorphism which is troublesome and would lead to an inefficient algorithm. The main goal of this paper is to provide an explicit formula for computing the cup product in the setting of cubical sets. As we will prove in Theorem 2.24 the computation of the cup product of two generating elementary cubes in dimension d reduces coordinate-wise to dimension one and the respective formula in dimension one, given by Theorem 2.20 is straightforward to implement.

Such an elementary and easy to implement formula is possible, because in the context of cubical sets the cochain cross product

$$\times : C^p(X)\times C^q(Y)\to C^{p+q}(X\times Y) $$

is simply the dual of the cubical product

$${\;\diamond }\;: C_p\bigl({\mathbb{R}}^{d_1}\bigr)\times C_q\bigl( {\mathbb{R}}^{d_2}\bigr)\to C_{p+q}\bigl({\mathbb{R}}^{d_1+d_2}\bigr), $$

introduced in [15], restricted to cubical sets \(X \in {\mathbb{R}}^{d_{1}}\) and \(Y \in {\mathbb{R}}^{d_{2}}\). The concept of cross product is much easier and more natural in the context of cubical sets than for simplical or singular complexes, because the cartesian product of generating cubes is again a generating cube. This is not true for simplices. These considerations lead to Definition 2.16 of the cubical cup product in Sect. 2.3.

In order to obtain Theorem 2.24, we need to derive an explicit formula for a chain map \(\operatorname {diag}_{\#}:\mathcal {C}(X)\to \mathcal {C}(X\times X)\) induced by the diagonal map. Actually, this task is more complex than it may seem at the first glance and Sect. 2.2 is devoted mainly to the related constructions.

Note that the choice of a chain map is not unique, thus the correctness of the definition and the properties of the cup product are achieved at the cohomology level. These properties are discussed in Sect. 2.3. We end the section with an example illustrating the use of the explicit, coordinate-wise formula.

Cubical sets arising from large data sets which are present in applications are built of a huge number of generating elementary cubes. In order to benefit from the established formula in this context, one needs reduction algorithms which render the computation efficient. Thus the second goal of this paper, reached in Sect. 3, is to show that the techniques of S-reductions of S-complexes successfully developed in [20, 21] with the purpose of computing homology of large cubical complexes may be adapted to computing the cohomology ring of a cubical set. The terminology of S-complexes, S-reduction pairs, the coreduction algorithm and the concept of homology models are reviewed and adapted for cohomology. We finish the paper with Sect. 3.5, where computations via S-reductions are carried out and compared on two explicit examples of a still quite simple nature.

The implementation of the methods presented in this paper as well as numerical experiments are in progress. In particular, the method of S-reductions for cohomology groups has been implemented in the Ph.D. thesis of P. Dłotko [6] and numerical experiments indicate the same efficiency of the implementation for cohomology groups as in the case of homology groups.

2 Cubical Cohomology

2.1 Cubical Cohomology Groups

Recall from [15, Chap. 2] that X⊂ℝd is a cubical set if it is a finite union of elementary cubes

$$Q = I_1\times I_2\times \cdots\times I_d \subset {\mathbb{R}}^d $$

where I i is an interval of the form I=[k,k+1] (non-degenerate) or I=[k,k] (degenerate) for some k∈ℤ. For short, [k]:=[k,k]. The dimension dimQ of Q is the number of non-degenerate intervals in its product expression and the embedding number \(\operatorname {emb}\ Q\) is d. The set of all elementary cubes in ℝd is denoted by \(\mathcal {K}({\mathbb{R}}^{d})\) and those of dimension k by \(\mathcal {K}_{k}({\mathbb{R}}^{d})\). Those which are contained in X are denoted by \(\mathcal {K}(X)\), respectively, \(\mathcal {K}_{k}(X)\).

The group C k (ℝd) of cubical k-chains is the free abelian group generated by \(\mathcal {K}_{k}({\mathbb{R}}^{d})\), its canonical basis. For k<0 and k>d, we set C k (ℝd):=0. In the sequel, we identify the geometric elementary cube Q with the elementary cubical chain defined by

$$P \mapsto \left \{ \begin{array}{l@{\quad}l} 1 & \mbox{ if } P=Q,\\ 0 & \mbox{otherwise.} \end{array} \right . $$

We recall that the cubical cross product

$${\times }: C_p\bigl({\mathbb{R}}^n\bigr)\times C_q\bigl( {\mathbb{R}}^m\bigr) \to C_{p+q}\bigl({\mathbb{R}}^{n+m}\bigr) $$

is defined on the canonical basis elements \(P\in \mathcal {K}_{p}^{n}\) and \(Q\in \mathcal {K}_{q}^{m}\) as the cartesian product P×Q and extended on all pairs of chains (c,c′) by bilinearity. In [15], this operation is called cubical product and denoted by cc′ in order to distinguish it from the cartesian product but we abandon this notation here to emphasize its equivalence to the cross product in homological algebra.

Given any k∈ℤ, the cubical boundary map \({\bf \partial }_{k}:C_{k}({\mathbb{R}}^{d})\to C_{k-1}({\mathbb{R}}^{d})\) is a homomorphism defined as follows. If k≤0 or k>d, we have C k (ℝd)=0, hence \({\bf \partial }_{k}=0\). If 0≤kd, \({\bf \partial }_{k}\) is defined on the elements Q of the basis \(\mathcal {K}_{k}({\mathbb{R}}^{d})\) by induction on d.

For d=1, either \(Q=[a]\in \mathcal {K}_{0}({\mathbb{R}}^{d})\) or \(Q=[a,a+1]\in \mathcal {K}_{1}({\mathbb{R}}^{d})\), for some a∈ℤ. In the first case, \({\bf \partial }_{0} Q=0\). In the second case, we put \({\bf \partial }_{1} Q:=[a+1]-[a]\).

For d>1 decompose Q as Q=I×P, where \(\operatorname {emb}\ I=1\) and \(\operatorname {emb}\ P=d-1\), and put

$$ {\bf \partial }_k Q := {\bf \partial }_p I {\times }P + (-1)^p I {\times }{\bf \partial }_q P, $$
(2)

where p=dimI and q=dimP. The pair \((\mathcal {C}({\mathbb{R}}^{d}),{\bf \partial }):=\{ (C_{k}({\mathbb{R}}^{d}),{\bf \partial }_{k} )\}_{k\in {\mathbb{Z}}}\) is called the cubical chain complex ofd. We refer to [15, Chap. 2] for the properties of the cubical cross product and cubical boundary maps, in particular for this one:

Proposition 2.1

[15, Proposition 2.34] For any cC p (ℝn), and c′∈C q (ℝm)

$${\bf \partial }_{p+q}\bigl(c {\times }c'\bigr)={\bf \partial }_p c {\times }c' + (-1)^p c \times {\bf \partial }_q c'. $$

As a consequence of the above formula, the cubical cross product induces an isomorphism of chain complexes

$$\bigoplus_{p+q=r}C_p\bigl({\mathbb{R}}^n\bigr)\otimes C_q\bigl({\mathbb{R}}^m\bigr) \cong C_{p+q}\bigl( {\mathbb{R}}^{n+m}\bigr) $$

(for the definition of the tensor product of chain complexes see e.g. [23, Chap. 7]).

For any c,dC p (ℝd), the notation 〈c,d〉 is used for the scalar product defined on the elements P,Q of the canonical basis \(\mathcal {K}_{p}\) by

$$ \langle P , Q \rangle := \left \{ \begin{array}{l@{\quad}l} 1 & \mbox{if } P=Q,\\[3pt] 0 & \mbox{otherwise.} \end{array} \right . $$
(3)

The support |c| of c is the union of all \(Q\in \mathcal {K}_{p}\) such that 〈c,Q〉≠0. Given a cubical set X⊂ℝd, the cubical chain complex of X denoted by \(\mathcal {C}(X)\) is the restriction of \(\mathcal {C}({\mathbb{R}}^{d})\) to the chains c whose support is contained in X. We refer to [15] for the properties of cubical chain complexes and for the computation of their homology.

Definition 2.2

Let X⊂ℝd be a cubical set. The cubical cochain complex \((\mathcal {C}^{*}(X),\delta )\) is defined as follows. For any k∈ℤ, the k-dimensional cochain group

$$C^k(X)=\mbox {Hom}\,\bigl(C_k(X),{\mathbb{Z}}\bigr), $$

where Hom(−,ℤ) is the functor assigning to any abelian group G the group of all homomorphisms from G to ℤ, called the dual of G. Elements of C k(X) are called cochains and denoted either by c k,d k or by c ,d , if we do not need to specify their dimension k. The value of a cochain c k on a chain d k is denoted by 〈c k,d k 〉. Note that this notation is also used for the scalar product in chain complexes introduced in (3) and in S-complexes in Sect. 3 but it is easy to figure out from the context which product we mean.

The kth coboundary map δ k:C k(X)→C k+1(X) is the dual homomorphism of \({\bf \partial }_{k+1}\) defined by

$$\big\langle \delta^k c^k , d_{k+1} \big\rangle := \big\langle c^k , {\bf \partial }_{k+1} d_{k+1} \big\rangle . $$

Note that C k(X) is the free abelian group generated by the dual canonical basis \(\{{Q}^{\star}|Q\in \mathcal {K}_{k}(X)\}\) where

$$\big\langle {Q}^{\star} , P \big\rangle := \left \{ \begin{array}{l@{\quad}l} 1 & \mbox{if } P=Q,\\[3pt] 0 & \mbox{otherwise.} \end{array} \right . $$

The notation Q , for the dual of Q, is aimed to be distinct from H for the cohomology functor.

Definition 2.3

Given a cubical set X⊂ℝd, the group of k-dimensional cocycles of X is Z k(X):=kerδ k, and the group of k-dimensional coboundaries of X is B k:=im δ k−1. The kth cohomology group of X is the quotient group

$$H^k(X):=Z^k(X)/B^k(X). $$

Definition 2.4

The cubical cross product of cochains c pC p(X) and c qC q(Y) is a cochain in C p+q(X×Y) defined on any elementary cube \(R\times S \in{ \mathcal {K}}_{p+q}(X\times Y)\), where \(R\in \mathcal {K}(X)\) and \(S\in \mathcal {K}(Y)\), as follows:

$$\big\langle c^p\times c^q , R\times S \big\rangle := \left \{ \begin{array}{l@{\quad}l} \langle c^p , R \rangle \cdot \langle c^q , S \rangle & \mbox{if } \dim R=p \mbox{ and }\dim S=q,\\[3pt] 0 & \mbox{otherwise.} \end{array} \right . $$

We easily check the following.

Proposition 2.5

The cross product of cochains is a bilinear map. Moreover, for \(P\in \mathcal {K}_{p}(X)\), \(Q\in \mathcal {K}_{q}(Y)\),

$${P}^{\star} {\times }{Q}^{\star} = {(P {\times }Q)}^{\star}. $$

Algebraic properties of the cubical product on cubical chains derived in [15, Sect. 2.2] readily extend to the cross product on cochains, in particular the following.

Proposition 2.6

If c p×c qC p+q(X), then

$$\delta \bigl(c^p {\times }c^q\bigr)=\delta c^p {\times }c^q + (-1)^p c^p \times \delta c^q. $$

2.2 Constructing Chain Maps

The most important step towards an explicit formula for the cup product is the construction of a homology chain map \(\operatorname {diag}_{\#}:\mathcal {C}(X)\to \mathcal {C}(X\times X)\) induced by the diagonal map \(\operatorname {diag}: X \to X\times X\) given by \(\operatorname {diag}(x):=(x,x)\). This is done using the construction presented in [15, Chap. 6]. We briefly outline that construction.

Given an elementary cube Q=I 1×I 2×⋯×I d , the corresponding elementary cell \(\stackrel{\circ}{Q}\) is Q with all its proper faces removed. Given cubical sets X and Y, a multivalued cubical map \(F :X{\,\overrightarrow {\to }\,}Y\) is a map from X to the set of subsets of Y such that

  1. (i)

    for every xX, F(x) is a cubical set;

  2. (ii)

    for every \(Q\in \mathcal {K}(X)\), \(F\mid_{\stackrel{\circ}{Q}}\) is constant.

The Chain Selector Theorem [15, Theorem 6.22] affirms that, if such a map is lower semicontinuous and has non-empty acyclic values (that is, \(\tilde{H}_{*}(F(x))=0\) for all xX), then it admits a chain selector, that is, a chain map \(\varphi:\mathcal {C}(X)\to \mathcal {C}(Y)\) with the properties

  1. 1.

    \(|{\varphi(Q)}| \subset F(\stackrel{\circ}{Q})\) for all \(Q \in \mathcal {K}(X)\);

  2. 2.

    φ(Q) is a vertex of F(Q) for any vertex \(Q \in \mathcal {K}_{0}(X)\).

Any two such chain selectors are chain homotopic [15, Theorem 6.25], so they give rise to the same map in homology. If a continuous map f:XY admits an acyclic-valued representation, that is, a lower semicontinuous cubical map F with the property f(x)∈F(x), the homology map of any chain selector φ of F is the map H (f) induced in homology by f [15, Proposition 6.56]. The idea behind this construction is illustrated in Fig. 1.

Fig. 1
figure 1

The graph of a continuous map f on an interval (displayed by a smooth curve), its representation F (displayed by shaded rectangles), and a symbolic display of a chain selector: The circles indicate pairs of vertices ([v],φ 0([v])) while the line segments connecting them can be used to localize, on the ordinate, the images of the corresponding edges under the chain map φ 1

In general, computing a map induced in homology may be hard, because an acyclic-valued representation may not always exist and one has to apply a process of rescaling [15, Sect. 6.4.2]. However, for the purpose of this paper, we do not need rescaling, because all considered maps admit the acyclic-valued minimal representations. Recall from [15, Proposition 6.33 and Definition 6.34] that the minimal representation of a continuous map f:XY is a lower semicontinuous cubical map \(F:X{\,\overrightarrow {\to }\,}Y\) defined by

$$F(x)=\mathrm{ch}\bigl(f\bigl(\mathrm{ch}(x)\bigr)\bigr), $$

where, given any set AX, the closed hull ch(A) is the smallest cubical set containing A. In the case A={x}, the set ch({x}) is an elementary cube denoted, for short, by ch(x). In the case of our diagonal map \(\operatorname {diag}: X \to X\times X\), its minimal representation \(\operatorname {\mathit {Diag}}:X {\,\overrightarrow {\to }\,}(X\times X)\) is given by

$$ \operatorname {\mathit {Diag}}(x):=Q\times Q, \quad \mbox{where } Q=\mathrm{ch}(x)\in \mathcal {K}(X). $$
(4)

Obviously, Q×Q is acyclic.

Given any maps f:X 1Y 1 and g:X 2Y 2 on cubical sets, we define f×g:X 1×X 2Y 1×Y 2 by (f×g)(x 1,x 2):=(f(x 1),g(x 2)). Given \(F_{i}: X_{i} {\,\overrightarrow {\to }\,}Y_{i}\) for i=1,2, we define \(F_{1} \times F_{2}: X_{1}\times X_{2} {\,\overrightarrow {\to }\,}Y_{1}\times Y_{2}\) by (F 1×F 2)(x,y):=F 1(xF 2(y).

Given chain maps \(\varphi:\mathcal {C}(X_{1})\to \mathcal {C}(Y_{1})\) and \(\psi:\mathcal {C}(X_{2})\to \mathcal {C}(Y_{2})\), their cubical tensor product \(\varphi \otimes \psi:\mathcal {C}(X_{1}\times X_{2})\to \mathcal {C}(Y_{1}\times Y_{2})\) is defined on generators \({Q}={Q}_{1}{\times }{Q}_{2}\in {\mathcal {K}}_{k}(X_{1}\times X_{2})\) as follows. Set p:=dimQ 1 and q:=dimQ 2. Note that p+q=k. Put

$$ (\varphi \otimes \psi)_k (Q):= \varphi_p({Q}_1) {\times }\psi_q({Q}_2), $$
(5)

where the right-hand side is the cubical cross product of chains defined in Sect. 2.1.

Lemma 2.7

Let X 1,X 2,Y 1,Y 2 be cubical sets and let f:X 1Y 1, g:X 2Y 2 be continuous maps which admit acyclic-valued representations F, G. Let φ and ψ be the chain selectors of F and, respectively, G.

  1. (a)

    The set-valued map F×G is an acyclic-valued cubical representation of f×g.

  2. (b)

    The chain map φψ is a chain selector of F×G.

Proof

The statement in (a) is straightforward because the product of acyclic sets is acyclic. To prove (b), we show first that φψ is a chain map. Given any \(Q=Q_{1}\times Q_{2}\in \mathcal {K}_{k}(X_{1}\times X_{2})\), we have, for p=dimQ 1, q=dimQ 2,

It remains to check the chain selector conditions (6.12), (6.13) in [15, Theorem 6.22]. First, we have

$$\big|(\varphi \otimes \psi)_k(Q)\big| = \big|\varphi_p({Q}_1)\big| \times \big|\psi_q({Q}_2)\big| \subset F(Q_1)\times G(Q_2). $$

Finally, for any vertex \(V=V_{1}\times V_{2} \in \mathcal {K}_{0}(X_{1} \times X_{2})\), W 1:=φ(V 1) and W 2:=ψ(V 2) are vertices, hence

$$(\varphi \otimes \psi)_0(V)= {W}_1 \times {W}_2\in {\mathcal {K}}_0(X). $$

 □

The following statement easily follows from the definitions.

Proposition 2.8

Let X 1R n and X 2⊂ℝdn be the images of a cubical set X⊂ℝd under its projections onto, respectively, the first n and the complementary dn coordinates ind. Consider the inclusion map j:XX 1×X 2. Then

  1. (a)

    The map \(J: X {\,\overrightarrow {\to }\,}X_{1} \times X_{2}\) given by J(x):=ch(x) is an acyclic-valued cubical representation of j;

  2. (b)

    The inclusion of chain complexes \(\iota: \mathcal {C}(X)\hookrightarrow \mathcal {C}(X_{1} \times X_{2})\) is a chain selector of J.

Theorem 2.9

Let X,Y be cubical sets and let λ:X×YY×X be the transpose given by λ(x,y):=(y,x).

  1. (a)

    The map \(\varLambda: X\times Y {\,\overrightarrow {\to }\,}Y\times X\) given by Λ(x,y):=Q 2×Q 1, where Q 1:=ch(x) and Q 2:=ch(y), is an acyclic-valued cubical representation of λ.

  2. (b)

    Let \(\lambda_{\#}: \mathcal {C}(X \times Y)\to C(Y \times X)\) be the map defined on generators \({Q}={Q}_{1}{\times }{Q}_{2}\in {\mathcal {K}}_{k}(X \times Y)\) by

    $$\lambda_k (Q):=(-1)^{\dim Q_1 \dim Q_2} {Q}_2 {\times }{Q}_1. $$

    Then λ # is a chain selector of Λ.

Proof

The statement (a) is a simple check of the definitions. For (b), the conditions (6.12), (6.13) in [15, Theorem 6.22] follow immediately from the definitions, so it remains to check that λ # is a chain map, that is, it commutes with the boundary map. Let \(Q=Q_{1}{\times }Q_{2}\in {\mathcal {K}}_{k}(X \times Y)\). On the one hand, we have

On the other hand, we have

Hence \({\bf \partial }\lambda_{k}(Q)=\lambda_{k-1} ({\bf \partial }{Q})\). □

From Proposition 2.8 and Theorem 2.9 we derive the following corollary.

Corollary 2.10

Let X 1,X 2,Y 1,Y 2 be cubical sets and consider the permutation

$$\tau: (X_1 \times Y_1) \times (X_2 \times Y_2) \to (X_1 \times X_2) \times (Y_1 \times Y_2) $$

given by τ(x 1,y 1,x 2,y 2)=(x 1,x 2,y 1,y 2). Then the map given by T(x):=τ(ch(x)) is an acyclic-valued representation of τ. It has the map

$$\tau_\#: \mathcal {C}( X_1 \times Y_1 \times X_2 \times Y_2) \to \mathcal {C}(X_1 \times X_2 \times Y_1 \times Y_2) $$

defined on products of \(P_{1}\in \mathcal {K}(X_{1})\), \(P_{2}\in \mathcal {K}(Y_{1})\), \(Q_{1}\in \mathcal {K}(X_{2})\), and \(Q_{2}\in \mathcal {K}(Y_{1})\) by

$$\tau_\# \bigl( (P_1 {\times }P_2) {\times }(Q_1 {\times }Q_2) \bigr) := (-1)^{\dim P_2 \dim Q_1} (P_1 {\times }Q_1 ) {\times }(P_2 {\times }Q_2 ) $$

as a chain selector.

Here are dual statements of Theorem 2.9 and Corollary 2.10 for cochains.

Corollary 2.11

Let λ:X×YY×X be the transpose defined in Theorem 2.9. Then the induced cochain map \(\lambda^{\#}:=\mathrm{Hom}(\lambda_{\#}):\mathcal {C}^{*}(Y\times X)\to \mathcal {C}^{*}(X\times Y)\) satisfies

$$\lambda^{p+q}\bigl(c^q {\times }c^p \bigr)=(-1)^{pq}c^p {\times }c^q. $$

Proof

Let \(P\in \mathcal {K}(X)\) and \(Q\in \mathcal {K}(Y)\). If dimP=p and dimQ=q, then

If dimPp or dimQq, then both sides vanish. □

Corollary 2.12

Let τ:(X 1×Y 1)×(X 2×Y 2)→(X 1×X 2)×(Y 1×Y 2) be the permutation discussed in Corollary 2.10. The map

$$\tau^\#:=\mathrm{Hom}(\tau_\#):\mathcal {C}^*(X_1 \times X_2 \times Y_1 \times Y_2)\to \mathcal {C}^*( X_1 \times Y_1 \times X_2 \times Y_2) $$

induced by τ # is given on products of duals of \(P_{1}\in \mathcal {K}(X_{1})\), \(P_{2}\in \mathcal {K}(Y_{1})\), \(Q_{1}\in \mathcal {K}(X_{2})\), and \(Q_{2}\in \mathcal {K}(Y_{1})\) by the formula

$$\tau^\# \bigl( \bigl({P}^{\star}_1 {\times }{P}^{\star}_2\bigr) {\times }\bigl( {Q}^{\star}_1 {\times }{Q}^{\star}_2\bigr) \bigr) = (-1)^{\dim P_2 \dim Q_1} \bigl( {P}^{\star}_1 {\times }{Q}^{\star}_1 \bigr) {\times }\bigl({P}^{\star}_2 {\times }{Q}^{\star}_2 \bigr). $$

Let X⊂ℝd be a cubical set. We proceed to the construction of a homology-representative chain map \(\operatorname {diag}_{\#}:\mathcal {C}(X)\to \mathcal {C}(X\times X)\) induced by the diagonal map. It is straightforward to see that the diagonal map admits an acyclic-valued representation \(\operatorname {\mathit {Diag}}:X {\,\overrightarrow {\to }\,}(X\times X)\) given by \(\operatorname {\mathit {Diag}}(x):=Q\times Q\) where \(Q=\mathrm{ch}(x)\in \mathcal {K}(X)\). The construction of a chain selector proceeds by induction on \(d=\operatorname {emb}X\).

Case d=1: If \(Q=[v]\in \mathcal {K}_{0}(X)\), we put

$$ \operatorname {diag}_0\bigl({[v]}\bigr):={[v]} {\times }{[v]}. $$
(6)

If \(Q=[v_{0},v_{1}]\in \mathcal {K}_{1}(X)\), we put

$$ \operatorname {diag}_1\bigl({[v_0,v_1]} \bigr):={[v_0]} {\times }{[v_0,v_1]}+{[v_0,v_1]} {\times }{[v_1]}. $$
(7)

For k∉{0,1}, we must have \(\operatorname {diag}_{k}=0\).

The formula (7) is illustrated in Fig. 2. In order to show that our formula defines a chain map we are looking for, we need to make two observations.

Fig. 2
figure 2

Illustration of two choices of chain maps induced by the diagonal map in dimension one. The path “up and right” shows the one defined in (7), while the path “right and up” shows the one in (8)

Lemma 2.13

Let emb X=1. The map \(\operatorname {diag}_{\#}\) defined by (6) and (7) is a chain selector for \(\operatorname {\mathit {Diag}}\).

Proof

The conditions [15, Theorem 6.22, (6.12), (6.13)] follow immediately from the definitions, so it remains to check that \(\operatorname {diag}_{\#}\) is a chain map. Since \({\bf \partial }_{0}=0\) and d=1, it is enough to check that \({\bf \partial }_{1}\operatorname {diag}_{1}=\operatorname {diag}_{0}{\bf \partial }_{1}\). Let \(Q=[v_{0},v_{1}]\in \mathcal {K}_{1}(X)\). On the one hand,

On the other hand,

hence the conclusion follows. □

Remark 2.14

The formula

$$ \operatorname {diag}_1^-\bigl({[v_0,v_1]} \bigr):= {[v_0,v_1]} {\times }[v_0]+[v_1] {\times }[v_0,v_1] $$
(8)

leads to a different chain selector of \(\operatorname {\mathit {Diag}}\) and a different definition of a cup product on cochains. Note that the two choices are homologous since

$$\operatorname {diag}_1\bigl({[v_0,v_1]}\bigr)- \operatorname {diag}_1^-\bigl({[v_0,v_1]}\bigr)={\bf \partial }\bigl([v_0,v_1]\times [v_0,v_1] \bigr) $$

These ideas are shown in Fig. 2.

Induction Step

Suppose that \(\operatorname {diag}_{\#}\) is defined for cubical sets of embedding numbers n=1,…,d−1 and let us construct it for a cubical set X of the embedding number d.

Note that

where τ:ℝ2d→ℝ2d is the permutation of coordinates which transposes the (d+1)st coordinate with the preceding d−1 coordinates. The formula for the chain maps induced by τ is provided by Corollary 2.10.

Consider the images X 1⊂ℝ and X 2⊂ℝd−1 of X under its projections of, respectively, the first and the complementary d−1 coordinates in ℝd. Let \(\operatorname {diag}^{X_{1}}\) and \(\operatorname {diag}^{X_{2}}\) be the diagonal maps defined, respectively, on X 1 and X 2. Then the diagonal map on X is the composition

$$ \operatorname {diag}= \tau \circ \bigl(\operatorname {diag}^{X_1} \times \operatorname {diag}^{X_2}\bigr) \circ j, $$
(9)

where j is the inclusion map discussed in Proposition 2.8. Note that τ takes values in X 1×X 2×X 1×X 2X×X but the composition of maps on the right-hand side of (9) takes values in X×X.

Lemma 2.15

Let d=emb X>1. Assume that the chain selector \(\operatorname {diag}_{\#}\) of \(\operatorname {\mathit {Diag}}\) is defined for cubical sets of embedding numbers less than d. Consider the chain map \(\varphi:\mathcal {C}(X)\to \mathcal {C}(X_{1}\times X_{2}\times X_{1}\times X_{2})\) defined by the formula

$$ \varphi := \tau_\# \circ \bigl( \operatorname {diag}^{X_1}_\#\otimes \operatorname {diag}^{X_2}_\#\bigr) \circ \iota, $$
(10)

where

  1. 1.

    \(\iota: \mathcal {C}(X)\to \mathcal {C}(X_{1}\times X_{2})\) is the inclusion of chain complexes,

  2. 2.

    \(\operatorname {diag}^{X_{1}}_{\#}:\mathcal {C}(X_{1})\to \mathcal {C}(X_{1}\times X_{1})\) and \(\operatorname {diag}^{X_{2}}_{\#}:\mathcal {C}(X_{2})\to \mathcal {C}(X_{2}\times X_{2})\) are defined by the induction hypothesis,

  3. 3.

    \(\operatorname {diag}^{X_{1}}_{\#}\otimes \operatorname {diag}^{X_{2}}_{\#}:\mathcal {C}(X_{1}\times X_{2})\to \mathcal {C}(X_{1}\times X_{1}\times X_{2}\times X_{2})\) is defined by formula (5), and

  4. 4.

    \(\tau_{\#}:\mathcal {C}(X_{1}\times X_{1}\times X_{2}\times X_{2})\to \mathcal {C}(X_{1}\times X_{2}\times X_{1}\times X_{2})\) is defined in Corollary 2.10.

Then φ takes values in \(\mathcal {C}(X \times X)\subset \mathcal {C}(X_{1}\times X_{2}\times X_{1}\times X_{2})\). Moreover, the map \(\operatorname {diag}_{\#}:\mathcal {C}(X)\to \mathcal {C}(X \times X)\), \(\operatorname {diag}_{k}(c):=\varphi_{k}(c)\), for cC k (X), k∈ℤ, is a chain selector of \(\operatorname {\mathit {Diag}}\).

Proof

We first check that the composition of the minimal representations of the maps involved in formula (9) and described in the series of preceding lemmas produces formula (4) for Diag. This implies, in particular, that the composition has acyclic values contained in X×X. Let x=(x 1,x 2)∈X, with x i X i , and \(Q=Q_{1}\times Q_{2}=\mathrm{ch}(x)\in \mathcal {K}(X)\), with \(Q_{i}\in \mathcal {K}(X_{i})\), i=1,2. It is easy to check that ch(x 1)=Q 1 and ch(x 2)=Q 2. By Proposition 2.8(a), J(x)=Q 1×Q 2=Q. Given any yQ, we have ch(y)⊂Q and the equality holds when \(y\in \stackrel{\circ}{Q}\). Let y=(y 1,y 2)∈Q 1×Q 2. We have

$$\mathit{Diag}^{X_i}(y_i)=\mathrm{ch}(y_i)\times \mathrm{ch}(y_i)\subset Q_i\times Q_i,\quad i=1,2, $$

and the inclusion becomes equality when \(y\in \stackrel{\circ}{Q}\). Thus, by Lemma 2.7(a), we have the inclusion

$$\bigl(\mathit{Diag}^{X_1}\times \mathit{Diag}^{X_2} \bigr) (y)\subset Q_1\times Q_1\times Q_2\times Q_2, $$

and the two sets are equal when \(y\in \stackrel{\circ}{Q}\). From this, we get

Using Corollary 2.10 and arguing as above, we get

Hence the map Diag is equal to \(T\circ \mathit{Diag}^{X_{1}}\times \mathit{Diag}^{X_{2}}\circ J\) with the range restricted to the image X×X. It follows that the composition of the corresponding chain selectors has the image in \(\mathcal {C}(X\times X)\). Finally, it follows from [15, Corollary 6.31] that this composition is a chain selector for Diag. □

2.3 The Cubical Cup Product

Definition 2.16

Let X be a cubical set. The cubical cup product

$$\smile : C^p(X)\times C^q(X) \to C^{p+q}(X) $$

of cochains c p and c q is defined by the formula

$$c^p\smile c^q=\operatorname {diag}^{^{p+q}}\bigl(c^p {\times }c^q\bigr). $$

In particular, for \({Q}\in{ \mathcal {K}}_{p+q}(X)\)

$$ \big\langle c^p\smile c^q , Q \big\rangle =\big\langle c^p {\times }c^q , \operatorname {diag}_{p+q}(Q) \big\rangle . $$
(11)

The distributive law for the cup product on cochains

$$ \bigl(c^p + d^p\bigr) \smile c^q = \bigl(c^p\smile c^q\bigr) + \bigl(d^p \smile c^q\bigr) $$
(12)

follows immediately from Definition 2.16, the linearity of \(\operatorname {diag}_{p+q}\), and the distributive law for the cross product. The proof of the associativity law and the identification of the unit element will be easier once we have established an explicit formula for the cup product. Definition 2.16 is also suitable for proving the boundary properties, and the graded commutative law:

Theorem 2.17

(Boundary Properties of the Cup Product)

  1. (a)

    δ(c pc q)=δc pc q+(−1)p c pδc q.

  2. (b)

    If z pZ p(X) and z qZ q(X), then z pz qZ p+q(X).

  3. (c)

    If x p,y pZ p(X), x py pB p(X), and z qZ q(X), then

    $$\bigl(x^p\smile z^q\bigr) - \bigl(y^p\smile z^q\bigr) \in B^{p+q}(X) \quad \mbox{and}\quad \bigl(z^q \smile x^p\bigr)-\bigl(z^q \smile y^p\bigr) \in B^{p+q}(X). $$

Proof

(a) Let \(Q\in \mathcal {K}_{k}(X)\), where k=p+q+1.

(b) is an immediate consequence of (a).

(c) Let x py p=δw. It follows from (a) that

$$\bigl(x^p-y^p\bigr)\smile z^q = \delta w \smile z^q = \delta \bigl(w \smile z^q\bigr) $$

because δz q=0. Hence x pz qy pz qB p+q(X). The second equation follows by the same argument. □

The property (a) in Theorem 2.17 is the analogy of the boundary property of the cubical cross product defined in [15, Sect. 2.2]. The property (b) asserts that the cup product sends cocycles to cocycles, and by (c) that it does not depend on a representative of a cohomology class. Thus, we get the definition:

Definition 2.18

The cup product ⌣:H p(XH q(X)→H p+q(X) is defined on cohomology classes of cocycles as follows:

$$ \bigl[z^p\bigr]\smile \bigl[z^q \bigr]:=\bigl[z^p\smile z^q\bigr]. $$
(13)

The distributive law (12) extends easily to cohomology classes. The following property holds only for cohomology classes.

Theorem 2.19

(Graded Commutative Law)

If z p and z q are cocycles, then

$$\bigl[z^q\bigr] \smile \bigl[z^p\bigr] = (-1)^{pq} \bigl[z^p \smile z^q\bigr]. $$

Proof

Let λ be the transpose defined in Theorem 2.9, applied for X=Y. Let \(Q\in \mathcal {K}(X)\). On the one hand, we have

$$\big\langle z^p \smile z^q , Q \big\rangle = \big\langle z^p {\times }z^q , \operatorname {diag}_{p+q}(Q) \big\rangle . $$

On the other hand, from Corollary 2.11,

Note that \(\lambda \circ \operatorname {diag}= \operatorname {diag}\) on X. The corresponding chain maps \(\psi_{\#}=\lambda_{\#}\circ \operatorname {diag}_{\#}\) and \(\varphi_{\#}=\operatorname {diag}_{\#}\) are both chain selectors for Diag. By [15, Theorem 6.25], they are chain homotopic. This implies that the associated cochain maps ψ # and φ # are cochain homotopic (see the definition preceding Theorem 44.1 in [23]), hence they induce the same homomorphism in cohomology. Thus, we get

We can now derive an explicit formula, suitable for computations, for the cubical cup product on cochains. By the distributive law (12), it is sufficient to present a formula for generators \({P}^{\star}\in {\mathcal {K}}^{p}(X)\) and \({Q}^{\star}\in {\mathcal {K}}^{q}(X)\). The formula is developed recursively with respect to d=emb X and presented in three stages, the first one for the case d=1, the second one for the recursion step, and the last one is the final recursion-free coordinate-wise formula. □

Theorem 2.20

Let X be a cubical set inand let \(P,Q \in \mathcal {K}(X)\), P=[a,b], Q=[c,d] be elementary intervals, possibly degenerate. Then

$${P}^{\star}\smile {Q}^{\star}=\left \{ \begin{array}{l@{\quad}l} {[a]}^{\star} & \mbox{\textit{if} } a=b=c=d, \\[3pt] {[c,d]}^{\star} & \mbox{\textit{if} } a=b=c=d-1, \\[3pt] {[a,b]}^{\star} & \mbox{\textit{if} } b=c=d=a+1, \\[3pt] 0 & \mbox{\textit{otherwise}.} \end{array} \right . $$

In particular, P Q is either zero, or a dual of an elementary interval.

Proof

Let p=dimP and q=dimQ. Then p,q∈{0,1}. Let k:=p+q. Consider first the case k=0. Let \(R=[v]\in \mathcal {K}_{0}(X)\). Then

When k=p+q=1, let \(R=[v_{0},v_{1}]\in \mathcal {K}_{1}(X)\). Then

Finally, when k=p+q=2, we have P Q =0, because emb(X)=1 and C 2(X)=0.

We reach the conclusion by expressing the values in terms of elementary intervals [a,b], [c,d]. □

Example 2.21

Since [a]⌣[a,a+1]=[a,a+1] and [a,a+1]⌣[a]=0, we see that the graded commutative law in Theorem 2.19 does not hold for the cup product on the level of chain complexes.

Theorem 2.22

Let \(\operatorname {emb}X=d>1\), and suppose that the formula foris given for cochains on cubical sets of embedding numbers n=1,…,d−1. Consider the decomposition of elementary cubes \(P=P_{1}\times P_{2}\in \mathcal {K}_{p}(X)\) and \(Q=Q_{1}\times Q_{2} \in \mathcal {K}_{q}(X)\) with emb P 1=emb Q 1=1 and emb P 2=emb Q 2=d−1. Let \(x={P}^{\star}_{1}\smile {Q}^{\star}_{1}\) and \(y={P}^{\star}_{2}\smile {Q}^{\star}_{2}\) be computed using the induction hypothesis. Then

$${P}^{\star}\smile {Q}^{\star} = \left \{ \begin{array}{l@{\quad}l} (-1)^{\dim P_2\dim Q_1}\; x {\times }y & \mbox{\textit{if} } |x {\times }y| \in \mathcal {K}(X),\\[3pt] 0 & \mbox{\textit{otherwise}.} \end{array} \right . $$

Proof

Consider a generator \(R=R_{1}\times R_{2}\in \mathcal {K}_{k}(X)\), where \(\operatorname {emb}\ R_{1}=1\) and \(\operatorname {emb}\ R_{2}=d-1\). Let p=dimR 1 and q=dimR 2. Note that p+q=k. By Lemma 2.15 we get

Since π k is a projection, its dual map π k is an injection which extends any element of \({ \mathcal {C}}^{\star}(X\times X)\) as zero on elementary cubes in \(\mathcal {K}(X_{1}\times X_{2} \times X_{1}\times X_{2})\setminus \mathcal {K}(X\times X)\). Set \(\sigma=(-1)^{\dim P_{2}\dim Q_{1}}\). By Proposition 2.8, Corollary 2.12 and Lemma 2.7, we get

with a non-trivial value assumed if and only if |x|=R 1 and |y|=R 2. However, \(R\in \mathcal {K}(X)\) and the conclusion follows. □

The following example illustrates the need for considering the alternative \(|x {\times }y| \notin \mathcal {K}(X)\) in the formula for P Q in Theorem 2.22.

Example 2.23

Let X=[0,1]2, P=[0]×[0,1], and Q=[0,1]×[0]. We get

$${P}^{\star}\smile {Q}^{\star}=(-1)^{1\cdot 1} \bigl({[0]}^{\star}\smile {[0,1]}^{\star} \bigr) {\times }\bigl({[0,1]}^{\star}\smile {[1]}^{\star} \bigr)=-{[0,1]^2}^{\star}. $$

However, if X=PQ, we get P Q =0.

We now pass to a coordinate-wise formula. Let P and Q be as in Theorem 2.22. Consider their decompositions to products of intervals in ℝ:

$$P=I_1\times I_2 \times \cdots \times I_d \quad \mbox{and}\quad Q=J_1\times J_2 \times \cdots \times J_d. $$

Let \(P_{j}':=I_{j+1}\times I_{j+2} \times \cdots \times I_{d}\). Put

$$\mathrm{sgn}(P,Q):=(-1)^{\sum_{j=1}^{d-1} \dim P_j' \dim J_j}=(-1)^{\sum_{j=1}^{d-1} (\dim J_j \sum_{i=j+1}^d \dim I_i )}. $$

We get the following.

Theorem 2.24

Let d=emb(X)>1. With the above notation for elementary cubes \(P,Q\in \mathcal {K}(X)\),

$$ {P}^{\star}\smile {Q}^{\star} = \mathrm{sgn}(P,Q) \bigl( {I}^{\star}_1\smile {J}^{\star}_1\bigr) {\times }\bigl({I}^{\star}_2 \smile {J}^{\star}_2\bigr) {\times }\cdots {\times }\bigl({I}^{\star}_d\smile {J}^{\star}_d\bigr), $$
(14)

provided the right-hand side is supported in X, and P Q =0 otherwise.

Proof

We derive the formula from Theorem 2.22 by induction on the embedding number d>1.

When d=2, we have \(\operatorname {sgn}(P,Q)= (-1)^{\dim P_{1}' \dim J_{1}}\), so the formula is exactly the one in Theorem 2.22 with P 1=I 1, \(P_{2}=P_{1}'=I_{2}\), and Q j =J j , j=1,2.

Let d>2. We apply Theorem 2.22 with P 1=I 1, \(P_{2}=P_{1}'\), Q 1=J 1, and \(Q_{2}=Q_{1}'\). Note that the support of the cross product on the right-hand side of (14) is the cartesian product of the supports of the terms:

$$\Biggl \vert \prod_{j=1}^d {I}^{\star}_j\smile {J}^{\star}_j \Biggr \vert =\big \vert {I}^{\star}_1\smile {J}^{\star}_1\big \vert \times \Biggl \vert \prod _{j=2}^d {I}^{\star}_j\smile {J}^{\star}_j \Biggr \vert . $$

Therefore, the support of the right-hand side of (14) is non-empty and contained in X if and only if one of x×y in Theorem 2.22 is non-empty and contained in X. If this is not the case, both formulas give the cochain 0. Assume the non-trivial case. Then the support of \({P_{1}'}^{\star}\smile {Q_{1}'}^{\star}\) is non-empty and contained in X 2. By induction hypothesis,

$${P_1'}^{\star}\smile {Q'}^{\star} = \operatorname {sgn}\bigl(P_1',Q_1'\bigr) \bigl( {I}^{\star}_2\smile {J}^{\star}_2\bigr) {\times }\cdots {\times }\bigl( {I}^{\star}_d\smile {J}^{\star}_d\bigr), $$

where

$$\mathrm{sgn}\bigl(P_1',Q_1' \bigr)=(-1)^{\sum_{j=2}^{d-1} \dim P_j' \dim J_j}. $$

By Theorem 2.22,

$${P}^{\star}\smile {Q}^{\star} = (-1)^{\dim P_1' \dim J_1} \bigl({I}^{\star}_1\quad I^{\star}_1\smile {J}^{\star}_1\bigr) {\times }\bigl({P_1'}^{\star}\smile Q^{\prime\star}\bigr). $$

Since \((-1)^{\dim P_{1}' \dim J_{1}}\operatorname {sgn}(P_{1}',Q_{1}')=\operatorname {sgn}(P,Q)\), the conclusion follows. □

Let X be a cubical set embedded in ℝd. We define the weight of a cochain c p in X by

$$w\bigl(c^p\bigr):=\mathrm{card}\bigl\{{Q\in \mathcal {K}(X)\mid \big\langle c^p , Q \big\rangle \neq 0}\bigr\} . $$

By bilinearity, the computation of c pc q for two cochains c p, c q in X reduces to finding w(c p)w(c q) cup products of generating elementary cubes. Since it follows easily from Theorem 2.24 that the cost of finding the cup product of two generating elementary cubes is O(d 2), we obtain the following.

Corollary 2.25

The computational complexity of evaluating c pc q is O(d 2 mn) where m is the weight of c p and n is the weight of c q.

Example 2.26

We illustrate the cup-product formula for the cubical torus T:=Γ 1×Γ 1⊂ℝ4, where \(\varGamma^{1}={\bf \partial }[0,1]^{2}\) is the boundary of the square. Since it is hard to draw pictures in ℝ4, we parameterize Γ 1 by the interval [0,4] with identified endpoints 0∼4, which permits visualizing T as the square [0,4]2 with pairs of identified boundary edges, as shown in Fig. 3.

Fig. 3
figure 3

The graphical representation of the cubical torus discussed in Example 2.26. The solid line vertical edges carry the cocycle x 1 and the horizontal ones the cocycle y 1. The shaded square carries x 1y 1

Consider the cocycle x 1 generated by the sum of four solid line vertical edges with [2,3] at the second coordinate, and y 1 by the sum of solid line horizontal edges with [1,2] at the first coordinate. Only the edges of the parametric square [1,2]×[2,3] may contribute to non-zero terms of x 1y 1. Thus, using Theorem 2.20 and Theorem 2.24,

The cohomology classes of cochains x 1 and y 1 generate H 1(T), and [Q ], where Q:=([1,2]×[2,3]), generates H 2(T).

We are now ready to prove the remaining ring properties for the cubical cup product.

Theorem 2.27

Let X be a cubical set. The cup product on cubical cochains is associative, that is,

$$\bigl(c^p \smile c^q\bigr) \smile c^r = c^p\smile \bigl(c^q \smile c^r\bigr). $$

The cochain given by \(1_{C_{0}(X)}:=\sum_{V\in \mathcal {K}_{0}(X)}{V}^{\star}\) is the unit element, that is,

$$1_{C_0(X)} \smile c^p = c^p \smile 1_{C_0(X)} = c^p. $$

A fortiori, these formulas are valid for cohomology classes.

Proof

By the distributive law (12), it is sufficient to work with generators \({P}^{\star}\in {\mathcal {K}}^{p}(X)\), \({Q}^{\star}\in {\mathcal {K}}^{q}(X)\), and \({R}^{\star}\in {\mathcal {K}}^{r}(X)\). Let \(d=\operatorname {emb}(X)\).

The unit element property easily follows from Theorem 2.20 in the case d=1 and from Theorem 2.24 in the case d>1.

We prove the associativity by induction on d. When d=1, a routine verification of the formula in Theorem 2.20 shows that (P Q )⌣R ≠0 if and only if there exists a∈ℤ such that the triple (P,Q,R) takes one of the forms

In the first case (P Q )⌣R =[a] and in the remaining cases it is [a,a+1]. The same is verified for P ⌣(Q R ).

Let now d>1 and suppose the conclusion is true for the embedding numbers smaller than d. Write P=P 1×P 2, Q=Q 1×Q 2, and R=R 1×R 2, where the first component of each elementary cube is in ℝ and the second one in ℝd−1. Using Theorem 2.20 and Theorem 2.22, we prove that

$$ \bigl({P}^{\star} \smile {Q}^{\star}\bigr) \smile {R}^{\star} = (-1)^\alpha \bigl[\bigl\{\bigl({P_1}^{\star}\smile {Q_1}^{\star}\bigr)\smile {R_1}^{\star} \bigr\} {\times }\bigl\{\bigl( {P_2}^{\star}\smile {Q_2}^{\star}\bigr)\smile {R_2}^{\star}\bigr\} \bigr] $$
(15)

where

$$ \alpha:=\dim P_2 \dim Q_1 + \dim\big| {P_2}^{\star} \smile {Q_2}^{\star}\big|\dim R_1, $$
(16)

provided the displayed cross product is non-trivial and supported in X, and it is 0 otherwise.

Indeed, assume the non-trivial case. The first application of Theorem 2.22 gives

$$ {P}^{\star} \smile {Q}^{\star}=(-1)^{\dim P_2 \dim Q_1} \bigl({P_1}^{\star} \smile {Q_1}^{\star}\bigr) {\times }\bigl({P_2}^{\star}\smile {Q_2}^{\star}\bigr). $$
(17)

By Theorem 2.20, P 1 Q 1 =S 1 , where \(S_{1}\in \mathcal {K}(X_{1})\) is equal either to P 1 or to Q 1. By Theorem 2.22, P 2 Q 2 =(−1)γ S 2 , for some γ∈ℤ and \(S_{2}\in \mathcal {K}(X_{2})\). Let S=S 1×S 2. By hypothesis, \(S\in \mathcal {K}(X)\). Hence (17) can be written as

$$ {P}^{\star} \smile {Q}^{\star}=(-1)^{\dim P_2 \dim Q_1 + \gamma} {S}^{\star}. $$
(18)

Another application of Theorem 2.22 gives

$$ {S}^{\star} \smile {R}^{\star}=(-1)^{\dim S_2 \dim R_1} \bigl({S_1}^{\star} \smile {R_1}^{\star}\bigr) {\times }\bigl({S_2}^{\star}\smile {R_2}^{\star}\bigr). $$
(19)

We obtain (15) by combining (18) with (19) and passing (−1)γ inside the cross product term containing S 2 . Analogously,

$$ {P}^{\star} \smile \bigl({Q}^{\star} \smile {R}^{\star}\bigr) = (-1)^\beta \bigl[\bigl\{{P_1}^{\star}\smile \bigl({Q_1}^{\star} \smile {R_1}^{\star}\bigr) \bigr\} {\times }\bigl\{{P_2}^{\star}\smile \bigl( {Q_2}^{\star}\smile {R_2}^{\star}\bigr)\bigr\}\bigr] $$
(20)

where

$$ \beta:= \dim P_2 \dim \big| {Q_1}^{\star} \smile {R_1}^{\star}\big| + \dim Q_2 \dim R_1, $$
(21)

with the same condition on the support. By the induction hypothesis, the expressions inside the square brackets in equations (15) and (20) are equal. In particular their supports are equal, so we may assume that both supports are non-empty and contained in X. It remains to show that (−1)α=(−1)β. By Definition 2.16,

$$\dim\big|{P_2}^{\star} \smile {Q_2}^{\star}\big|=\dim P_2 + \dim Q_2 \quad \mbox{and}\quad \dim \big| {Q_1}^{\star} \smile {R_1}^{\star}\big| = \dim Q_1 + \dim R_1; $$

hence the conclusion follows.

By Definition 2.18, the last statement on extension to the cohomology classes is obvious. □

The algebraic properties listed in (12), Theorem 2.27 and in Theorem 2.19 are referred to as the graded ring properties. Thus we arrived at the key definition:

Definition 2.28

Let X be a cubical set. The cubical cohomology ring of X is the graded abelian group H (X) with the graded multiplication given by the cup product.

It is known that the ring structure introduced in Definition 2.28 may be used to distinguish non homeomorphic spaces even if their homology and cohomology groups are isomorphic. This is shown in the example presented in Sect. 3.5.

Remark 2.29

All what we have done until now can be extended to chain complexes \(\mathcal {C}(X;R):=\mathcal {C}(X)\otimes R\) with coefficients in a ring with unity R, which are graded modules over R. This gives rise to the cohomology ring H (X;R). We have initially chosen coefficients in ℤ for the sake of clarity and, in particular, to avoid confusion between two rings, R and the graded cohomology ring. However, we introduce ring coefficients in the next section because, for computational purposes, it is often convenient to choose coefficients in the finite field R=ℤ p , p a prime number. Field coefficients are sufficient in many practical applications.

3 Computing Cohomology

The aim of this section is to show that the techniques of S-reductions of S-complexes developed in [20, 21] in order to construct efficient algorithms computing homology of cubical complexes may be easily adapted to provide algorithms computing the cohomology ring of a cubical set.

3.1 S-Complexes

Let R be a ring with unity and let S be a finite set. Denote by R(S) the free module over R generated by S. Let (S q ) q∈ℤ be a gradation of S such that S q =∅ for all q<0. Then (R(S q )) q∈ℤ is a gradation of the module R(S) in the category of modules over the ring R. For every element sS, the unique number q such that sS q is called the dimension of s and denoted by dims. We use the notation 〈⋅,⋅〉:R(SR(S)→R for the inner product which is defined on generators by

$$\langle t,s \rangle =\begin{cases} 1 & \mbox{for } t=s,\\ 0 & \mbox{otherwise,} \end{cases} $$

and extended bilinearly to R(SR(S).

We recall (see [20, 21]) that a pair (S,κ), where κ:S×SR is a map such that κ(s,t)=0 unless dims=dimt+1, is called an S-complex , if the pair \((R(S),{\bf \partial }^{\kappa})\) is a free chain complex with base S and the boundary map \({\bf \partial }^{\kappa}:R(S)\to R(S)\) is defined on generators sS by

$${\bf \partial }^\kappa(s) := \sum_{t\in S}\kappa(s,t)t. $$

The homology of an S-complex (S,κ) is the homology of the associated chain complex \((R(S),{\bf \partial }^{\kappa})\), denoted H(S,κ) or simply H(S). The elements of R(S) are called chains.

Any cubical set X⊂ℝd discussed in Sect. 2 defines an S-complex (S,κ), where \(S=\mathcal {K}(X)\) is the set of all elementary cubes of X and \(\kappa(Q,P):=\langle {\bf \partial }Q , P \rangle \), \({\bf \partial }\) the cubical boundary map. Its chain complex \((R(S),{\bf \partial }^{\kappa})\) is equal to \(\mathcal {C}(X;R)=\mathcal {C}(X)\otimes R\), the cubical chain complex of X with coefficients in R.

Let R (S):=Hom(R(S),R) be the group of cochains. The coboundary map defined as the dual \(\delta^{\kappa}:={ ({\bf \partial }^{\kappa})}^{\star}\) satisfies

$$\delta^\kappa\bigl({t}^{\star}\bigr):=\sum_{s\in S}\kappa(s,t) {s}^{\star} $$

for duals of generators tS. Moreover, for any pair of a chain cR(S q ) and a cochain dR (S q−1) we have

$$\big\langle {\bf \partial }^\kappa c,d \big\rangle =\big\langle c,\delta^\kappa d \big\rangle . $$

The cohomology of the cochain complex (Hom(R(S),R),δ κ) is called the cohomology of the S-complex and denoted H (S).

In the following, we will drop the superscript κ in \({\bf \partial }^{\kappa}\) and δ κ whenever κ is clear from the context.

The technique of S-reductions consists of replacing the original set of generators S by a subset S′⊂S, and the original coincidence index κ by the restriction κ′:=κ| S′×S. This has to be done in such a way that (S′,κ′) is still an S-complex, and the (co)homology does not change. A subset \(\mathcal {K}'\subset \mathcal {K}\) is an S-subcomplex of the S-complex \(\mathcal {K}\) if \((\mathcal {K}',\kappa')\), with \(\kappa':=\kappa|_{\mathcal {K}'\times \mathcal {K}'}\), the restriction of κ to \(\mathcal {K}'\times \mathcal {K}'\), is itself an S-complex, i.e. if \((R[\mathcal {K}'],\partial^{\kappa'})\) is a chain complex. Note that the concept of an S-subcomplex is not the same as the chain subcomplex (see [7, Example 1]).

Two important special cases of S-subcomplexes are the closed and open subset of an S-complex. In order to define these concepts we introduce the following notation for any subset AS:

We say that \(\mathcal {K}' \subset \mathcal {K}\) is closed in \(\mathcal {K}\) if \(\mbox {bd\,}_{\mathcal {K}} \mathcal {K}' \subset \mathcal {K}'\). We say that \(\mathcal {K}' \subset \mathcal {K}\) is open in \(\mathcal {K}\) if the complement \(\mathcal {K}\setminus \mathcal {K}'\) is closed. Note that if \(\mathcal {K}'\) is closed in \(\mathcal {K}\), then \(\partial^{\kappa}(R[\mathcal {K}'])\subset R[\mathcal {K}']\). Therefore, there is a well defined restriction

$$\partial^\kappa\big|_{R[\mathcal {K}']}:R\bigl[\mathcal {K}'\bigr]\to R \bigl[\mathcal {K}'\bigr], $$

which gives rise to a chain subcomplex \((R[\mathcal {K}'],\partial^{\kappa}|_{R[\mathcal {K}']})\) of the chain complex \((R[\mathcal {K}],\partial^{\kappa})\).

Similarly, if \(\mathcal {K}'\) is open in \(\mathcal {K}\), then there is a well defined quotient complex \((R[\mathcal {K}]/R[\mathcal {K}\setminus \mathcal {K}'],\partial')\) with the boundary map ′ taken as the respective quotient map of κ. From the computational point of view it is worth to observe that the quotient complex is isomorphic to the S-complex \((\mathcal {K}'',\delta^{\kappa''})\) where \(\mathcal {K}''=\mathcal {K}\setminus \mathcal {K}'\) and \(\kappa''=\kappa_{|\mathcal {K}''\times \mathcal {K}''}\) (cf. [20]).

The following theorem is a straightforward extension of Theorem 3.4 in [20] to cohomology.

Theorem 3.1

Let (S,κ) be an S-complex over the ring R, S′⊂S a closed subset and S″:=SSthe associated open subset. Then we have the following long exact sequence of homology modules:

$$ \cdots \stackrel{\partial_{q+1}}{\rightarrow} H_q \bigl(S'\bigr) \stackrel{\iota_q}{\rightarrow} H_q(S) \stackrel{\pi_q}{\rightarrow} H_q \bigl(S''\bigr) \stackrel{\partial_q}{ \rightarrow} H_{q-1}\bigl(S'\bigr) \stackrel{ \iota_{q-1}}{\rightarrow} \cdots $$

and the following long exact sequence of cohomology modules:

$$ \cdots \stackrel{\iota^{q-1}}{\rightarrow} H^{q-1} \bigl(S'\bigr) \stackrel{\delta^q}{\rightarrow} H^q\bigl(S''\bigr) \stackrel{ \pi^q}{\rightarrow} H^q(S) \stackrel{\iota^q}{\rightarrow} H^q\bigl(S'\bigr) \stackrel{ \delta^{q+1}}{\rightarrow} \cdots $$

in which ι :H q (S′)→H q (S) and ι :H q(S)→H q(S′) are induced by the inclusion ι:R(S′)→R(S), whereas π :H q (S)→H q (S″) and π :H q(S″)→H q(S) are induced by the projection π:R(S)→R(S″).

3.2 S-Reduction Pairs and the Coreduction Algorithm

Let (S,κ) be an S-complex. A pair (a,b) of elements of S is called an S-reduction pair if κ(b,a) is invertible and either cbd S a={b} or bd S b={a}. In the first case the S-reduction pair is referred to as an elementary reduction pair and in the other case as an elementary coreduction pair .

Arguing as in the proof of [20, Theorem 4.1] we obtain the following theorem.

Theorem 3.2

Assume S is an S-complex and (a,b) is an S-reduction pair in S. If (a,b) is an elementary reduction pair then {a,b} is open in S. If (a,b) is an elementary coreduction pair then {a,b} is closed in S. Moreover, in both cases {a,b} is an S-subcomplex of S and H ({a,b})=H ({a,b})=0.

Theorems 3.1 and 3.2 result in the following corollary.

Corollary 3.3

If (a,b) is an S-reduction pair in an S-complex S, then the homology modules H(S) and H(S∖{a,b}) as well as the cohomology modules H (S) and H (S∖{a,b}) are isomorphic.

Corollary 3.3 lies at the heart of the coreduction homology algorithm presented in [20, Algorithm 6.1]. The same algorithm without any changes may be used to speed up computation of cohomology modules. The algorithm consists of performing as many S-reductions as possible before applying the general Smith diagonalization algorithm to the reduced S-complex in order to compute the homology or cohomology module. To make it useful, one needs to find as many S-reduction pairs as feasible. In the case of simplicial complexes and cubical complexes it is straightforward to provide examples which admit elementary reduction pairs, but elementary coreduction pairs are not possible right away. However, it is easy to observe that by removing a vertex one obtains an open subcomplex which admits elementary coreduction pairs. Moreover, the homology of this subcomplex coincides with the reduced homology of the original complex and the cohomology of this complex coincides with the reduced cohomology of the original complex. Therefore, not only elementary reduction pairs, but also elementary coreduction pairs are useful when computing the homology or cohomology of simplicial or cubical complexes.

If the reduced S-complex is small when compared to the original S-complex then the coreduction algorithm is fast, because the reduction process is linear whereas the Smith diagonalization algorithm is supercubical. In fact, numerical experiments indicate that elementary coreduction pairs provide essentially deeper reductions than the elementary reduction pairs, and the speed up is essential. For details we refer the reader to [20, Sect. 5].

3.3 Homology Models

The Smith diagonalization algorithm applied to the reduced S-complex enables computing the cohomology module of the original S-complex up to isomorphism. In order to compute the cohomology ring of a cubical set it is not sufficient to have the cohomology generators in a reduced S-complex. It is necessary to construct the cohomology generators in the original cubical set.

In order to achieve this we need the following theorem which is an immediate consequence of [21, Theorems 2.8 and 2.9]:

Theorem 3.4

Assume (S,κ) is an S-complex, (a,b) is an S-reduction pair in S and \(\bar{S}:=S\setminus\{a,b\}\). Then \((\bar{S},\bar{\kappa})\) with \(\bar{\kappa}:=\kappa_{|\bar{S}\times \bar{S}}\) is an S-subcomplex of (S,κ) and the maps \(\psi=\psi^{(a,b)}: R(S)\to R(\bar{S})\), respectively, \(\iota=\iota^{(a,b)}: R(\bar{S}) \to R(S)\) given by

(22)
(23)

are mutually inverse chain equivalences. In particular, the chain complexes \((R(S),{\bf \partial }^{\kappa})\) and \((R(\bar{S}),{\bf \partial }^{\bar{\kappa}})\) are chain homotopic.

Since mutually inverse chain equivalences induce isomorphisms in cohomology, we get the following corollary.

Corollary 3.5

If (S,κ), is an S-complex over the ring R and (a,b) is an S-reduction pair in S, then the isomorphisms pointed out in Corollary 3.3 are induced by the chain maps defined in (22) and (23) for homology and their duals for cohomology.

As we already mentioned, the coreduction algorithm consists of performing a sequence of reductions. A reduction sequence of an S-complex (S,κ) is a sequence of pairs ω={(a i ,b i )} i=1,2,…,n in S such that (a i ,b i ) is a reduction pair in (S i−1,κ i−1), where the S-complexes (S i,κ i) are defined recursively by taking

We then use the notation S ω for the last chain complex in the sequence of S-complexes {S i} i=1,2,…,n and call this S-complex the ω-reduction of S. A homology model of S is an ω reduction S ω together with the chain equivalences.

In order to discuss the benefits of constructing a homology model of an S-complex S let us define first the weight of S by

$$w(S):=\max \bigl\{{\max(\operatorname {card}\mbox {bd\,}s,\operatorname {card}\mbox {cbd}\,s)\mid s\in S}\bigr\} . $$

The construction of a homology model of an S-complex S may be performed in time \(O(w(S)\operatorname {card}S)\) (see [20, Theorem 6.2]). In particular, in the case of cubical sets of fixed embedding dimension the homology model construction takes linear time. When the ω-reduction of S is small relative to S, one can profit from the homology model whenever homology generators and/or a decomposition of a homology class on the generators are needed. To construct the generators of H(S) one constructs the generators of H(S ω) and transports them to H(S) via the map ι ω, i.e. computes their image in ι ω. The computational complexity of this computation is \(O(w(S)\operatorname {card}S)\) (see [21, Theorem 3.1]). To decompose a homology class in H(S) one transports the class via the map ψ ω to H(S ω) and finds the decomposition there. See [21, Sect. 3.1] for details.

3.4 Homology Models for Cohomology

Precisely the same method may be used to speed up the construction of the cohomology generators in H (S) and the same complexity analysis applies to this case. One only uses the dual (ι ω) of ι ω to transport the cochains in the S-complex to its ω reduction and the dual (ψ ω) of ψ ω to transport the cochains in the ω-reduction back to the original S-complex. However, the transport requires an analogue of Theorem 3.4 for the duals ψ and ι . For this it is convenient to make the following convention. If T is an S-subcomplex of the S-complex S and t is a generator in T then dual of t in T is the restriction to T of the dual of t in S. Since the dual of t in S is always zero on ST, it is convenient to identify both duals and denote them by the same symbol t . Using this convention and the setting of Theorem 3.4 we have the following theorem.

Theorem 3.6

The duals of the chain maps ψ and ι are given by

(24)
(25)

Proof

It is enough to verify the formulas on generators. Let \(t\in\bar{S}\) and let cR(S). Then by (22)

However, since \(t\in\bar{S}=S\setminus\{a,b\}\), we have t (b)=0. Thus, we get

$$\psi^\star\bigl(t^\star\bigr) (c)= \biggl(t^\star- \frac{\langle b^\star, \delta t^\star \rangle}{\langle \partial b, a \rangle}a^\star \biggr) (c), $$

which proves (24). In order to prove (25) take sS and \(c\in R(\bar{S})\). Then by (23) we have

which proves (25). □

Surprisingly, there are even more benefits from the homology model for cohomology computations than for homology computations. This is because of the following theorem.

Theorem 3.7

Assume ω is a reduction sequence of an S-complex consisting only of elementary coreduction pairs. Then (ψ ω) is an inclusion

$${R}^{\star}\bigl(S^\omega\bigr)\hookrightarrow {R}^{\star}(S), $$

that is, (ψ ω)(c)=c for any cR (S ω).

Proof

If (a,b) is an elementary coreduction pair, then bd b={a}. Since \(a\not\in \bar{S}=S\setminus\{a,b\}\), we have 〈b ,δc〉=〈∂b,c〉=0 for any \(c\in R(\bar{S})\). Therefore, (ψ (a,b))(c)=c for any \(c\in {R}^{\star}(\bar{S})\). Since the reduction sequence ω consists only of elementary coreduction pairs, the conclusion follows. □

Note the following consequence. In the case of a reduction sequence ω consisting only of elementary coreduction pairs there is no need to transport the cohomology generators from the ω-reduction back to the original S-complex. The cohomology generators constructed in the ω-reduction are the cohomology generators in the original S-complex. This is particularly useful for computing the ring structure of a cubical set X, because we can apply formula (14) directly to the cohomology generators in the ω-reduction.

3.5 Computational Example

Observe that the set

is a cubical subset of ℝ3 homeomorphic to S 2S 1S 1 (see Fig. 4 top left).

Fig. 4
figure 4

Wedge of S 2 and two S 1 (top left) and wedge of S 2 and two S 1 coreduced (top right). Cubical torus (bottom left) and cubical torus coreduced (bottom right). For visualization purposes, the vertices are displayed as small black cubes, edges as long square-based prisms and 2D faces as large square-based prisms. The 2D faces of cubical sets are partially transparent to enable viewing through

The coreduction algorithm (see Sect. 3.3) applied to X outputs a model X ω with respect to a reduction sequence ω. The model consists of the following cells:

$$\bigl\{{[0]\times[0]\times[0], (1,2)\times[1]\times[0], (0,1)\times(0,1) \times[1], [0]\times(0,1)\times[2]}\bigr\} . $$

It is straightforward to observe that the cohomology classes of the cocycles

form the basis of the first cohomology module of X ω, and the cohomology class of the cocycle

$$\gamma:=\bigl([0,1]\times[0,1]\times[1]\bigr)^{\star} $$

generates the second cohomology module of X ω. By Theorem 3.7 and Theorem 3.4 [α], [β] form the basis of H 1(X) and [γ] generates H 2(X).

A routine calculus based on Theorem 2.24 shows that

$$ [\alpha]\smile[\beta] = 0. $$
(26)

Moreover, we consider

which is a cubical subset of ℝ3 homeomorphic to a torus (see Fig. 4 bottom left).

The coreduction algorithm applied to T outputs a model T ω with respect to a reduction sequence ω. The model consists of the following cells:

It is easy to check that the cohomology classes of the cocycles

and

form the basis of the first cohomology module of T ω and the cohomology class of the cocycle

$$\gamma=\bigl([1,2]\times[2,3]\times[1]\bigr)^{\star} $$

generates the second cohomology module of T ω. By Theorem 3.7 and Theorem 3.4 [α], [β] form the basis of H 1(T) and [γ] generates H 2(T).

Moreover, a long but routine computation based on Theorem 2.24 shows that

$$ \alpha\smile\beta = \pm\gamma. $$
(27)

Equations (26) and (27) show that the cohomology rings of X and T are different. In this simple case, it is possible to make the necessary computations by hand. However, one may have two cubical sets homeomorphic respectively to X and T whose representations consist of millions of cubes. Such cubical sets often result from rigorous numerics of dynamical systems, data or image analysis. The benefits from computing the ring structure via the cohomology model is evident. This is visible even in the case of a simple rescaling (for the definition of rescaling see [15, Sect. 6.4.2]) of the cubical sets in our two examples (see Fig. 5).

Fig. 5
figure 5

Rescaled wedge of the sphere and two circles from Fig. 4 (top left) and the result of a coreduction (top right). Rescaled cubical torus (bottom left) and the result of a coreduction (bottom right)