{'fraction_non_alphanumeric': 0.05288979638137372, 'fraction_numerical': 0.011414553910725427, 'mean_word_length': 4.011369288708875, 'pattern_counts': {'":': 0, '<': 2, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 57, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
A directed persistent homology theory for dissimilarity functions

We develop a theory of persistent homology for directed simplicial complexes which detects persistent directed cycles in odd dimensions. We relate directed persistent homology to classical persistent homology, prove some stability results, and discuss the computational challenges of our approach. Our directed persistent homology theory is motivated by homology with semiring coefficients: by explicitly removing additive inverses, we are able to detect directed cycles algebraically.


Introduction
Persistent homology is one of the most successful tools in Topological Data Analysis [3], with recent applications in numerous scientific domains such as biology, medicine, neuroscience, robotics, and many others [18]. In its most common implementation, persistent homology is used to infer topological properties of the metric space underlying a finite point cloud using two steps [10]: (1) Build a filtration of simplicial complexes from distances, or similarities, between data points.
(2) Compute the singular homology of each of the simplicial complexes in the filtration, along with the linear maps induced in homology by their inclusions. The resulting persistence module can normally be represented using a persistence diagram or a persistence barcode. A fundamental limitation of persistent homology, and in fact homology, is its inability to incorporate directionality, which can be important in some real-world applications (see examples below). For instance, homology cannot in principle distinguish between directed and undirected cycles ( Figure  1). Although the definition of homology, namely the differential or boundary operator, requires a choice of orientation for the simplices, the resulting homology is independent of this choice. Previous attempts have had some partial success at this issue (see 'Related work' below), however, as far as we know, there is no homology theory able to exactly detect directed cycles up to boundary equivalence.
The main difficulty occurs at the algebraic level: opposite orientations on a simplex correspond to additive inverse elements in the coefficient ring or field. Our key insight is to retain the submodule of homology generated by those classes that only have non-negative coefficients on elementary chains. In this way, we can define a directed homology module (Def. 3.6) of directed simplicial complexes (Def. 3.1) that detects homology classes of directed 1-cycles, as desired ( Fig. 1

, Prop. 3.24).
This insight arises from the use of homology with semiring coefficients, where additive inverses may not exist. Indeed, the main results in this paper can be understood and reformulated in full generality using homology theory with semiring coefficients, see Appendix A.
Our directed homology theory can be extended to the persistent setting. More concretely, we define two persistence modules associated to filtrations of directed simplicial complexes: an undirected one using the whole homology module (Def. 4.2) and a directed one using the submodule of directed homology (Def. 4.3). We show that the bars in the directed barcodes can be matched one-to-one with bars in the undirected barcodes, with the directed bars possibly having a later birth (Prop. 4.7,Figs. 2,5,6).
Our motivation to develop directed persistent homology is the applications to real-world data sets where asymmetry or directionality, in particular the presence of directed cycles, plays a fundamental role. Examples include biological neural networks (directed synaptic connections), time series data (directed temporal connections) or biological molecular networks such as protein-protein interaction networks (inhibitory and excitatory connections). Mathematically, we can model these situations using a finite set V of data points, and an arbitrary function d V : V × V → R, which we call dissimilarity function (Section 2.2) and which, crucially, may not be symmetric. Our main example of a directed simplicial complex is the directed Rips complex (Definition 4.12) of (V, d V ), which becomes the input of our suggested directed persistent homology pipeline.
In the context of dissimilarity functions, we prove a stability result with respect to the bottleneck distance between (directed) persistent diagrams and the correspondence distortion distance (a generalisation of the Gromov-Hausdorff distance) between dissimilarity functions over finite sets (Thm. 4.19). We finish this article by discussing the computational challenges of our approach.
Related work. A first approach to incorporating directionality would be to encode the asymmetry of a data set in the simplicial complex built from it. In [25], the author uses ordered tuple complexes or OT-complexes, which are generalisations of simplicial complexes where simplices are ordered tuples of vertices. Similar ideas have been successfully used in the field of neuroscience to show the importance of directed cliques of neurons [21], showing that directionality in neuron connectivity plays a crucial role in the structure and function of the brain. In [7], the authors use so-called Dowker filtrations to develop persistent homology for asymmetric networks, and note [7,Remark 35] that a non-trivial 1-dimensional persistence diagram associated to Dowker filtrations suggests the presence of directed cycles. However, they also note that such persistence diagram may be non-trivial even if directed cycles are not present. Further progress can be achieved by combining the ideas above with homology theories that are themselves sensitive to asymmetry. In [8], the authors develop persistent homology for directed networks using the theory of path homology of graphs [14]. This persistent homology theory shows stability with respect to the distance between asymmetric networks [4], and is indeed able to tell apart digraphs with isomorphic underlying graphs but different orientations on the edges. Nonetheless, cycles in path homology do not correspond to directed cycles, see [8,Example 10]. Another significant contribution can be found in [25], where four new approaches to persistent homology are developed for asymmetric data, all of which are shown to be stable. Each approach is sensitive to asymmetry in a different way. For example, one of them uses a generalisation of poset homology to preorders to detect strongly connected components in digraphs, a feature our implementation does not have (see Proposition 3.18). More interestingly for our purposes, in [25, Section 5] the author introduces a persistent homology approach that builds a directed Rips filtration of ordered tuple complexes associated to dissimilarity functions d V : V × V → R. This is indeed sensitive to asymmetry and yields a persistent homology pipeline that is stable with respect to the correspondence distortion distance, a generalisation of the Gromov-Hausdorff distance to dissimilarity functions (see [25,Section 2] and Section 2.2). However, undirected cycles are also detected by this homology theory. In contrast, in this article we produce a theory of persistent homology associated to ordered tuple complexes that only detects directed cycles and which is also stable with respect to the correspondence distortion distance.
Overview of results. We introduce modules of undirected and directed homology associated to directed simplicial complexes (Definition 3.4) and show that they satisfy some desirable properties. Furthermore, we prove that for certain coefficient rings, closed paths will only have non-trivial directed homology in dimension 1 when their edges form a directed cycle, as we set up to do (Proposition 3.24). Our modules of directed homology can be defined in dimensions greater than one, although they are zero in all even dimensions (Proposition 3.26) except in dimension 0 where they detect weakly connected components (Proposition 3. 18). Figure 2. A filtration of a directed simplicial complex (top, left to right) and corresponding undirected (bottom, left) and directed (bottom, right) persistence barcodes. Every bar in the directed barcode corresponds to a unique bar in the undirected barcode (shown here by matching colours).
Next, we extend our homology theory to the persistence setting. In particular, we introduce, for each dimension, two persistence modules associated to the same filtration: an undirected persistence module (Definition 4.2), which is analogous to the one introduced in [25, Section 5], and the submodule generated by directed classes, which we call the directed persistence module (Definition 4.3). The directed persistence module gives rise to bars associated to homology classes that can be represented by directed cycles, as illustrated in Fig. 2 and Examples 4.8 to 4.11. We also establish a relation between the undirected and directed persistence barcodes of the same filtration. Indeed, in Proposition 4.7 we show that every bar in the directed barcode corresponds to a unique bar in the undirected barcode that dies at the same time. The bar in the directed barcode may, however, be born later, and some bars in the undirected barcode may be left unmatched (see Figs. 2, 5 and 6).
Having all the necessary ingredients, we can provide a complete workflow for directed persistent homology: given a dissimilarity function d V on a finite set V , we construct its directed Rips filtration (Definition 4.12), and take the corresponding undirected and directed n-dimensional persistence modules, respectively denoted H n (V, d V ) and H Dir n (V, d V ) (Definition 4.13). Both of these persistence modules have persistence diagrams and barcodes (Definition 4.15) and the associated persistence modules are stable with respect to the correspondence distortion distance (Section 2.2 and Theorem 4.19).
We finish the article with a discussion of the computational challenges of calculating the directed persistent homology of a dissimilarity function. The Standard Algorithm can easily be adapted to compute the barcodes of the undirected persistent homology of the dissimilarity function, but the computation of the directed persistence barcodes is more challenging. A direct approach results in an extreme ray enumeration problem (Section 5), a well-known problem in computational geometry. Developing an algorithm that computes the directed homology classes, rather than all directed cycles, remains an open problem.
We include an Appendix on homology with semiring coefficients and on how it gives rise to the ideas introduced in this article. This provides additional motivation and context for our results, and presents them in full generality.
Outline of the article. In Section 2, we introduce the necessary background in persistence modules (2.1) and dissimilarity functions (2.2). In Section 3 we introduce undirected and directed homology modules of directed simplicial complexes. We then use these homology modules to introduce directed and undirected persistent homology in Section 4, where we also show our stability results with respect to dissimilarity functions. In Section 5, we discuss the computational implementation of directed persistent homology and lay out some future research directions. Finally, Appendix A introduces homology with semiring coefficients and shows how it relates to directed homology.

Persistence modules and dissimilarity functions
Our goal is to extend persistent homology to directed simplicial complexes such as those constructed from a dissimilarity function. In this section, we introduce the necessary background regarding persistent homology (Section 2.1) and dissimilarity functions (Section 2.2).
2.1. Persistence modules, diagrams and barcodes. In this section, we introduce persistence modules and their associated persistence diagrams and barcodes. We follow the exposition in [8], as it is simple and focused on persistence modules arising in the context we are interested in: that of persistent homology of finite simplicial complexes. Many of the results below hold in more generality [6] but we chose to keep the exposition simple.
Let R be a ring with unity and let T ⊆ R be a subset.
Let us assume that R is a field, thus V = {V δ }, {ν δ ′ δ } δ≤δ ′ ∈T is a persistence vector space, and that V δ is finite-dimensional, for every δ ∈ R. Furthermore, we suppose that there exists a finite subset {δ 0 , δ 1 , . . . , δ n } ⊆ T for which When R is a field, either of these restrictions alone (namely, each V δ being finitedimensional or the existence of a finite subset {δ 0 , δ 1 , . . . , δ n } as above) is enough to associate a persistence barcode and a persistence diagram to V [6, Theorem 2.8]. We nevertheless assume both restrictions since they hold for persistence diagrams associated to finite simplicial complexes, which are precisely the sort of objects that arise from data, and such assumption makes the exposition simpler.
Let us now introduce persistence barcodes and diagrams. First, for simplicity, we consider V indexed by the natural numbers: where V δ k = V δn for all k ≥ n and ν δ l δ k is the identity whenever k, l ≥ n. (This clearly contains all of the information in V.) By [11, Basis Lemma], we can find bases B i of the vector spaces V δ i , i ∈ N, such that Such bases are called compatible bases. Elements in B i that are mapped to an element in B i+1 correspond to linearly independent elements of V δ i that 'survive' until the next step in the persistence vector space. Similarly, elements in a basis B i which are not in B i−1 are considered to be 'born' at index i. Formally, we define we call i the birth index of the basis element b. This element 'survives' on subsequent bases until it is eventually mapped to zero. When this happens, the number of steps taken until the class dies is its death index of b. Formally, the death index of (b, i) is Using this information, we can introduce the persistence barcode of V. We call a pair (X, m) a multiset if X is a set and m : X → N = N ∪ {+∞} is a function. We call m(x) the multiplicity of x ∈ X.
δ i } i∈N as above. The persistence barcode of V is defined as the multiset of intervals Thus, persistence barcodes encode the birth and death of elements in a family of compatible bases. Crucially, and even though compatible bases are not unique, the number of birth and death events at each step is determined by the rank of the linear maps ν δ i+1 δ i and their compositions, and it is thus independent of the choice of compatible bases. Furthermore, the persistence barcode of a persistence vector space completely determines both the dimension of the vector spaces V δ i and the ranks of the linear maps between them, hence it determines the persistence vector space up to isomorphism [6,Theorem 2.8].
Each interval in Pers(V) is called a persistence interval. Persistence barcodes can be represented by stacking horizontal lines, each of which represents a persistence interval or bar. The endpoints of the line in the horizontal axis correspond to the endpoints of the interval it represents, whereas the vertical axis has no significance other than being able to represent every persistence interval at once. Persistence bars can be stacked in any order, although they are usually ordered by their birth. This representation is what gives persistence barcodes their name.
An alternative characterisation of a persistence vector space is its persistence diagram. Let us write R = R ∪ {−∞, +∞} for the extended real line.
Definition 2.4. The persistence diagram of the persistence vector space V is the multiset The multiplicity of a point in Dgm(V) is the multiplicity of the corresponding interval in Pers(V).
A crucial property for applications of persistent homology to real data is that a small perturbation of the input (a data set, encoded as filtration of simplicial complexes) results in a small perturbation of the output (its persistence module). Algebraically, this amounts to proving that a small perturbation of the persistence diagram results in a small perturbation of the associated persistence module. In order to state this stability result, we therefore need to introduce distances between persistence diagrams, and persistence modules, respectively.
To measure how far apart two persistence diagrams are, we can use the bottleneck distance between multisets of R 2 . Let ∆ ∞ denote the multiset of R 2 consisting of every point in the diagonal counted with infinite multiplicity. A bijection of multisets ϕ : y, that is, a bijection between the sets obtained when counting each element in both X and Y with its multiplicity. where the infimum is taken over all bijections of multisets ϕ : A ∪ ∆ ∞ → B ∪ ∆ ∞ and where · ∞ denotes the ℓ ∞ -norm in R 2 .
Note that the bottleneck distance between two persistence diagrams defined from persistence barcodes can only be finite if the diagrams have the same amount of bars of form [a, ∞) for a ∈ R.
We also need a distance between persistence vector spaces. To that purpose, we use the interleaving distance, introduced in [5].
be two persistence vector spaces, and ε ≥ 0. We say that V and W are ε-interleaved if there exist two families of linear maps {ϕ δ : V δ → W δ+ε } δ∈R , {ψ δ : W δ → V δ+ε } δ∈R such that the following diagrams are commutative for all δ ′ ≥ δ ∈ R: The interleaving distance between V and W is then defined as The authors in [5] show that the interleaving distance is a pseudometric (a zero distance between distinct points may occur) in the class of persistence vector spaces. Moreover, they show the following Algebraic Stability Theorem.

2.2.
Dissimilarity functions and the correspondence distortion distance. Our objective is to define a theory of persistent homology able to detect directed cycles modulo boundaries. Therefore, instead of building filtrations (of simplicial complexes) from finite metric spaces, we are interested in filtrations (of directed simplicial complexes) built from arbitrary dissimilarity functions. We will follow [25], where they receive the name of set-function pairs, and [4,7,8], where they are referred to as dissimilarity networks or asymmetric networks. In this section, we introduce the necessary background on dissimilarity functions, and the correspondence distortion distance between them, which is a generalisation of the Gromov-Hausdorff distance to the asymmetric setting. We finish with a reformulation of this distance, established in [4], which we will need to prove our persistent homology stability result.
Note that no restrictions are imposed on d V , thus it may not be symmetric, the triangle inequality may not hold, and the distance from a point to itself may not be zero. These functions are also referred to as asymmetric networks [4,7,8] since they may be represented as a network with vertex set V and an edge from v 1 to v 2 with weight d V (v 1 , v 2 ) for every (v 1 , v 2 ) ∈ V × V . Thus, dissimilarity functions are very flexible and allow for the modelling of widely different problems, including any problem that can be modelled using a network.
We would like to build (directed) simplicial complexes and, ultimately, persistence diagrams from dissimilarity functions. In order to check the stability of our constructions, we need a way to measure how close two such objects are. When comparing networks with the same vertex sets, a natural choice is the ℓ ∞ norm. However, we are interested in comparing dissimilarity functions on different vertex sets. To that end, we consider the ℓ ∞ norm over all possible pairings (quantified by a binary relation) between vertex sets, following ideas similar to those behind the definition of the Gromov-Hausdorff distance.
Definition 2.9. Let (V, d V ) and (W, d W ) be two dissimilarity functions and let θ be a non-empty binary relation between V and W , that is, an arbitrary subset θ ⊆ V × W . The distortion of the relation θ is defined as A correspondence between V and W is a relation θ between these sets such that π V (θ) = V and π W (θ) = W , where π V : V × W → V is the projection onto V , and similarly for π W . That is, θ is a correspondence if every element of V is related to at least an element of W , and vice-versa. The set of all correspondences between V and W is denoted R(V, W ).
The correspondence distortion distance [25] between (V, d V ) and (W, d W ) is defined as This notion agrees with that of the Gromov-Hausdorff distance when (V, d V ) and (W, d W ) are metric spaces, [2, Section 7.3.3].
We will use a reformulation of the correspondence distortion that can be found in [7]. In order to introduce it, we need to define the distortion and co-distortion of maps between sets endowed with dissimilarity functions.
The co-distortion of ϕ and ψ (with respect to d V and d W ) is defined as Note that codistortion is not necessarily symmetrical, namely, codis(ϕ, ψ) and codis(ψ, ϕ) may be different if either of the dissimilarity functions are asymmetric.
Finally, we have the following reformulation of the correspondence distortion distance.

Directed homology of directed simplicial complexes
In this section, we introduce and study a family of subrings of the homology rings of simplicial complexes which encode directionality information and in particular detect directed cycles (Fig. 1). We cannot introduce such a family using (undirected) simplicial complexes, as they cannot encode directionality information of the simplices. One approach is to use the so-called ordered-set complexes, where simplices are sets with a total order on the vertices. They generalise simplicial complexes, which can be encoded as fully symmetric ordered-set complexes, that is, ordered-set complexes where if a set of vertices forms a simplex, it must do so with every possible order. However, persistent homology of ordered-set complexes is not stable (Remark 4.20).
To achieve stability, we use one further generalisation, called ordered tuple complexes or OTcomplexes in [25], and called directed simplicial complexes in this article (Definition 3.1). The only difference is that arbitrary repetitions of vertices are allowed in the ordered tuples representing simplices. Clearly, any ordered-set complex is a directed simplicial complex. Furthermore, a (undirected) simplicial complex can be encoded as a fully symmetric (as above) directed simplicial complex where every possible repetition of vertices is also included. When doing so, the (undirected) simplicial complex and its associated directed simplicial complex have isomorphic homologies over rings (Remark 3.5), and morphisms of simplicial complexes can be lifted to morphisms between their associated directed simplicial complexes (Remark 3.9). Finally, and crucially for us, we will be able to use the above mentioned subrings encoding information on directed cycles to introduce a theory of persistent homology for dissimilarity functions which is stable with respect to the correspondence-distortion distance (Section 4). Note that, as ordered-set complexes are directed simplicial complexes, the results stated here apply to homology computations on ordered-set complexes as well.
3.1. Chain complexes of directed simplicial complexes. In this section, we introduce directed simplicial complexes and their associated chain complexes and homology modules, including modules of directed homology.
. , x n ) ∈ X for every i = 0, 1, . . . , n. (Here and throughout the rest of the paper, x i indicates that x i is omitted from the list.) We will denote the directed simplicial complex (V, X) just by X, and assume that every vertex belongs to at least one directed simplex (so that V is uniquely determined from X). Elements of X of length n + 1 are called n-simplices, and the subset of the n-simplices of X is denoted by X n . Note that arbitrary repetitions of vertices in a tuple are allowed.
Note that directed simplicial complexes are more general objects than simplicial complexes, in a way that allows directed simplicial complexes to encode asymmetric information. Note further that it is possible to define a geometric realisation for these objects in which simplices with vertex repetitions are collapsed to a simplex with no repetitions, thus simplices with repeated vertices play a role similar to that of the degenerate simplices in simplicial sets.
We make use of the following terminology when dealing with directed simplicial complexes. Elements of X of length n + 1 are called n-simplices, and the subset of the n-simplices of X is denoted by X n . An n-simplex obtained by removing vertices from an m-simplex, n ≤ m, is said to be a face of the m-simplex. Such face is called proper if n < m, or equivalently, if at least vertex of the m-simplex is removed. A directed simplicial complex is said to be n-dimensional, denoted dim(X) = n, if X n+1 is trivial (empty) but X n is not. A collection Y of simplices of X that is itself a directed simplicial complex is said to be a directed simplicial subcomplex (or, simply, subcomplex ) of X, denoted Y ⊆ X. Note that the vertex set of Y may be strictly smaller than that of X.
We now introduce chain complexes associated to a directed simplicial complex. These definitions are straight generalisations of those for (undirected) simplicial complexes.
Definition 3.2. Let R be a commutative ring. The n-dimensional chains of X are defined as the elements of the free R-module generated by the n-simplices, We call the elements [x 0 , x 1 , . . . , x n ] ∈ C n (X, R), (x 0 , x 1 , . . . , x n ) ∈ X, elementary n-chains. Definition 3.3. Let X be a directed simplicial complex. For each n > 0, we define a morphism of R-modules ∂ n : C n (X, R) → C n−1 (X, R) by For n = 0, let ∂ 0 : C 0 (X, R) → {0} be the trivial map.
A straightforward computation analogous to the one for chain complexes in simplicial homology shows that {C n (X, R), ∂ n } is a chain complex of R-modules. In particular, we can define homology groups.
Definition 3.4. Let X be a directed simplicial complex, R a commutative ring, and n ≥ 0. The n-dimensional cycles, boundaries, and homology of X are Z n (X, R) = {x ∈ C n (X, R) | ∂ n (x) = 0}, B n (X, R) = Im ∂ n+1 and the quotient H n (X, R) = Z n (X, R)/B n (X, R), respectively. Remark 3.5. If X is an (undirected) simplicial complex, we can define an ordered-set simplicial complex X OT where (x 0 , x 1 , . . . , x n ) ∈ X OT whenever {x 0 , x 1 , . . . , x n }, after removing any repetition of vertices, is a simplex in X. The chain complex C * (X OT , R) is called the ordered chain complex of X in [17], and its homology is isomorphic to the singular homology of X over R.
We now discuss how to only retain the information associated to directed cycles. Note that when introducing the differential for the chain complexes of simplicial complexes, an orientation is chosen for each of the simplices. However, undirected cycles can still be produced because the chosen orientation for a simplex can be reverted by changing the sign of the corresponding elementary chain. As such, homology of (undirected) simplicial complexes is independent of these choices of orientations.
In the case of directed simplicial complexes, orientations are not chosen, and we can ensure that we are only retaining information regarding directed cycles by making sure that all of the chains have positive coefficients, when the coefficient ring is chosen appropriately. However, we also require the introduced object to be a submodule of the entire module of homology. Thus, we arrive at the following definition.
The nth dimensional module of directed homology, H Dir n (X, R), is the submodule of H n (X, R) generated by the directed cycles, Remark 3.7. The rings Z, Q and R are used to simplify the exposition: the definition of Z Dir n (X, R), and thus of H Dir n (X, R), can be made in an analogous way for any ring R that is the Grothendieck completion of a cancellative, zerosumfree semiring Λ (see Appendix A).
In view of Definition 3.6 it is clear that, in dimension 1, directed circuits in the directed graph underlying a directed simplicial complex will give rise to directed cycles. In Section 3.3 we will show how these directed submodules of homology behave in a desirable way.

3.2.
Functoriality of directed homology. In this section, we prove that homology and directed homology are functors from the category of directed simplicial complexes to the category of graded R-modules. We also show that two morphisms allowing for the construction of the prism operator must induce the same map on homology, a result we will need to prove our persistent homology stability result. We begin by introducing morphisms of directed simplicial complexes.
Remark 3.9. This definition is stricter than the classical notion of morphism of simplicial complexes, where morphisms are allowed to take simplices to simplices of lower dimension, as directed simplicial complexes can intrinsically account for vertex repetitions. However, note that if X and Y are (undirected) simplicial complexes, a map f : X → Y is a morphism of simplicial complexes if and only if f : X OT → Y OT (see Remark 3.5) is a morphism of directed simplicial complexes.
We will often abbreviate C n (f ) = f n .
Remark 3.12. Let X and Y be (undirected) simplicial complexes and let R be a ring. If f : X → Y is a morphism of (undirected) simplicial complexes, the map induced on homology by f : X → Y is the same as the map induced on homology by f : X OT → Y OT (see Remarks 3.5 and 3.9). We finish this section by showing a sufficient condition for two morphisms to induce the same map on homology. We will need this result to prove that our definition of persistent homology is stable.
Lemma 3.14. Let R be a commutative ring. Let X and Y be two directed simplicial complexes and let f, g : We show that this family of maps provides a chain homotopy between f and g. Namely, we prove that C n (g) − C n (f ) = ∂ n+1 s n + s n−1 ∂ n , for all n. On the one hand, On the other hand, By exchanging the roles of the indices in this last equation, we obtain that Now, adding Equations (3.1) and (3.2), It is now straightforward to check that this sum amounts to and we are done.

Basic computations and examples.
In this section, we explore some basic properties of this homology theory. We begin by studying the relation between homology and connectivity.
connected if it has only one connected component, that is, every pair of vertices can be connected by a path.
Note that this notion of connectedness ignores the direction of the edges (1-simplices). The next result shows that we can compute the homology of each connected component independently. The proof follows by observing that the chain complex C n (X, R) is clearly the direct sum of the chain complexes associated to each of the (weakly) connected components of X. In particular, it is immediate that any directed cycle can be decomposed as a sum of directed cycles in each of the directed components.
Proposition 3.16. The (directed) homology of a directed simplicial complex X is isomorphic to the direct sum of the (directed) homology modules of its (weakly) connected components.
We next show that the 0th (directed) homology counts the number of (weakly) connected components of a directed simplicial complex X. We start with a lemma. Proof. It is clear that λ[v] is a cycle as ∂ 0 is trivial. On the other hand, it is clear that it must be the trivial class if λ = 0. Now assume that λ[v] is the trivial class. We shall prove that λ = 0.
Assume that X has n + 1 vertices, namely where we are assuming that λ ij = 0 whenever [x i , x j ] is not a 1-chain. By computing the differentials, is a basis of C 0 (X, R), the coefficients of each element in the basis must be equal in both sides of the equality. Namely, for each j = 0, 0 = n i=0 (λ ij − λ ji ), and λ = n i=0 (λ i0 − λ 0i ). Adding these equations, we deduce that λ = 0. Proposition 3.18. Let X be a directed simplicial complex and let R be a commutative ring. Then For the second statement, if R ∈ {Z, Q, R}, we can compute H Dir n (X, R). In such case, [v] is a directed cycle, thus [v] = H 0 (X, R) ⊆ H Dir 0 (X, R). It then follows that H 0 (X, R) = H Dir 0 (X, R). Remark 3. 19. The fact that 0th directed homology ignores edge directions seems counter-intuitive, as we set up this framework to detect directed features, namely directed cycles. However, this is a natural consequence of homology being an equivalence relation. In particular, as mentioned in the proof, if either [u, v] or [v, u] are 1-chains, [u] and [v] are homologous, thus directionality of the 1-chains does not affect 0th directed homology. However, this only occurs in dimension 0, as a consequence of 0-chains always being cycles. Thus, when working with 1-simplices, the symmetry in the homology relation does not affect the detection of asymmetry in the data, as such asymmetry is encoded in the cycles themselves. It is also worth mentioning that a persistent homology able to detect strongly connected components in directed graphs has been introduced in [25].
We now show that the homology of a point is trivial for positive indices. Indeed, X is connected, thus H 0 (X, R) = R by Proposition 3.18. For n ≥ 1, there are no nchains, hence H n (X, R) = 0. In this case, it is also immediate to check that if R ∈ {Z, Q, R}, H Dir n (X, R) = H n (X, R), for every n. Directed simplicial complexes whose homology is isomorphic to that of the point are called acyclic.
Note that acyclic implies directionally acyclic, as directed homology is a submodule of the module of homology, for every n.
Next, we show that a directed simplicial complex consisting of one m-dimensional simplex along with all of its faces (note that this is an ordered-set complex) is acyclic.  Proof. As a consequence of how X is defined, if x ∈ C n (X, R) is a chain so that x 0 does not participate in any of its elementary n-chains (as there are no repetitions in the simplices of X), then x 0 can be added as the first element of every elementary n-chain in x, giving us an (n + 1)-chain which we denote x 0 x ∈ C n+1 (X, R). Simple computations show that Now take x ∈ Z n (X, R) any cycle and decompose it as x = x 0 y + z, where x 0 does not participate in any of the chains in either y or z. Using the formula above, In particular, the chains in which x 0 does not participate must add up to zero, namely y + ∂(z) = 0. Finally, consider the chain x 0 z. We have that Thus, x ∈ Z n (X, R) is homologous to zero, and the result follows.
We now illustrate the ability of this homology theory to detect directed cycles. We do so through some simple examples.
Example 3.23. Let R ∈ {Z, Q, R}. Let X, Y and Z be the directed simplicial complexes represented in Figure 3. These three complexes are connected, so their 0th homologies are R, both directed and undirected. Furthermore, neither X nor Y have k-simplices for k ≥ 2, so H k (X, R) and H k (Y, R) are trivial (zero) for every k ≥ 2. This in particular implies that H Dir k (X, R) and H Dir k (Y, R) are trivial as well. Although Z has one 2-simplex, it is not a 2-cycle, thus H 2 (Z, R) is also trivial. To compute the first homology, we need to consider the 1-simplices and their differentials. We list them below.
is a cycle for X if and only if λ 1 = λ 2 = −λ 3 . Since there are no 2-cycles in X, different 1-cycles cannot be homologous. We deduce that H 1 (X, R) ∼ = R. However, no 1-cycle can have non-negative coefficients for the three elementary 1-cycles, thus H Dir cycles. In particular, Z Dir 1 (Z, R) consists of linear combinations of those two cycles, with positive coefficients. Note, however, that generating sets of Z 1 (X, R) containing fewer than two directed cycles exist. This shows that computing a generating set for the cycles may not be enough to compute the full set of directed cycles.
Continuing with the homology computations, note that in this case we have a 2-simplex, y = ] be a cycle. If x is non-trivial, we can assume without loss of generality that λ 0 = 0. We can further assume that e 0 = (v 0 , v 1 ). Thus, The only other edge in which e 1 participates is e 1 . We deduce that  Figure 4), which are allowed in a directed simplicial complex. Indeed, an immediate computation shows that [v 1 , v 2 ] + [v 2 , v 1 ] is a directed 1-cycle. This result shows that directed homology is not a homotopy invariant for the geometric realisation of directed simplicial complexes, as all of the polygons considered in Proposition 3.24 give rise to homotopic geometric realisations.
We end this section by noting that, although our initial aim was a directed homology group able to detect directed 1-cycles, we have a directed homology theory defined in all dimensions. However, we can show that the directed homology is trivial in even dimensions other than 0. Proof. We will show that no non-trivial directed cycles may exist in such dimensions. In order to do so, consider the morphism of R-modules Thus, if x = k i=0 λ i x i where x i is an elementary n-chain, ϕ n (x) = k i=0 λ i . Now assume that x i is an elementary 2n-chain, for some n ≥ 1. In this case, ∂(λ i x i ) = λ i ∂(x i ), where ∂(x i ) consists of the sum of ⌊ 2n 2 ⌋ = n elementary n-chains with positive sign and ⌊ 2n−1 2 ⌋ = n−1 elementary n-chains with negative sign. Thus, ϕ 2n−1 (λ i x i ) = λ i (n − (n − 1)) = λ i .
To prove our claim, let x = k i=0 λ i x i ∈ Z 2n (X, R) be a cycle where each x i is an elementary 2n-cycle. Then, given that ∂(x) = 0, ϕ 2n−1 ∂(x) = k i=0 λ i = 0. If x is directed, then λ i ≥ 0, for all i, thus we deduce that λ i = 0, for all i. Namely, the trivial cycle is the only directed cycle, and H Dir 2n (X, R) = {0}. Remark 3.27. The proof of this result is based on the fact that the number of positive coefficients in the boundary of an elementary n-chain is larger than the number of negative coefficients, if n is even. This may also be related to the fact that there is no obvious way to define directed n-cycles for n > 1. For the purposes of this article, it suffices to consider 1-cycles and H 1 (X, R). However, note that non-trivial (homological) cycles do exist in all odd dimensions. For instance, the elementary (2n − 1)-chain obtained by repeating a vertex 2n times is always a cycle.

Persistent directed homology
In this section, we introduce a theory of persistent homology for directed simplicial complexes which comes in two flavours: one takes into account the directionality of the complex, whereas the other one is analogous to persistent homology in the classical setting. We thus have, associated to the same filtration of directed simplicial complexes, two persistence modules which produce two different barcodes. Both persistent homology theories show stability (see Theorem 4.19) and they are closely related. Indeed, directed cycles are undirected cycles as well, thus every bar in a directed persistence barcode can be uniquely matched with a bar in the corresponding undirected one, although the undirected bar may be born sooner, see Proposition 4.7.

4.1.
Persistence modules associated to a directed simplicial complex. Let us begin by introducing filtrations of directed simplicial complexes.
Definition 4.1. Let X be a directed simplicial complex (Definition 3.1). A filtration of X is a family of subcomplexes (X δ ) δ∈T , T ⊆ R, such that if δ ≤ δ ′ ∈ T , then X δ is a subcomplex of X δ ′ , and such that X = ∪ δ∈T X δ . Note that for δ ≤ δ ′ , the inclusion i δ ′ δ : X δ → X ′ δ is a morphism of directed simplicial complexes.
We now introduce undirected persistence modules.
Definition 4.2. Let (X δ ) δ∈T be a filtration of a directed simplicial complex X and let R be a commutative ring. The n-dimensional undirected persistence R-module of X is the persistence Rmodule ({H n (X δ , R)}, {H n (i δ ′ δ )} δ≤δ ′ ∈T . The functoriality of H n makes this a persistence module. Now, in order to retain the information on directionality, we take the submodule of directed classes. Definition 4.3. Let (X δ ) δ∈T be a filtration of a directed simplicial complex X and let R ∈ {Z, Q, R}. The n-dimensional directed persistence R-module of X is the persistence R-module are defined as in Definition 3.6, i δ ′ δ : X δ → X δ ′ are the inclusion maps, and H Dir n (i δ ′ δ ) are the restrictions of the maps H n (i δ ′ δ ) to directed homology, as introduced in Proposition 3.11. Remark 4.4. Let (X δ ) δ∈T be a filtration of a directed simplicial complex X and let δ ≤ δ ′ ∈ T . If R ∈ {Z, Q, R}, by applying Proposition 3.11 to the map i δ ′ δ : X δ → X δ ′ , we have a commutative diagram In particular, the injections H Dir n (X δ , R) ֒→ H n (X δ , R) δ∈T give rise to a monomorphism of persistence modules.
We can now introduce persistence diagrams and barcodes associated to filtrations of directed simplicial complexes. As these were only introduced for fields in Section 2.1, from this point on, we will assume that R is a field. In particular, when taking directed homology, we will assume that R ∈ {Q, R}.
Definition 4.5. Let (X δ ) δ∈T be a filtration of a directed simplicial complex X where T ⊆ R is finite. The persistence diagrams associated to the n-dimensional undirected and directed persistence R-modules of X are respectively denoted Dgm n (X, R) and Dgm Dir n (X, R). Similarly, the respective barcodes are denoted Pers n (X, R) and Pers Dir n (X, R).
Remark 4.6. Note that H Dir 0 (X δ , R) ∼ = H 0 (X δ , R) for every δ ∈ T , as shown in Proposition 3.18. As a consequence, the 0-dimensional directed and undirected persistence R-modules of a directed simplicial complex X are isomorphic. In particular, they have the same persistence barcodes and diagrams, and they measure the connectivity of the simplicial complex at each stage of the filtration.
The next result establishes the relation between the undirected and directed persistence barcodes and diagrams of a persistence module, and it is thus key to understanding the directed persistence barcodes. Note that a bar in the directed persistence barcode of a filtration may be born after the one it is matched with in the undirected one, and some bars in the undirected barcode may remain unmatched (see Examples below and Figures 5 and 6).
We now introduce some examples to illustrate Proposition 4.7 and the general behaviour of the directed persistence barcodes.
Example 4.8. Let us illustrate how undirected and directed persistence modules and their barcodes can be different. First, consider the directed simplicial complexes X and Y in Figure 3 (see Example 3.23). Regardless of the filtration chosen for X, the lack of directed cycles means that the 1-dimensional directed persistence module is trivial. However, at the end of the filtration, there is a cycle in homology, thus there is a bar in the undirected persistence barcode. In the case of Y , the only 1-cycle is directed, so the undirected and directed persistence modules associated to any filtration of Y are isomorphic, and different from those of X.
These two classes become equivalent in Z 3 . The undirected and directed 1-dimensional persistence barcodes of this filtration, shown in Figure 5, illustrate how undirected classes may become directed.
The last example also shows an important difference between classical and directed persistence modules and barcodes. Namely, in the undirected setting, the addition of one simplex to the filtration can either cause the birth of a class in the dimension of the added simplex, or kill a class in the preceding dimension. This simple idea is in fact the basis of the Standard Algorithm for computing persistent homology. However, the addition of only one simplex to a directed simplicial complex can cause the birth of several classes in directed homology, as shown in the previous example at δ = 2, and also in the following example. Figure 5. A filtration of the directed simplicial complex Z in Example 3.23 ( Figure 3) and its associated undirected (bottom, left) and directed (bottom, right) 1-dimensional persistence barcodes. The shorter undirected bar (blue) is also directed, while the longer undirected bar (red) becomes directed at δ = 2.   Figure 2 in the Introduction, where X δ = X 3 for every δ ≥ 3. It is clear that Z Dir 1 (X j , R) is trivial for j = 0, 1, 2, whereas undirected cycles appear as early as X 1 . However, by adding the edge from v 5 to v 1 , several directed cycles are born at once. Namely, Z Dir 1 (X 3 , R) contains the cycles Straightforward computations show that H 1 (X 3 , R) = R 4 , and four of the cycles above are linearly independent, thus H Dir 1 (X 3 , R) = H 1 (X 3 , R) = R 4 . Consequently, at δ = 3 every class (including the birthing one) becomes directed.
Our last example shows an undirected homology class that never becomes directed.

4.2.
Directed persistent homology of dissimilarity functions. In this section, we introduce the undirected and directed persistence diagrams and barcodes associated to dissimilarity functions (Definition 4.13) and prove their stability with respect to the bottleneck distance (Theorem 4.19).
Let us begin by introducing the directed Rips filtration of directed simplicial complexes associated to a dissimilarity function, [25,Definition 16].
Let us now introduce the persistent homology modules associated to such a filtration. Assume that R ∈ {Q, R}.
Definition 4.13. Let (V, d V ) be a dissimilarity function and consider its associated directed Rips Remark 4.14. The persistence module H n (V, d V ) associated to the directed Rips filtration of (V, d V ) is precisely the persistence module studied in [25,Section 5], hence the remarks made there hold for the undirected persistence module.
is the (classical) Vietoris-Rips filtration of (V, d V ). Furthermore, in this case, it can easily be seen . Thus, these persistence modules generalise the persistence modules associated to the Vietoris-Rips filtration of a metric space. Also note that R Dir (V, d V ) is closed under adjacent repeats, [25,Definition 18]. Namely, given . . , v n ) ∈ R Dir (V, d V ) δ , for any i = 0, 1, . . . , n. Using this, it can be proven that the homology of this object must be trivial in dimensions larger than |V | + 1.
As R is a field and since V is finite, both of these persistence modules fulfil the assumptions in Section 2.1. Namely, their indexing sets can be chosen to be finite, corresponding to the threshold values where new simplices are added to the simplicial complex. Furthermore, no simplex is added to the filtration until the threshold value reaches the minimum of the images of the dissimilarity function. Finally, and even though the directed simplicial complex R Dir (V, d V ) δ may have infinite simplices due to arbitrary repetitions of vertices being allowed, it always has a finite number of simplices in a given dimension n, thus its n-dimensional homology is always finite-dimensional. As a consequence, we can introduce the following. Of course, Proposition 4.7 holds for these barcodes, namely, every bar in Pers Dir n (V, d V ) can be uniquely matched with one in Pers n (V, d V ) which dies at the same time, although the directed bar may be born later.
We now use results from Section 2.2 to show that both these persistent homology constructions are stable. The proof is split in several lemmas. Let (V, d V ) and (W, d W ) be two dissimilarity functions on respective sets V and W and define η = 2d CD (V, d V ), (W, d W ) , where d CD is the correspondence distortion distance (Definition 2.9). By Proposition 2.11, we can find maps ϕ : V → W and ψ : W → V such that dis(ϕ), dis(ψ), codis(ϕ, ψ), codis(ψ, ϕ) ≤ η. To simplify notation in the proofs below, denote R Dir (V, d V ) δ = X δ V and R Dir (W, d W ) δ = X δ W , for all δ ∈ R.
The following are commutative diagrams of morphisms of directed simplicial complexes: We prove that the first diagram is commutative (the proof for the second diagram is analogous).
. Lemma 4.18. With the same notation as in Lemmas 4.16 and 4.17, for every δ ∈ R, the following diagrams of morphisms of directed simplicial complexes induce commutative diagrams on homology.
Proof. Again, we only prove the result for the first diagram, as the proof for the second diagram is analogous. We show that it is commutative up to homotopy by showing that the maps i δ+2η δ and ψ δ+η • ϕ δ satisfy the hypothesis of Lemma 3.14.
We now have everything we need to prove the stability results.
. By Theorem 2.7, it suffices to show that the persistence modules H n (V, d V ) and H n (W, d W ) (respectively H Dir n (V, d V ) and H Dir n (W, d W )) are η-interleaved. Comparing Definition 2.5 (for ε = η) and Lemmas 4.16, 4.17 and 4.18, the result follows by using the functoriality of homology and, in the directed case, Proposition 3.11.
Remark 4.20. Recall from Remark 4.14 that the persistence module H n (V, d V ) associated to the directed Rips filtration of (V, d V ) is the persistence module studied in [25,Section 5]. Thus, the remarks made in [25, Section 5.2] hold for these persistence modules, meaning that a result analogous to Theorem 4.19 would not hold if we were using ordered-set complexes instead of directed simplicial complexes, as mentioned at the beginning of Section 3. This justifies our definition of directed simplicial complex (Definition 3.1).

Computational challenges
Let (V, d V ) be a dissimilarity function in a finite set V . In this section, we study the algorithmic aspects of computing both H n (V, d V ) and H Dir n (V, d V ). For simplicity, we assume that R = R. The computation of the persistence barcodes for the undirected persistent homology H n (V, d V ) can be made using the Standard Algorithm [9,26], which also applies to ordered simplicial complexes. Write R Dir (V, d V ) δ = X δ V , δ ∈ R for the directed Rips filtration (Definition 4.12). As V is finite, the number of simplices in X δ V up to dimension n + 1 is finite, say N . We can list them {σ 1 , σ 2 , . . . , σ N } in such a way that i < j if σ i is a (proper) face of σ j , or if σ j appears 'later' in the filtration, thus having a compatible ordering. Then, we can represent the differential using a sparse N × N matrix M over R, where the (i, j)-entry M ij is the coefficient of σ j in the differential of σ i . Such matrix M is an upper-triangular matrix. At this stage, the Standard Algorithm can be used to compute Dgm k (V, d V ) by reducing M at once using column operations.
We cannot directly adapt the Standard Algorithm to compute Dgm Dir k (V, d V ): we can try to find reduction operations that generate directed cycles using operations with positive coefficients only, but this is not enough to guarantee that we find all the possible directed cycles. For instance, once one column has been eliminated, we may be preventing the participation of the simplex it represents in directed cycles not involving the columns we are using in the elimination. To avoid such a problem, we would need to keep track of every possible way in which column eliminations can be produced using only positive coefficients. This is very similar to the double description algorithm for the computation of extreme rays of a polyhedral cone [12,16]. Indeed, the directed cycles Z Dir n (X, R) are the non-negative solutions to the linear equation M x = 0, that is, where a vector x = (x 1 , x 2 , . . . , x N ) ∈ R N represents the cycle N i=1 x i σ i , M is the matrix corresponding to the differential, and x ≥ 0 means that every entry in x is non-negative, that is, x i ≥ 0 for all i. Equivalently, directed cycles are the extreme rays of the unbounded polyhedral cone consisting of the intersection of the solution space to the linear system M x = 0 with the first quadrant of R N . The enumeration of the extreme rays (generators of the solution set) of a polyhedral cone such as Eq. (5.1) is a well-known albeit hard problem in computational geometry. Several algorithms, including the double description algorithm, and modifications thereof, exist [24].
Note, however, that we do not require the computation of all the directed cycles. Indeed, it would be enough to calculate them up to homology, which suggests that efficient computations may be possible.
In summary, although important challenges remain on the computation of the persistence diagrams associated to directed persistence modules, our objective was to provide the necessary groundwork for the study of directed persistent homology of asymmetric data sets, and we are hopeful that we are opening up an exciting new approach for future research into the topological properties of asymmetric data sets.
Acknowledgements. This work was supported by The Alan Turing Institute under the EPSRC grant EP/N510129/1. The first author was partially supported by Ministerio de Economía y Competitividad (Spain) Grants Nos. MTM2016-79661-P and MTM2016-78647-P and by Ministerio de Ciencia, Innovación y Universidades (Spain) Grant No. PGC2018-095448-B-I00.
Appendix A. Directed persistent homology via semiring homology As mentioned in the Introduction, our ideas of directed homology are based on homology with semiring coefficients, which can be introduced for directed simplicial complexes using chain complexes of semimodules and their associated homologies, building on work by Patchkoria [19,20]. In this appendix, we introduce this homology theory and explain how it relates to the modules of directed homology introduced in Definition 3.6.
A.1. Semirings, semimodules and their completions. Let us begin by introducing the algebraic structures that we need, following [13].
Example A.2. Every ring is a semiring. The non-negative integers, rationals and reals with their usual operations, respectively denoted N, Q + and R + , are cancellative zerosumfree commutative semirings which are not rings. Definition A.3. Let Λ be a semiring. A (left) Λ-semimodule is an abelian monoid (A, +) with identity element 0 A together with a map Λ × A → A which we denote (λ, a) → λa and such that for all λ, λ ′ ∈ Λ and a, a ′ ∈ A, • (λλ ′ )a = λ(λ ′ a), • λ(a + a ′ ) = λa + λa ′ , is closed under addition and scalar multiplication, which implies that B is a left Λ-semimodule with identity element 0 A ∈ B. If A and B are Λ-semimodules, a Λ-homomorphism is a map f : A → B such that for all a, a ′ ∈ A and for all λ ∈ Λ, A Λ-semimodule A is cancellative if a + a ′ = a + a ′′ implies a ′ = a ′′ , and zerosumfree if a + a ′ = 0 implies a = a ′ = 0, for all a, a ′ , a ′′ ∈ A.
The Cartesian product of Λ-semimodules is a Λ-semimodule. The definition of direct sum of modules can be generalised to the framework of Λ-semimodules, and a finite direct sum of Λ-semimodules is isomorphic to the Cartesian product of the same Λ-semimodules. Quotient Λ-semimodules can be defined using congruence relations.
If B is a subsemimodule of a Λ-semimodule A, then it determines a Λ-congruence ∼ B by setting a ∼ B a ′ if there exist b, b ′ ∈ B such that a + b = a ′ + b ′ . Classes in this quotient are denoted a/B, and the factor semimodule is denoted A/B. If Λ is a ring, this is just the usual quotient module of A by B.
Example A.5. The following are examples of factor semimodules.
• If Λ is a ring and B ≤ A are Λ-modules, the factor semimodule A/B is the usual module quotient of A by B.
It is immediate to show that ρ is a N-congruence, and the factor semimodule (N × N)/ρ is isomorphic to Z. Indeed, consider the map shows that it is well-defined and injective, and it is clearly surjective.
Clearly, if Λ is a semiring then it is a Λ-semimodule over itself. The idea of free Λ-semimodules comes about naturally just as in the case of rings, and we will make extensive use of these objects.
Definition A.6. Let Λ be a semiring, A a left Λ-semimodule and V = {v 1 , v 2 , . . . , v n } a finite subset of A. The set V is a generating set for A if every element in A is a linear combination of elements of V . The rank of a Λ-semimodule A, denoted rank(A), is the least n for which there is a set of generators of A with cardinality n, or infinity, if not such n exists.
The set V is linearly independent if for any λ 1 , λ 2 , . . . , λ n ∈ Λ and µ 1 , µ 2 , . . . , µ n ∈ Λ such that n i=1 λ i v i = n i=1 µ i v i , then λ i = µ i , for i = 1, 2, . . . , n, and it is called linearly dependent otherwise. We call V is a basis of A if it is a linearly independent generating set of A.
Remark A.7. It is easy to check that free Λ-semimodules over a cancellative semiring Λ are themselves cancellative, as are subsemimodules of cancellative Λ-semimodules. The quotient of a cancellative Λ-semimodule over any of its subsemimodules is also cancellative, see [13,Proposition 15.24].
Note that if Λ is a ring, free Λ-semimodules are just free Λ-modules. Thus, as not every module over a ring is free, clearly not every Λ-semimodule is free. On the other hand, Λ n (the direct sum, or product, of n copies of Λ) is clearly a free Λ-semimodule, for every n ≥ 1. Another key property is that if A is a free Λ-semimodule with basis V and B is another Λ-semimodule, each map V → B uniquely extends to a Λ-homomorphism A → B, see [13,Proposition 17.12].
Remark A.8. If Λ is a commutative semiring and A is a Λ-semimodule admitting a finite basis, every basis has the same cardinality, which coincides with the rank of A, [23,Theorem 3.4]. In fact, for every integer n > 0, every finitely generated subsemimodule of N n has a unique basis, whereas basis for semimodules of (R + ) n are unique up to non-zero multiples, see e.g. [15,Theorem 2.1].
We finish this section by extending the Grothendieck construction from abelian monoids to semirings and semimodules. Definition A.10. Let Λ be a semiring. The group completion K(Λ) becomes a ring with the operation [x 1 , x 2 ] · [y 1 , y 2 ] = [x 1 y 1 + x 2 y 2 , x 2 y 1 + x 1 y 2 ], and k Λ : Λ → K(Λ) is in fact a morphism of semirings, which is injective if Λ is cancellative. We call K(Λ) the ring completion of Λ. If f : Λ → Λ ′ is a morphism of semirings, the map K(f ) : K(Λ) → K(Λ ′ ) as introduced in Definition A.9 is a morphism of rings, and K is a functor from the category of semirings to the category of rings.
If A is a Λ-semimodule, then the abelian group K(A) together with the operation A.2. Chain complexes of semimodules. Now that we have introduced the necessary algebraic structures, we move on to chain complexes of semimodules over semirings, following [20]. This theory is a natural generalisation of the classical theory of chain complexes of modules and, in fact, they give rise to the same cycles, boundaries and homologies when the semimodules are modules over a ring.
In order to introduce chain complexes in the context of semimodules an immediate problem arises: alternating sums cannot be defined as elements in a semimodule may not have inverses. The solution is to use two maps, a positive and negative part, for the differentials.
Definition A.11. Let Λ be a semiring and consider a sequence of Λ-semimodules and homomorphisms indexed by n ∈ Z X : · · · ⇒ X n+1 We say that . As in the classical case, chain complexes of Λ-semimodules give rise to a Λ-semimodule of homology.
Definition A.12. Let X = {X n , ∂ + n , ∂ − n } be a chain complex of Λ-semimodules. The Λ-semimodule of cycles of X is Z n (X, Λ) = {x ∈ X n | ∂ + n (x) = ∂ − n (x)}. The nth homology of X is then the quotient Λ-semimodule H n (X, Λ) = Z n (X, Λ)/ρ n (X, Λ) where ρ n (X, Λ) is the following Λ-congruence relation on Z n (X, Λ): . We will omit from now on the coefficient semiring Λ from the notation when it is clear from the context.
Remark A. 13. The definition of cycle is a direct generalisation of the classical definition. For the boundary relation, note that we may need two different chains u and v in order to establish two classes as homologous. Intuitively, these two classes are the 'positive' and 'negative' part of w, where x = y + ∂(w) in the classical setting.
Remark A.14. If X = {X n , ∂ + n , ∂ − n } is a chain complex of Λ-semimodules, then · · · −→ K(X n+1 ) is a chain complex of K(Λ)-modules. If furthermore the Λ-semimodules X n are cancellative for all n, the converse is also true. If Λ is a ring, then K(Λ) = Λ and the functor K acts as the identity on Λ-modules. Therefore, X = {X n , ∂ + n , ∂ − n } is a chain complex of Λ-semimodules if and only if · · · −→ X n+1 is a chain complex of Λ-modules. In this case, it is clear that the homology semimodules introduced in Definition A.12 are precisely the usual homology modules of X.
We remark that a similar idea of decomposition of differentials in a positive and negative components has been used by Steiner to relate ω-categories with the so-called augmented directed complexes, [22]. These structures share, in fact, a deep similarity with Patchkoria's chain complexes with semiring coefficients.
We now turn our attention to maps between complexes.
It is clear that for such a map f n Z n (X) is a Λ-subsemimodule of Z n (X ′ ). Furthermore, if X n and X ′ n are cancellative Λ-semimodules, f is also compatible with the congruence relations ρ n (X) and ρ n (X ′ ), so it induces a map H n (f ) : H n (X) → H n (X ′ ). It is then easy to check that homology H * is a functor from the category of chain complexes of cancellative Λ-semimodules and morphisms to the category of graded Λ-semimodules.
Remark A. 16. Let Λ be a semiring and let {X n , ∂ + n , ∂ − n } be a chain complex of Λ-semimodules. The family of canonical maps k Xn : X n → K(X n ) gives rise to a morphism from {X n , ∂ + n , ∂ − n } to K(X n ), K(∂ + n ), K(∂ − n ) and, therefore, to a morphism of Λ-semimodules H(k X ) : H n (X) → H n K(X) , which takes the class of x to the class of [x, 0]. Furthermore, if the Λ-semimodules X n are cancellative, H n (k X ) is injective, which in particular implies that H n (X) is a cancellative Λ-semimodule. Also note that, by Remark A.14, the homology of K(X n ), K(∂ + n ), K(∂ − n ) and the usual homology of K(X n ), K(∂ + n ) − K(∂ − n ) are isomorphic as K(Λ)-modules. Finally, we discuss chain homotopies.
We say that f is homotopic to g if there exist Λ-homomorphisms s + n , s − n : X n → X ′ n+1 such that all n. The family {s + n , s − n } is called a chain homotopy from f to g, and we write (s + , s − ) : f ≃ g. We then have the following result.
Homotopy equivalences are defined in the usual way and they induce isomorphisms on homology. We finish with a remark that the homotopy of maps behaves well with respect to semimodule completion.
Remark A. 19. If a morphism f : X → X ′ is homotopic to g : X → X ′ , then K(f ) : K(X) → K(X ′ ) is homotopic to K(g) : K(X) → K(X ′ ). Furthermore, if both X n and X ′ n are cancellative Λ-semimodules, for all n, and X n is a free Λ-semimodule for all n, the converse is also true.
A.3. Chain complexes of semimodules of directed simplicial complexes. In this section, we introduce chain complexes of semimodules and homology semimodules of directed simplicial complexes, Definition 3.1. The results introduced here directly generalise those in Section 3.
Definition A.20. The n-dimensional chains of a directed simplicial complex X are defined as the elements of the free Λ-semimodule generated by (i.e. with basis) the n-simplices, We call the elements [x 0 , x 1 , . . . , x n ] ∈ C n (X, Λ), (x 0 , x 1 , . . . , x n ) ∈ X, elementary n-chains.
Remark A.21. Note that if Λ is a cancellative semiring, the Λ-semimodule C n (X, Λ) is cancellative for every n, as it is a free semimodule over a cancellative semiring.
We now define the positive and negative differentials on C n (X, Λ).
Definition A. 22. Let X be a directed simplicial complex. For each n > 0, we define morphisms of Λ-semimodules ∂ + n , ∂ − n : C n (X, Λ) → C n−1 (X, Λ) by . , x 2i , . . . , x n ], and For n = 0, let ∂ + 0 , ∂ − 0 : C 0 (X, Λ) → {0} be the trivial maps, by definition. Proposition A. 23. Let X be a directed simplicial complex and Λ be a cancellative semiring. Then {C n (X, Λ), ∂ + n , ∂ − n } is a chain complex of modules of Λ-semimodules. Proof. By Remark A.21, the Λ-semimodule C n (X, Λ) is cancellative for every n. Thus, by Remark A.14, it is enough to prove that K C n (X, Λ) , K(∂ + n )−K(∂ − n ) is a chain complex of K(Λ)-modules. Note that K C n (X, Λ) is a free K(Λ)-module whose basis is given by elements [x 0 , x 1 , . . . , x n ], 0 such that [x 0 , x 1 , . . . , x n ] is an elementary n-chain. Thus, it suffices to show that the composition is trivial (zero) on these elements. Since the proof is now a straightforward computation analogous to the standard one for chain complexes in simplicial homology.
Proposition A.23 allows us to define the homology of a directed simplicial complex with coefficients on a semiring.
Definition A. 24. Let X be a directed simplicial complex and n ≥ 0 and Λ a cancellative semiring. The n-dimensional homology of X, written H n (X, Λ), is the nth homology Λ-semimodule of the chain complex {C n (X, Λ), ∂ + n , ∂ − n }. Remark A.25. If Λ is a ring, by defining ∂ = ∂ + − ∂ + , {C n (X, Λ), ∂} is a chain complex in the usual sense. In fact, it is precisely the chain complex introduced in Definition 3.3. Thus, as a consequence of Remark A.14, the homology theory introduced in Definition A.24 coincides with the one introduced in Definition 3.4. Therefore, homology with semiring coefficients of directed simplicial complexes is a non-trivial generalisation of homology with ring coefficients.
The following result will become useful later on, so we recorded it here.
Proof. Take n ≥ 0 an integer. By definition, C n X, K(Λ) is the free K(Λ)-module over the ele- A.4. Functoriality of semiring homology. In this section, we prove that homology is a functor from the category of directed simplicial complexes to the category of graded Λ-semimodules. We also show that two morphisms allowing for the construction of the prism operator must induce the same map on homology, a result we will need to prove our persistent homology stability result. Recall the definition of morphism of directed simplicial complexes, Definition 3.8. Proof. Simple computations show that f n−1 ∂ + n = ∂ + n f n and that f n−1 ∂ − n = ∂ − n f n . Remark A.29. As a consequence of Proposition A.26, the map C n (f ) : C n X, K(Λ) → C n Y, K(Λ) is precisely K C n (f ) : K C n (X, Λ) → K C n (Y, Λ) .
Corollary A.30. Homology is a functor from the category of directed simplicial complexes to the category of graded Λ-semimodules. In particular, isomorphic directed simplicial complexes have isomorphic homologies. Note further that when Λ is a ring, the homology functor is precisely the functor introduced in Section 3.2.
We finish this section by showing a sufficient condition for two morphisms to induce the same map on homology. We will need this result to prove that our definition of persistent homology is stable.
Lemma A.31. Let Λ be a cancellative semiring. Let X and Y be two directed simplicial complexes and let f, g : X → Y be morphisms of directed simplicial complexes such that if (x 0 , x 1 , . . . , x n ) ∈ X, then f (x 0 ), f (x 1 ), . . . , f (x i ), g(x i ), . . . , g(x n ) ∈ Y for every i = 0, 1, . . . , n. Then, H n (f ) = H n (g) for every n ≥ 0. Now recall that since Λ is cancellative, the canonical map k n : C n (X, Λ) → K C n (X, Λ) is injective for all n. We will show that (s + , s − ) : C(f ) ≃ C(g) by proving that both sides of the equality in Definition A.17 have the same images through k n . We will also make use of the isomorphism K C n (X, Λ) ∼ = C n X, K(Λ) established in Proposition A.26, and that for any Λ-morphism h : C n (X, Λ) → C n (X, Λ), k n • h = K(h) • k n . By abuse of notation, we write k n (x) = x = [x 0 , x 1 , . . . , x n ] ∈ C n X, K(Λ) . Denote ∂ n = K(∂ + n ) − K(∂ − n ) and s n = K(s + n ) − K(s − n ). Then, . . , f (x j ), g(x j ), . . . , g(x n ) .
Note that, by appropriately grouping the terms in the equality in Definition A.17, it suffices to show that K(g n ) − K(f n ) and ∂ n+1 s n + s n−1 ∂ n have the same image on x. These computations are analogous to the ones in Lemma 3.14.
A.5. Comparison to directed homology and relation to persistence. In Section 3, directed homology modules were introduced by taking submodules of homology generated by cycles with only non-negative coefficients on the elementary chains. This was done for the rings Z, Q, and R. These three rings have in common that they are the Grothendieck's completion of a cancellative, zerosumfree semiring. Namely, Z = K(N), Q = K(Q + ), R = K(R + ). It turns out that homology with coefficients in this class of semirings has the ability to detect directed cycles, and what we have introduced in the main body of this article is a particular case of this fact.
Proposition A.32. Let Λ ∈ {N, Q + , R + } and let X be a directed simplicial complex. Consider Z Dir n X, K(Λ) the set of directed cycles introduced in Definition 3.6. Then, Z Dir n X, K(Λ) ∼ = Z n (X, Λ) as Λ-semimodules.
Proof. First note that for the considered semirings, Λ can be seen as the non-negative elements of K(Λ). Using this identification, it is straightforward to show that Z Dir n X, K(Λ) is a Λ-semimodule. In particular, linear combinations of directed cycles with non-negative coefficients are directed cycles.
By abuse of notation, we will denote elementary n-chains in the same way in C n (X, Λ) and in C n X, K(Λ) . Assume that n i=1 λ i c i ∈ Z n (X, Λ). Then clearly n i=1 λ i c i ∈ Z n X, K(Λ) (see Proposition A.26). Furthermore, since the involved coefficients are non-negative, n i=1 λ i c i ∈ Z Dir n X, K(Λ) . Consequently, we can introduce a map ϕ : Z n (X, Λ) −→ Z Dir n X, K(Λ) It is immediate to check that ϕ is a morphism of Λ-semimodules. It is also injective. We only need to prove that it is surjective. For that, it would be enough to prove that if n i=1 λ i c i ∈ Z Dir n X, K(Λ) , then n i=1 λ i c i ∈ Z n (X, Λ). To that purpose, note that x = n i=1 λ i c i can be regarded as an element of C n (X, Λ) as the involved coefficients are non-negative, and thus, in Λ. We only need to prove that ∂ + (x) = ∂ − (x). Since Λ is cancellative, it is enough to prove that K ∂ + (x) = K ∂ − (x) , or equivalently, that K ∂ + (x) − K ∂ − (x) = 0. But this follows from Proposition A.26 and from the fact that x ∈ Z n X, K(Λ) .
In general, we could use homology with coefficients in a cancellative, zerosumfree semiring to detect directed cycles. Namely, we can prove an analogous to Proposition 3.24 for homology with semiring coefficients.