#import "template.typ": *
#show: thmrules
#show: project.with(
  title: "Discrete Morse Theory for Persistent Homology for Sequences of Cosheaves",
  subtitle: [A mini-project submitted for the course of
  
   _C3.9 Computational Algebraic Topology_],
  author: "Candidate Number 1079278", 
  date: "Hilary Term, 2024"
)

#pagebreak()

// #TODO[reminder: add punctuations to displayed formulae]
= Introduction

The goal of this project is to describe how discrete Morse theory can be used to simplify the computation of persistent homology for sequences of cosheaves over finite simplicial complexes.
Throughout this project, let $K$ be a finite simplicial complex and let $FF$ be a field.

= Cosheaf Homology
 Write $(K, >=)$ for the poset of simplices in $K$ ordered by coface relations, which can also be naturally seen as a category, where each simplex in $K$ is an object and each coface relation $tau >= sigma$ is a morphism $tau -> sigma$. 
#definition[
  A *cosheaf over $K$* which takes values in $FF$-vector spaces  is a functor $cC : (K, >=) -> VF$.
  In other words, $cC$ assigns 
  + to each simplex $tau$ of $K$ a finite-dimensional vector space $cC(tau)$ over $RR$, and
  + to each coface relation $tau >= sigma$ a linear map $cC(tau >= sigma) : cC(tau) -> cC(sigma)$,
  subject to the following axioms:
  + for every simplex $tau$ in $K$, the map $cC(tau >= tau)$ is the identity on $cC(tau)$, and 
  + for each triple $tau >= sigma >= rho $ in $K$, we have $cC(sigma >= rho) oo cC(tau >= sigma) = cC(tau >= rho)$.
]
<def-cosheaf>
#example[
Write $FVR$ for the category of finite-dimensional vector spaces over $RR$. In particular, a cosheaf over $K$ which takes values in finite-dimensional real vector spaces is a functor $cD : (K , >=) -> FVR$. 
]

Now fix a cosheaf $cC : (K, >=) -> VF$ over $K$.

#notation[
  Denote
    $
    [sigma : tau] := cases(
      +1 quad &sigma = tau_(-j) " for " j "even,",
      -1 quad &sigma = tau_(-j) " for " j "odd,",
      0 quad &"otherwise."
    )
  $
  Then define $cC_(tau, sigma) : cC(tau) -> cC(sigma)$ as 
  $cC_(tau, sigma) := [sigma : tau] dot cC (tau >= sigma) 
    // = cases(
    //   + cC (tau >= sigma) quad & sigma = tau_(-j) "for even " j comma ,
    //   - cC (tau >= sigma) quad & sigma = tau_(-j) "for odd " j comma , 
    //   0 quad & "otherwise." 
    // )
  $.
  ]
<sign-adjustment>

#definition[
  For each dimension $k>=0$, the vector space of *$k$-chains of $K$* with $cC$-coefficients is the product 
  $bC_k (K; cC) = product_(dim tau = k) cC(tau).
  $
  For each $k >= 0$, the $k$-th *boundary map* of $K$ with $cC$-coefficients is the linear map 
  $diff^cC_k : bC_k (K ; cC) -> bC_(k+1) (K ; cC),
  $
  defined such that for each pair of simplices $tau >= sigma$ with $dim tau = k$ and $dim sigma = k - 1$, the $cC(tau) -> cC(sigma)$ component of $diff^cC_k$ is given by 
  $diff^cC_k|_(tau, sigma) = cC_(tau, sigma).
  $
]
<def-cosheaf-chain>

#let ct(k, co: cC) = [$bC_#k (K; #co)$]
#let cf(k, co: cC) = [$diff^#co _ #k$]
#let cfa(k, co: cC) = [$->^cf(#k, co: co)$]
#let cft(k, co: cC) = [$ ct(#k, co: co) cfa(#k, co: co)$]

#proposition[
  The sequence $bC_cx (K; cC)$
  $
    ... cfa(k+1) cft(k)  ... cfa(2) cft(1) ct(0) -> 0
  $
   is a chain complex over $FF$. 
]
<cosheaf-is-chain>
#proof[
  This is analogous to @notes[Proposition 7.8]. It suffices to show that for any $(k+1)$-simplex $tau$ and any $(k-1)$-simplex $tau''$, the $cC(tau) -> cC(tau'')$ component of the composition $diff^cC _(k) oo diff^cC_(k+1)$ is zero. We compute 
  $
    (diff^cC _(k) oo diff^cC_(k+1))|_(tau, tau'') &= sum_(dim tau' = k) diff^cC_(k)|_(tau', tau'') oo diff^cC_(k+1) |_(tau, tau') \
    &= sum_(dim tau' = k) [tau'' : tau'][tau' : tau] dot cC (tau' >= tau'') oo   cC (tau >= tau') \
    // &= sum_(dim tau' = k) [tau'' : tau'][tau' : tau] dot cC (tau >= tau'') \ 
    &= (sum_(dim tau' = k) [tau'' : tau'][tau' : tau]) dot cC (tau >= tau''), \ 
    // &= 0,
  $
  where $cC (tau' >= tau'') oo   cC (tau >= tau') = cC (tau >= tau'')$ by the associativity axiom and $sum_(dim tau' = k) [tau'' : tau'][tau' : tau] = 0$ because it is the coefficient from $tau$ to $tau''$ in $diff_k^K oo diff_(k+1)^K$.
]

#definition[
  For each dimension $k >= 0$, the *$k$-th homology group of $K$ with coefficients in $cC$* is defined by 
  $bH_cx (K; cC) := Ker(cf(k)) over Im(cf(k+1)).
  $
]
<cosheaf-homology-groups>

#definition[
  Let $V$ be a $FF$-vector space.
  The *constant cosheaf* $underline(V)_K : (K , >=) &-> VF$ is the functor which sends any simplex $tau$ in $K$ to $V$ and any coface relation $tau >= sigma$ to the identity map $id_V$.
  
  //  is the functor given as follows:  
  // $
  //   underline(V)_K : (K , >=) &-> VF \
  //   tau &mapsto V \
  //   (tau >= sigma) &mapsto id_V.
  // $
]
<constant-cosheaf>

= Morphism of Cosheaves
Let $cC$ and $cC'$ be two cosheaves over $K$. 

#definition[
  A *morphism of cosheaves* over $K$ is a natural transformation $Phi : cC -> cC'$. In other words, $Phi$ consists of the following data: for each $tau in K$, there is a linear map $Phi_tau : cC(tau) -> cC'(tau)$, such that the following diagram of linear maps commutes for each $tau >= sigma$:
  // https://t.yw.je/#N4Igdg9gJgpgziAXAbVABwnAlgFyxMJZABgBpiBdUkANwEMAbAVxiRAGMBhAChzqYCUIAL6l0mXPkIoyARiq1GLNl27YA5gFs6Q0eOx4CRWeQX1mrRB04ByXv11iQGA1OOl51c8qtc7G7V0FGCh1eCJQADMAJwhNJDIQHAgkE0ULFR4+JgACAD4AXhyAnREnGLikACZqZKQAZi8lS2s7bPyiksco2PjERLrEGvSfEAAFAAssAH1ssp<KEY>
#align(center, commutative-diagram(
  node-padding: (70pt, 50pt),
  node((0, 0), [$cC(tau)$]),
  node((1, 0), [$cC(sigma)$]),
  node((0, 1), [$cC'(tau)$]),
  node((1, 1), [$cC'(sigma).$]),
  arr((0, 0), (1, 0), [$cC(tau >= sigma)$]),
  arr((0, 1), (1, 1), [$cC'(tau >= sigma)$]),
  arr((0, 0), (0, 1), [$Phi_tau$]),
  arr((1, 0), (1, 1), [$Phi_sigma$]),
))
]
<morphism-of-cosheaves>

Now fix a morphism $Phi : cC -> cC'$ of cosheaves. 

#proposition[
  $Phi : cC -> cC'$ induces a chain map $bC_cx (K; cC) -> bC_cx (K; cC')$.
]
<morphism-induce-chain>
#proof[
  For each $k>=0$ and any $k$-simplices  $tau$ and $tau'$  in $K$, define $Phi_k : bC_k (K; cC) -> bC_k (K; cC')$ as the linear map whose $cC(tau) -> cC'(tau')$ component is 
  $
    cases(Phi_tau quad & tau = tau' comma, 
    0 quad &  "otherwise".)
  $
  We claim that ${Phi_k}_(k>=0)$ is a chain map $bC_cx (K; cC) -> bC_cx (K; cC')$, i.e., the following diagram commutes:

// https://t.yw.je/#N4Igdg9gJgpgziAXAbVABwnAlgFyxMJZABgBpiBdUk<KEY>
#align(center, commutative-diagram(
  node-padding: (70pt, 50pt),
  node((0, 0), [$bC_k (K; cC)$]),
  node((0, 1), [$bC_(k-1) (K; cC)$]),
  node((1, 0), [$bC_k (K; cC')$]),
  node((1, 1), [$bC_(k-1) (K; cC').$]),
  arr((0, 0), (1, 0), [$Phi_k$]),
  arr((0, 1), (1, 1), [$Phi_(k-1)$]),
  arr((0, 0), (0, 1), [$diff_k^cC$]),
  arr((1, 0), (1, 1), [$diff_k^(cC')$]),
))

  By linearity and by how we define each $Phi_k$, it suffices to consider an arbitrary pair of simplices $tau >= sigma$ such that $dim tau = k$ and $dim sigma = k - 1$, in which case the above diagram becomes:
  
    // https://t.yw.je/#N4Igdg9gJgpgziAXAbVABwnAlgFyxMJZABgBpiBdUkANwEMAbAVxiRAGMBhAChzqYCUIAL6l0mXPkIoAjOSq1GLNl27YA5gFs6Q0eOx4CRMjIX1mrRB04ByAAS<KEY>
#align(center, commutative-diagram(
  node-padding: (100pt, 50pt),
  node((0, 0), [$cC(tau)$]),
  node((0, 1), [$cC(sigma)$]),
  node((1, 0), [$cC' (tau)$]),
  node((1, 1), [$cC' (sigma),$]),
  arr((0, 0), (0, 1), [$[sigma : tau] dot cC(tau >= sigma)$]),
  arr((1, 0), (1, 1), [$[sigma : tau] dot cC'(tau >= sigma)$]),
  arr((0, 0), (1, 0), [$Phi_tau$]),
  arr((0, 1), (1, 1), [$Phi_sigma$]),
))
  which commutes by @morphism-of-cosheaves.
]

#corollary[
  $Phi : cC -> cC'$ induces a map on homology groups $bH_cx Phi : bH_cx (K; cC) -> bH_cx (K; cC')$.
]
<morphism-induce-homology>
#proof[
  By the functoriality of homology, i.e., @notes[Proposition 4.7].
]

#definition[
  Let $Phi : cC -> cC'$ be a morphism of cosheaves.
  - $Phi$ is a *monomorphism* if each $Phi_tau : cC(tau) -> cC'(tau)$ is injective;
  - $Phi$ is an *epimorphism* if each $Phi_tau : cC(tau) -> cC'(tau)$ is surjective; and
  - $Phi$ is an *isomorphism* if each $Phi_tau : cC(tau) -> cC'(tau)$ is an isomorphism.

  We also say that $Phi$ is a *strict monomorphism* (resp. *strict epimorphism*) if $Phi$ is a monomorphism (resp. epimorphism) but is not an isomorphism.
]
<def-mono>
#proposition[
If $Phi: cC -> cC'$ is an isomorphism, its inverse $Phi^(-1) : cC' -> cC$ consists of $(Phi_tau)^(-1) : cC'(tau) -> cC(tau)$ for each simplex $tau$ in $K$. 
]
<iso-inverse>
#proof[
  We need to check that $Phi^(-1)$ is indeed a natural transformation. For each pair $tau >= sigma$, the naturality of $Phi$ says that 
  $cC' (tau >= sigma) oo Phi_tau = Phi_sigma oo cC (tau >= sigma).
  $
  Hence 
  $(Phi_sigma)^(-1) oo cC' (tau >= sigma)  =   cC (tau >= sigma) oo (Phi_tau)^(-1),
  $
  which shows the naturality of $Phi^(-1)$. 
]

= Examples of Cosheaves

#lemma[
  The constant cosheaf $underline(FF)_K$ gives the same homology groups as the standard homology.
]
#proof[
  In this case, 
  $bC_k (K; FK) = product_(dim tau = k) FF.
  $
  This agrees with @notes[Definition 3.6]. It is also easy to see the boundary maps agree with @notes[Definition 3.7]. 
  // #TODO[show?]
]

#example[
  Let $V = {v}$ and 
  let $K$ be the simplicial complex ${tau}$, where $tau = {v}$. Let $cC : (K, >=) -> VF$ be the cosheaf which assigns the zero vector space to the only simplex $tau = {v}$ in $K$. Then $K$ has standard homology of a single point, which agrees with the homology induced by $FK$. On the other hand,  the chain complex induced by $cC$ has $bC_k (K; cC) = 0$ for all $k >= 0$, so $bH_k (K ; cC) = 0$ for all $k >= 0$. Thus $FK$ has the homology of a single point, but $cC$ does not.
]
<task-3-1>
#example[
  Let $V = {v_1, v_2}$ and let $K = {tau_1, tau_2}$, where $tau_1 = {v_1}$ and $tau_2 = {v_2}$. Let $cC$ be the cosheaf such that $cC(tau_1) = FF$ and $cC(tau_2) = 0$. (There is no non-trivial coface relation in $K$.) Then  with $FK$-coefficients, $K$ has chain complex $ bC_k (K ; FK) = cases(FF^2 quad &"if" k = 0 comma, 0 quad &"otherwise,") $ with all the boundary maps necessarily zero, which gives 
  $
    bH_k (K ; FK) = cases(FF^2 quad &"if" k = 0 comma, 0 quad &"otherwise.")
  $
  On the other hand, with $cC$-coefficients, we similarly see that 
  $ bH_k (K ; cC) = bC_k (K ; cC) = cases(FF quad &"if" k = 0 comma, 0 quad &"otherwise.") $
  Thus $FK$ does not have the homology of a single point, but $cC$ does. 
]
<task-3-2>
// #TODO[what is strict monomorphism? each component is injective or some component is injective?]

#example[
  Let $V = {v_1, v_2}$ and $K = {tau_1, tau_2, tau_3}$, where $tau_1 = {v_1}$, $tau_2 = {v_2}$ and $tau_3 = {v_1, v_2}$. (In other words, $K = Delta(1)$.) Define cosheaf $cC$  as follows: 
  $
    tau_1 &mapsto FF, 
    tau_2 &mapsto FF^2, 
    tau_3 &mapsto FF^2, 
    (tau_3 >= tau_1) &mapsto ((a, b) |-> a), 
    (tau_3 >= tau_2) &mapsto id_(FF^2). 
  $
  There is no non-trivial coface relation composition in $K$, so $cC$ is easily seen to be a cosheaf.

  We then define morphism $Phi : FK -> cC$ as follows: $Phi_(tau_1) = id_FF$, $Phi_(tau_2) (a) = (a, 0)$ and $Phi_(tau_3) (a) = (a, 0)$. 
  Since the following diagram commutes 
// https://t.yw.je/#N4Igdg9gJgpgziAXAbVABwnAlgFyxMJZABgBoBGAXVJADcBDAGwFcYkQAxDkAX1PUy58hFOQrU6TVuy4A9AEy9+IDNjwEi88TQYs2iThwVKBa4UTLEJu6Qa4mVg9SORirOqfsMPVQjSi13ST0Zbh4JGCgAc3giUAAzACcIAFskABYaHAgkAGYPEIMsKAB9ez4E5LTETJBspABWAtsQYrKw5STUpDE6nMQyYJaACnpSACMASgAfAFoAPnoHLure+sQtIa9RiZmFnanlqsas-s2bL3oAAjn5q53iSaPuxHy+pEGL9jbyzuOa049ZqXG4Le5jR68Sg8IA
#align(center, commutative-diagram(
  node-padding: (90pt, 50pt),
  node((1, 0), [$FF$]),
  node((1, 1), [$FF^2$]),
  node((1, 2), [$FF^2,$]),
  node((0, 0), [$FF$]),
  node((0, 1), [$FF$]),
  node((0, 2), [$FF$]),
  arr((0, 1), (0, 0), [$id_FF$]),
  arr((0, 1), (0, 2), [$id_FF$]),
  arr((1, 1), (1, 0), [$(a,b)|->a$]),
  arr((1, 1), (1, 2), [$id_(FF^2)$]),
  arr((0, 2), (1, 2), [$a |-> (a,0)$]),
  arr((0, 0), (1, 0), [$id_FF$]),
  arr((0, 1), (1, 1), [$a |-> (a,0)$]),
))
  we see that $Phi$ is indeed a natural transformation. Further, each component of $Phi$ is injective but $Phi$ is not an isomorphism, so $Phi$ is a strict monomorphism.
  
  $K = Delta(1)$, so by @notes[Proposition 2.6], $K$ has the same homology groups with $FK$-coefficients as a single point. We then compute the chain complex of $K$ with $cC$-coefficients: $ bC_0 (K ; cC) = cC(tau_1) plus.circle cC(tau_2) = FF^3, $ $ bC_1 (K ; cC) = cC(tau_3) = FF^2, $ and the only non-trivial boundary map $diff_1^cC$ sends $(a, b)$ to $(a, -a, -b)$. Thus $Ker diff_1^cC = 0$ and $Im diff_1^cC = FF^2$, and thus $bH_0 (K; cC) = FF^3 over FF^2 = FF$ and $bH_1 (K ; cC) = 0$. Finally, since $Phi_0 : bC_0 (K; FK) ->  bC_0 (K; cC)$ is injective, which in particular does not send any generator of $bH_0 (K; FK)$ to zero, the induced map $bH_0 (K; FK) -> bH_0 (K; cC)$ is then necessarily an isomorphism $FF -> FF$. This is the only non-trivial map in $bH_cx (K; FK) -> bH_cx (K; cC)$, which is thus an isomorphism.
]
<task-3-3>

#proposition[
  For any simplicial complex $K$ and any cosheaf $cC$ over $K$,
  there does not exist a strict epimorphism $Phi : FK -> cC$ which induces an isomorphism on homology.
]
<task-3-4>

#proof[
  Suppose such $Phi$ exists, then there exists a simplex $tau$ in $K$ such that $Phi_tau : FF -> cC(tau)$ is surjective but is not an isomorphism. Then $Phi_tau$ is necessarily the zero map $FF -> cC(tau) = 0$. 

  We then claim that for any simplex $sigma$ in $K$ such that $tau >= sigma$, $Phi_sigma = 0$ and $cC(sigma) = 0$. By the naturality of $Phi$, the following commutes:

  #align(center, commutative-diagram(
  node-padding: (70pt, 50pt),
  node((0, 0), [$FF$]),
  node((1, 0), [$FF$]),
  node((0, 1), [$cC(tau)$]),
  node((1, 1), [$cC(sigma),$]),
  arr((0, 0), (1, 0), [$id_FF$]),
  arr((0, 1), (1, 1), [$cC(tau >= sigma)$]),
  arr((0, 0), (0, 1), [$Phi_tau = 0$]),
  arr((1, 0), (1, 1), [$Phi_sigma$]),
))
  which forces the surjective $Phi_sigma : FF -> cC(sigma)$ to also be the zero map, and thus $cC(sigma) = 0$. 
  
  This in particular shows that there must be some vertex $rho = {v}$ such that $Phi_rho = 0$ and $cC(rho) = 0$. Then in the chain map, $Phi_0 : bC_0 (K ; FK) -> bC_0 (K; cC)$ sends $rho$ to $0$. However, $rho$ can be seen as a generator of $bH_0 (K; FK)$, representing the connected component to which $rho$ belongs. Then the induced map $bH_0 (K; FK) -> bH_0 (K; cC)$ on homology would also send the class of $rho$ to $0$ and thus cannot be an isomorphism. We have therefore reached a contradiction.
]

= Filtration and Persistence Homology

#definition[
  Let $cC$ be a cosheaf over a simplicial complex $K$. Then a *filtration* ${cC^i}$ of $cC$ over $K$ of length $l >= 1$ is a collection of cosheaves ${cC^1, cC^2, ..., cC^l = cC} $ over $K$ together with strict monomorphisms $Psi^i : cC^i -> cC^(i+1)$ for each $i = 1, 2, ..., l-1$. 
  // We denote such a filtration as 
  // $
  //   cC^1 subset cC^2 subset ... subset cC^l = cC.
  // $
Then for each dimension $k >= 0$, there are induced maps on homology 
$
  bH_k (K ; cC^1) ->^(bH_k Psi^1) bH_k (K ; cC^2) ->^(bH_k Psi^2)  ... ->^(bH_k Psi^(l-1)) bH_k (K ; cC^l)
$
For any $1 <= i <= j <= l$, we denote $Psi^(i->j) = Psi^(j-1) oo ... oo Psi^i$ (when $i = j$, $Psi^(i -> i) = id_(cC^i)$) and by the functoriality of homology,
$bH_k Psi^(i->j) = bH_k Psi^(j-1) oo ... oo bH_k Psi^i.
$
Then the associated *persistent homology* of $K$ with coefficients in ${cC^i}$ is defined by 
$
  PH_(k) Psi^(i->j) = Im(bH_k Psi^(i->j)),
$
which is a subspace of $bH_k (K; cC^j)$. 
]
<def-filtration>

#lemma[
If $cC = FK$, a filtration ${cC^i}$ of $K$ defined as above is the same as a filtration defined as in @notes[Definition 1.6].
]

#proof[
  Since all $Phi_i$'s are strict monomorphisms, each $cC^i$ would only assign either $FF$ or $0$ to each simplex in $K$. Also, for any $i$ and any pair $tau >= sigma$, if $cC^i (tau) = FF$, then $Psi^(i->l)_(tau) = id_FF$ by injectivity, and the naturality of $Psi^(i -> l)$ would ensure that $cC^i (sigma) = FF$ as well. This indicates that for each $i$, the simplices in $K$ to which $cC^i$ assigns $FF$ form a subcomplex of $K$, which can be viewed as $bF_i K$ as in @notes[Definition 1.6]. 
]
= Partial Matchings
The following is based on @notes[Section 8.1].

#definition[
  A *partial matching* on $K$ is a collection $Sigma$ of simplex-pairs $sigma lt.tri tau$ of $K$ such that each simplex in $K$ only occurs in any of the pairs at most once. A simplex in $K$ is said to be a *critical simplex* if it does not occur in any of the pairs in $Sigma$.
]
#definition[
  A *$Sigma$-path* is a zigzag sequence of distinct simplices in $K$ of the form 
  $
    rho = (sigma_1 lt.tri tau_1 gt.tri sigma_2 lt.tri tau_2 gt.tri ... gt.tri sigma_m lt.tri tau_m ),
  $
  where $(sigma_j lt.tri tau_j)$ lies in $Sigma$ for each $j = 1, 2, ..., m$.  Such a $Sigma$-path $rho$ is a *$Sigma$-cycle* if $m > 1$ and $tau_m lt.tri sigma_1$. Any $Sigma$-path which is not a $Sigma$-cycle is a *gradient path*. 
]

#definition[
  A partial matching $Sigma$ on $K$ is said to be *acyclic* if there does not exist any $Sigma$-cycle.
]


#definition[
  Let ${cC^i}$ be a filtration of $cC$ over $K$ of length $l >= 1$. An acyclic partial matching $Sigma$ on $K$ is *compatible* with ${cC^i}$ if for any $1<= i <= l$ and any pair $sigma lt.tri tau$ in $Sigma$, the map $cC^i  (tau >= sigma)$ is an isomorphism.
]
<def-compatible>
// #definition[
//   Given an acyclic partial matching $Sigma$ on $K$ which is compatible with ${cC^i}$,  for each $1 <= i <= l$, a simplex $tau$ in $K$ is said to be a *critical simplex* if $tau$ does not occur in any of the pairs in $Sigma$.
//   // + $cC^i (tau) != 0$.
// ]
// #TODO[is this a helpful definition ? do we want to omit definition (2)?]

  #figure(placement: auto, caption: [A filtration ${cC^i}$ of length $3$ over $Delta(1)$.],
    table(
    columns: (auto, auto, auto, auto, auto, auto),
    inset: 10pt,
    align: horizon,
    [], $cC^1$, $Psi^1$, $cC^2$, $Psi^2$, $cC^3$,
    $tau_1$, $0$, $0$, $FF$, $mat(1; 0 ; 0)$, $FF^3$,
    $tau_3 >= tau_1$, $0$, [], $id_FF$, [], $mat(1, 2; 0, 4; 0, 3)$,
    $tau_3$, $FF$, $id_FF$, $FF$, $mat(1; 0)$, $FF^2$,
    $tau_3 >= tau_2$, $id_FF$, [], $id_FF$, [], $id_(FF^2)$,
    $tau_2$, $FF$, $id_FF$, $FF$, $mat(1; 0)$, $FF^2$,
    )
  )
  <fit-example>
#example[
  Take $K = Delta(1)$ with $tau_1, tau_2, tau_3$ defined as in @task-3-3. We define the cosheaves $cC^1, cC^2, cC^3$ on $K$ together with morphisms $Psi^1 : cC^1 -> cC^2$ and $Psi^2: cC^2 -> cC^3$, shown in @fit-example. Note that each $cC^i$ assigns a vector space to each $tau_j$ and a linear map to each of the coface relations $tau_3 >= tau_1$ and $tau_3 >= tau_2$. Each $Psi^i$ then assigns a linear map $cC^i (tau_j) -> cC^(i+1) (tau_j)$ to each $tau_j$. To verify the naturality of each $Psi^i$, note that the only non-trivial relation here is $  cC^3 (tau_3 >= tau_1) oo Psi^2 _(tau_3) = Psi^2 _(tau_1) oo cC^2 (tau_3 >= tau_1)$, i.e., 
  $
    mat(1, 2; 0, 4; 0, 3) mat(1; 0) = mat(1; 0; 0).
  $
  
  Since each $Psi^i$ is a strict monomorphism, we have a filtration ${C^i}$ of length $3$ over $K$. 

  We then construct a partial matching $Sigma$ on $K$, which only consists of the pair $(tau_2 lt.tri tau_3)$. Then the only critical simplex of $Sigma$ is $tau_1$. Since the only possible $Sigma$-path is $(tau_2 lt.tri tau_3)$, which is not a $Sigma$-cycle (and hence is a gradient path), we see that $Sigma$ is acyclic. Further, $Sigma$ is compatible with ${cC^i}$ defined in @fit-example, as for all $cC^i$, the linear map $cC^i (tau_3 >= tau_2)$ is the identity and thus an isomorphism.

  // To construct some numerical examples, we further assume that any cosheaf is a functor $cC : (K , >=) -> FVR$ and for each vector space the standard basis is chosen. Then to define a cosheaf, we only need the following data:
  // + A natural number $n_tau$ for each simplex $tau$ in $K$, representing the dimension of the $RR$-vector space $cC(tau)$, and
  // + An $(n_(sigma) times n_tau)$-matrix over $RR$ for each pair $tau gt.tri sigma$, representing the linear map $cC(tau >= sigma)$.
  // All other linear maps $cC(tau >= sigma)$, where $sigma$ has codimension greater than $1$ as a face of $tau$, can then be written as a composition $cC(tau'' gt.tri sigma) oo ... oo cC(tau gt.tri tau')$, where $tau gt.tri tau' gt.tri ... gt.tri tau'' gt.tri sigma$.

  // We then assume for a filtration ${cC^i}$ of $cC$, each $Psi^i_tau : cC^i (tau) -> cC^(i+1) (tau)$ is represented by a matrix 
]
<fit-example-1>

= The Morse Chain Complex

Fix a filtration ${cC^i}$ of $cC$ over $K$ of length $l >= 1$ and  an acyclic matching $Sigma$ on $K$ compatible with ${cC^i}$. 
Until further notice, also fix $i$ such that $1<= i<= l$.

== Chain Construction 
Now it is helpful to recall @sign-adjustment.

  #definition[
  For a $Sigma$-path
     $rho = (sigma_1 lt.tri tau_1 gt.tri sigma_2 lt.tri tau_2 gt.tri ... gt.tri sigma_m lt.tri tau_m ),
  $
  define its *$cC^i$-weight* $w_(i)(rho)$ as the linear map $cC^i (sigma_1) -> cC^i (tau_m)$ given by 
  $
    w_(i)(rho) := (-1)^m dot (cC_(tau_m, sigma_m)^i)^(-1) oo ... oo (cC_(tau_2, sigma_2)^i)^(-1) oo cC_(tau_1, sigma_2)^i oo (cC_(tau_1, sigma_1)^i)^(-1).
  $
]
#remark[
  Since $cC^i_(tau_j, sigma_j) = plus.minus cC^i (tau_j >= sigma_j)$ for each $1 <= i <= l$ and $1 <=  j <= m$ is by definition an isomorphism, taking its inverse is justified.
]
#let cw = [$cal(w)_i$]

#notation[
  Let $alpha, beta$ be simplices in $K$ such that $dim alpha = dim beta + 1$ and let $rho = (sigma lt.tri ... lt.tri tau)$ be a $Sigma$-path. Denote $cw(alpha gt.tri rho gt.tri beta) := cC^i_(tau, beta) oo w_(i) (rho) oo cC^i_(alpha, sigma)$. Note that $cw(alpha gt.tri rho gt.tri beta) != 0$ if and only if $alpha gt.tri sigma$ and $tau gt.tri beta$. In particular, if we also allow $rho$ to be the empty path $emptyset$, then in this case $cw(alpha gt.tri emptyset gt.tri beta) := cC^(i)_(alpha, beta)$.
]
<new-path-notation>

// #definition[
//   Let $L$ be a subset (but not necessarily a subcomplex) of $K$  and let $(bD_cx, diff^bD_cx)$ be a sequence (but not necessarily a chain complex), where each $bD_k = product_(dim alpha = k,  alpha in L) cC^i (alpha) $. Let $(sigma lt.tri tau)$ be a pair of simplices in $K$ but not in $L$. Define the *elimination operation* of $(sigma lt.tri tau)$ on $(bD_cx, diff^bD_cx)$ as follows: for any $alpha, beta$ such that $k = dim alpha = dim tau = dim beta + 1 = dim sigma + 1$, this operation changes $diff_k^bD |_(alpha, beta)$ to 
//   $
//     diff_k^bD |_(alpha, beta)- diff_k^bD |_(tau, beta) oo (cC^i_(tau, sigma))^(-1) oo diff_k^bD |_(alpha, sigma),
//   $
//   and leaves all $diff_i^bD$ for $i != k$ unchanged.
// ]
// #TODO[formalise this idea]
// #lemma[
//   The elimination operation leaves other pairs of an acyclic partial matching unchanged.
// ]
// #lemma[
//   We have the Morse complex (constructed by induction) with the following boundary operation...
// ]
#definition[
  The *Morse complex* of $Sigma$ with coefficients in $cC^i$ is a sequence 
  $(bC_cx^Sigma (K; cC^i), d_cx ^(cC^i, Sigma) ),
  $
  where for each dimension $k >= 0$,
  $
    bC_k^Sigma (K; cC^i) = product_(dim alpha = k comma \ alpha "critical ") cC^i (alpha),
  $
  and for critical simplices $alpha, beta$ in $K$ with $dim alpha = k$ and $dim beta = k-1$, 
  $d_k ^(cC^i, Sigma) : bC_k^Sigma (K; cC^i) -> bC_(k-1)^Sigma (K; cC^i)$  has the following $cC^i (alpha) -> cC^i (beta)$ component:
  $
    d_k ^(cC^i, Sigma)|_(alpha, beta) = cC^i_(alpha, beta) + sum_(Sigma"-path" rho = (sigma lt.tri ... lt.tri tau)) cC^i_(tau, beta) oo w_(cC^i)(rho) oo cC^i_(alpha, sigma).
  $
  Alternatively, if we denote the set of all $Sigma$-path (including the empty path $emptyset$) as $Gamma_Sigma$, we could write $ d_k ^(cC^i, Sigma)|_(alpha, beta) = sum_(rho in Gamma_Sigma) cw(alpha gt.tri rho gt.tri beta)$ using @new-path-notation. 
]
<def-morse>

To simplify later proofs, we first need an 'induction principle' for the Morse complex. This lemma is the only place where we vary $Sigma$ in this section.
#lemma[
  Let $P$ be a proposition on the Morse complex $(bC_cx^Sigma (K; cC^i), d_cx^(cC^i, Sigma))$. Then to prove $P$ for any acyclic partial matching $Sigma$ compatible with ${cC^i}$, it suffices to consider the case $Sigma_0 = {(sigma lt.tri tau)}$.
]
<induction-principle>
#proof[
  We suppress the explicit appearance of $K$ and $cC^i$ in the notations as they are fixed in this proof.
  First, we notice that if $Sigma_0 = {(sigma lt.tri tau)}$ with $dim sigma + 1 = dim tau = k$, then the only $Sigma_0$-path is $(sigma lt.tri tau)$, and the construction of the Morse complex $(bC_cx^(Sigma_0) , d_cx ^(Sigma_0) )$ based on the _sequence_ $(bC_cx , d_cx  )$ (we may forget that $(bC_cx , d_cx  )$ is a chain complex for now) is equivalent to applying the following algorithm $(star)$ with $(sigma lt.tri tau)$ to $(C_cx, d_cx)$:
  + For each $k$-simplex $alpha$ and $(k-1)$-simplex $beta$, change the block $d_k |_(alpha, beta)$ to $ d_k |_(alpha, beta) - d_k |_(tau, beta) oo (d_k|_(tau, sigma))^(-1) oo d_k |_(alpha, sigma); $ 
  + Remove $cC^i (tau)$ from the product of $bC_k$ and remove $cC^i (sigma)$ from the product of $bC_(k-1)$, and remove all corresponding blocks from $d_(k+1)$, $d_k$ and $d_(k-1)$.
  // + $diff_k^bD |_(alpha, beta)- diff_k^bD |_(tau, beta) oo (cC^i_(tau, sigma))^(-1) oo diff_k^bD |_(alpha, sigma),$
  For an arbitrary $Sigma$, we claim that applying algorithm $(star)$ recursively with each pair in $Sigma$ produces the same Morse complex $(bC_cx^(Sigma) , d_cx ^(Sigma) )$ as in @def-morse. Take any $(sigma lt.tri tau)$ in $Sigma$ and let $Sigma' = Sigma - {(sigma lt.tri tau)}$. Then by induction, suppose we have the Morse complex $(bC_cx^(Sigma') , d_cx ^(Sigma') )$ specified as in @def-morse. Then we note that for any $rho in Gamma_Sigma'$, $cw (tau gt.tri rho gt.tri sigma) != 0$ only if $rho  = emptyset$, for otherwise we can form a $Sigma$-cycle $(sigma lt.tri tau  lt.tri rho)$, which contradicts the acyclicity of $Sigma$. Thus, 
  $d_k^(Sigma')|_(tau, sigma) = sum_(rho in Gamma_(Sigma')) cw (tau gt.tri rho gt.tri sigma) = cC^i_(tau, sigma)$. 
  
  Therefore, step (1) of algorithm $(star)$ changes the block $d_k^(Sigma')|_(alpha, beta)$ to 
  $
    & d_k ^(Sigma') |_(alpha, beta) - d_k ^(Sigma') |_(tau, beta) oo (cC^i_(tau, sigma))^(-1) oo d_k ^(Sigma') |_(alpha, sigma) \
    
     = &sum_(rho_1 in Gamma_Sigma') cw(alpha gt.tri rho_1 gt.tri beta) - (sum_(rho_2 in Gamma_Sigma') cw(tau gt.tri rho_2 gt.tri beta)) oo (cC^i_(tau, sigma))^(-1) oo (sum_(rho_3 in Gamma_Sigma') cw(alpha gt.tri rho_3 gt.tri sigma)) \

    = &sum_(rho_1 in Gamma_Sigma') cw(alpha gt.tri rho_1 gt.tri beta) - (sum_(rho_2 in Gamma_Sigma') sum_(rho_3 in Gamma_Sigma') cw(tau gt.tri rho_2 gt.tri beta) oo (cC^i_(tau, sigma))^(-1) oo  cw(alpha gt.tri rho_3 gt.tri sigma)) \
    = &  sum_(rho in Gamma_Sigma) cw (alpha gt.tri rho gt.tri beta) = d_k^Sigma|_(alpha,beta).
  $
  The last but one equality is because any $rho in Gamma_Sigma$ 
  - either does not consist of $(sigma lt.tri tau)$, in which case $rho = rho_1 in Gamma_Sigma'$, 
  - or passes $(sigma lt.tri tau)$ exactly once, in which case $rho$ can be written as $(rho_3 gt.tri sigma lt.tri tau gt.tri rho_2)$ for $rho_2, rho_3 in Gamma_Sigma'$ and then $cw (alpha gt.tri rho gt.tri beta)$ can be decomposed as in the summand.

  Step (2) of algorithm $(star)$ simply updates the critical simplices by removing $sigma$ and $tau$. Thus, we see that applying algorithm $(star)$ with $(sigma lt.tri tau)$ to $(bC_cx^(Sigma') , d_cx ^(Sigma') )$ produces the same $(bC_cx^(Sigma) , d_cx ^(Sigma) )$ as in @def-morse. In other words, we could have equivalently defined the Morse complex as the sequence produced by recursively applying algorithm $(star)$ with each pair of $Sigma$ (in an arbitrary order) to $(bC_cx, d_cx)$. This constructive definition indicates our 'induction principle'.
]

// #TODO[change all $cC^i$ to $cC$ since they are fixed...]

#notation[
 With $K$, ${cC^i}$ and $Sigma$ fixed as above, for each $1 <= i <= l$ and each dimension $k >=0$, 
  denote $bC_k^i := bC_k (K ; cC^i) comma  diff_k^i := diff_k^(cC^i) comma   
  bM_k^i  := bC_k^Sigma (K; cC^i),   d_k^i := d_k^(cC^i, Sigma) . $ 
  // We also denote $w_i (rho) := w_(cC^i) (rho)$ for any $Sigma$-path $rho$.
]

#proposition[
  For each $i$, the Morse complex $(bM_cx^i, d^i_cx)$ is a chain complex.
]
<morse-is-chain>
#let ci(s, t) = [$cC^i_(#s, #t)$] 
#proof[
  // #TODO[why induction works here?]
  This is analogous to @notes[Proposition 8.8]. To elaborate, by @induction-principle, it suffices to consider when $Sigma = {(sigma lt.tri tau)}$, the set of critical simplices $C_Sigma = K - {sigma, tau}$, and the only $Sigma$-path $rho = (sigma lt.tri tau)$. Then we need to show that for each $k >= 2$, for any $alpha, omega in C_Sigma$ such that $dim alpha = dim omega + 2 = k$, we have $ B := sum_(dim xi = k - 1 comma \ xi in C_Sigma) d^i_(k-1) |_( xi, omega) oo  d^i_k |_(alpha , xi) = 0. $
  For each $xi$ in the sum, denote $B_xi := d^i_(k-1) |_( xi, omega) oo  d^i_k |_(alpha , xi)$, which by definition expands to 
  $
    B_xi = 
    underbrace( ci(xi, omega) oo ci(alpha, xi), B_(xi, 1))
    underbrace(- ci(tau, omega) oo (ci(tau, sigma))^(-1) oo ci(xi, sigma) oo ci(alpha, xi) , B_(xi, 2))
    underbrace(
    -ci(xi, omega) oo ci(tau, xi) oo (ci(tau, sigma))^(-1) oo ci(alpha, sigma), 
    B_(xi, 3)) \ + ci(tau, omega) oo (ci(tau, sigma))^(-1) oo ci(xi, sigma) oo ci(tau, xi) oo (ci(tau, sigma))^(-1) oo ci(alpha, sigma),
  $
  where the fourth term is always zero, since $ci(alpha, sigma) != 0$ only if $dim sigma = k-1$, but $ci(xi, sigma) != 0$ only if $dim sigma = k-2$. Now denote the first three terms of $B_xi$ as $B_(xi, j)$ for $j = 1, 2, 3$ respectively, so $B_xi = sum_(j=1)^3 B_(xi, j)$. Since $diff^i_cx$ is a boundary operator, we have $ sum_xi B_(xi, 1) = - ci(tau, omega) oo ci(alpha, tau) -  ci(sigma, omega) oo ci(alpha, sigma). $
  We then see that $sum_xi B_(xi, j) = 0$ for any $j = 1, 2, 3$ if $dim sigma != k - 2$ and $dim sigma != k-1$. Then there remain two cases:
  - If $dim sigma = k-2$ and so $dim tau = k -1$, then $B_(xi, 3) = 0$ for any $xi$ in the sum, and $sum_xi B_(xi, 2) =  ci(tau, omega) oo (ci(tau, sigma))^(-1) oo ci(tau, sigma) oo ci(alpha, tau) =  ci(tau, omega) oo ci(alpha, tau), $
    which would cancel with $sum_xi B_(xi, 1)$;
  - If $dim sigma = k -1$, the situation is similar as above, with $B_(xi, 2) = 0$ for any $xi$ and also $sum_xi B_(xi, 3) $ cancelling with $sum_xi B_(xi, 1) $.
  Therefore, we conclude that $B = sum_xi B_xi = 0$ as desired.
]
== Chain Homotopy Equivalence
#proposition[
  For each $i$, the Morse complex $(bM_cx^i, d^i_cx)$ is chain homotopy equivalent to the chain complex $(bC_cx^i, diff^i_cx)$.  In particular, there exists a chain map $phi^i_cx : bM_cx^i -> bC_cx^i$ which induces an isomorphism   $bH_k (bM^i_cx) -> bH_k (bC^i_cx)$ for each dimension $k>=0$.
]
<morse-equivalent>
#proof[
  This is analogous to @notes[Proposition 8.10] and @notes[Lemma 8.11]. Again, it suffices to assume $Sigma = {(sigma lt.tri tau)}$. For each $k >= 0$ and for each pair of $k$-simplices $(alpha, omega) in K times C_Sigma$, define the $cC^i  (alpha) -> cC^i (omega)$ component of the linear map $psi^i_k : bC_k^i -> bM_k ^i$  by 
  $
    psi^i_k |_(alpha, omega) = cases(
      id_(cC^i (alpha)) quad & alpha = omega != tau comma, 
      - ci(tau, omega) oo (ci(tau, sigma))^(-1) quad & alpha = sigma comma , 
      0 & "otherwise".
    ) 
  $
  Conversely, define the $cC^i (omega) -> cC^i (alpha)$ component of the linear map $phi^i _k : bM_k ^i -> bC_k ^i$ by 
  #math.equation(block: true, numbering: "(1)", supplement: "Equation",
  $
    phi^i_k |_(omega, alpha) = cases(
      id_(cC^i (omega)) quad & omega =  alpha != sigma comma, 
      -  (ci(tau, sigma))^(-1) oo ci(omega, sigma)   quad & alpha= tau comma , 
      0 & "otherwise".
    )
  $) <def-phi>
  
  One can verify that $psi^i_cx$ and $phi^i_cx$ are two chain maps.
  //  #TODO[...] 
  We then note that $psi^i_k oo phi^i_k$ is the identity map on $bM^i_k$. Indeed, for each $omega, omega' in bM_k^i$, 
  $(psi^i_k oo phi^i_k)|_(omega, omega') = sum_(alpha in bC_k^i) psi^i_k |_(alpha, omega') oo phi^i_k |_(omega, alpha).
  $
  If $alpha = sigma$, then $phi^i_k |_(omega, alpha) = 0$. If $alpha = tau$, then $psi^i_k |_(alpha, omega') = 0$. Thus we only need to consider the case when $alpha in.not {tau, sigma}$. Then we see that if $omega != omega'$, one of $psi^i_k |_(alpha, omega')$ and $ phi^i_k |_(omega, alpha)$ must be $0$; if $omega = omega'$, we have $psi^i_k |_(alpha, omega') oo phi^i_k |_(omega, alpha) = id_(cC^i (omega))$ only if $alpha = omega = omega'$. 

  Similarly, we can find that for each $alpha, alpha' in bC_k^i$, 
  $
    (phi^i_k oo psi^i_k)|_(alpha, alpha') = cases(
      - ci(tau, alpha') oo (ci(tau, sigma))^(-1) quad & alpha = tau != alpha' comma, 
      - (ci(tau, sigma))^(-1) oo ci(alpha, sigma) quad & alpha != sigma = alpha' comma,
      id_(cC^i (alpha)) quad & alpha = alpha' comma , 
      0 quad & "otherwise".  
    )
  $
  Then the linear maps $theta_k : bC_k^i -> bC_(k+1)^i$, whose $cC(alpha) -> cC(beta)$ component for $k$-simplex $alpha$ and $(k+1)$-simplex $beta$ is defined as 
  $
    theta_k |_(alpha, beta) = cases(
      (ci(tau, sigma))^(-1) quad & alpha = sigma "and" beta = tau comma, 
      0 quad & "otherwise" comma
    )
  $
  gives a chain homotopy between $phi^i_k oo psi^i_k$ and the identity chain map on $bC_k^i$.
  // Then to move on to general cases of $Sigma$, the discussion at the end of @notes[Section 8.3] also applies with slight modification. In particular, by removing a single pair $(sigma lt.tri tau) in Sigma$ from $K$, we change any $ci(alpha, omega)$ to $ci(alpha, omega) - ci(tau, omega) oo (ci(tau, sigma))^(-1) oo ci(alpha, sigma)$. Now suppose for another pair $(sigma' lt.tri tau') in Sigma$, we have $ci(tau, sigma') oo (ci(tau, sigma))^(-1) oo ci(tau', sigma) != 0$. This indicates that $tau' gt.tri sigma lt.tri tau gt.tri sigma'$, but since $sigma' lt.tri tau'$, we have constructed a $Sigma$-cycle, which contradicts the acyclicity of $Sigma$.
  // #TODO[do we want to write more?]
]
// By induction on $Sigma$, 
// A by-product of the proof above is the following:
// #corollary[

// ]
// <iso-homo>

== The Commutative Cube

To show that the Morse complex $bM_cx^i$ induces the same persistent homology as $bC_cx^i$, we first introduce a useful (and beautiful) diagram, shown in @cube.
#figure(caption: "The commutative cube.", 
placement: auto
)[
// https://t.yw.je/#N4Igdg9gJg<KEY>
#align(center, commutative-diagram(
  node-padding: (50pt, 40pt),
  node((0, 0), [$bC_(k-1)^i$]),
  node((1, 0), [$bC_(k)^i$]),
  node((0, 2), [$bC_(k-1)^(i+1)$]),
  node((1, 2), [$bC_(k)^(i+1)$]),
  node((2, 1), [$bM_(k-1)^(i)$]),
  node((2, 3), [$bM_(k-1)^(i+1)$]),
  node((3, 1), [$bM_(k)^(i)$]),
  node((3, 3), [$bM_(k)^(i+1)$]),
  arr((1, 0), (0, 0), [$diff_(k)^i$]),
  arr((0, 0), (0, 2), [$Psi_(k-1)^i$]),
  arr((1, 0), (1, 2), [$Psi_(k)^i$]),
  arr((1, 2), (0, 2), [$diff_(k)^(i+1)$]),
  arr((2, 1), (2, 3), [$tilde(Psi)_(k-1)^i$]),
  arr((3, 1), (3, 3), [$tilde(Psi)_(k)^i$]),
  arr((3, 1), (2, 1), [$d_(k)^i$], label-pos: right),
  arr((3, 3), (2, 3), [$d_(k)^(i+1)$], label-pos: right),
  arr((2, 1), (0, 0), [$phi_(k-1)^i$], label-pos: left, ),
  arr((3, 1), (1, 0), [$phi_(k)^i$], ),
  arr((2, 3), (0, 2), [$phi_(k-1)^(i+1)$], label-pos: right),
  arr((3, 3), (1, 2), [$phi_(k)^(i+1)$]),
))
]
<cube>
In @cube, each vertical line is a chain complex. We have shown that the back face commutes, since each $Psi^i_cx$ is a chain map; the left face (as well as the right face) commutes, since each $phi_cx^i$ is a chain map; and furthermore, each slant arrow $phi^i_k$ induces an isomorphism on homology.
To show the commutativity of the remaining faces,
now we consider what happens when we vary $i$, the stage of the filtration. 

#proposition[
  Each $Psi^i : cC^i -> cC^(i+1)$ induces a chain map $tilde(Psi)^i_cx : bM_cx^i -> bM_cx^(i+1). $ In other words,  the front face of @cube commutes.
]
<front-commute>
#proof[
  For each dimension $k >= 0$,
  for an arbitrary pair of critical $k$-simplices $alpha, alpha'$, define the $cC^i  (alpha) -> cC^(i+1) (alpha')$ component of the linear map $tilde(Psi)^i_k : bM_k^i -> bM_k^(i+1)$ as $Psi^i_alpha$ if $alpha = alpha'$ and $0$ otherwise.
  // $
  //   cases(
  //     Psi^i_alpha quad & alpha = alpha' comma , 
  //     0 quad & "otherwise".
  //   )
  // $
  Then it suffices to show for any critical $k$-simplex $alpha$ and critical $(k-1)$-simplex $beta$, 
  $d_k^(i+1) |_(alpha, beta) oo Psi_alpha^i = Psi_beta^i oo d_k^(i) |_(alpha, beta),
  $
  which by definition expands  to 
  #math.equation(block: true, numbering: "(1)", supplement: "Equation",
  $
         (cC^(i+1)_(alpha, beta) + sum_(Sigma"-path" rho = (sigma lt.tri ... lt.tri tau)) cC^(i+1)_(tau, beta) oo w_(i+1)(rho) oo cC^(i+1)_(alpha, sigma)) oo 
Psi_alpha^i = \ Psi_beta^i oo
(        cC^i_(alpha, beta) + sum_(Sigma"-path" rho = (sigma lt.tri ... lt.tri tau)) cC^i_(tau, beta) oo w_(i)(rho) oo cC^i_(alpha, sigma)).
  $) <eq1>
  
  

   Notice that for any simplices $delta >= gamma$ in $K$, by the naturality of $Psi^i$, we have 
   $cC^(i+1) (delta >= gamma) oo Psi^i_(delta) = Psi^i_(gamma) oo cC^i (delta >= gamma)$. Hence, for an arbitrary pair of simplices $ delta, gamma$ in $K$,
   #math.equation(block: true, numbering: "(1)", supplement: "Equation",
   $ cC^(i+1) _(delta, gamma) oo Psi^i_(delta) = Psi^i_(gamma) oo cC^i_ (delta , gamma). $ ) <eq2>

   In particular, if $(gamma lt.tri delta) in Sigma$, then by compatibility, both $cC^(i+1) _(delta, gamma)$ and $cC^i_ (delta , gamma)$ are isomorphisms, and we have #math.equation(block: true, numbering: "(1)", supplement: "Equation",
   $
        (cC^(i+1) _(delta, gamma))^(-1) oo Psi^i_(gamma) = Psi^i_(delta) oo (cC^i_ (delta , gamma))^(-1). 
   $) <eq3>
   
  Finally, note that each $w_(i+1) (rho)$ consists of nothing but compositions of $cC^(i+1) _(ast, ast)$ or its inverse, apart from a sign.
  So for each summand on the left-hand side of @eq1, we can imagine passing $Psi_alpha^i$ step-by-step from right to left using @eq2 or @eq3, changing the superscript $(i+1)$ to $i$ at each step, and eventually $Psi_alpha^i$ becomes $Psi_beta^i$ on the far left, which is exactly a corresponding summand on the right-hand side of @eq1.
]

#proposition[
  The bottom face (hence as well as the top face) of @cube commutes. 
]
<bottom-commute>
#proof[
  By induction, it suffices to consider $Sigma = {(sigma lt.tri tau)}$.
  It then suffices to show for any critical $k$-simplex $omega$ and any $k$-simplex $alpha$ that 
  $phi_k^(i+1) |_(omega, alpha) oo Psi_omega^i = Psi_alpha^i oo phi_k^i |_(omega, alpha).
  $
  Expand this using @def-phi, and the proof for @front-commute would also work, again thanks to the naturality of $Psi^i$.
]

#theorem[
  For each $k >= 0$, $bC_k^cx$ and $bM_k^cx$ induce the same persistent homology.
]
<same-persistence>
#proof[
  We have shown that @cube commutes. In other words, in the category of chain complexes, we have the following commutative diagram: 
// https://t.yw.je/#N4Igdg9gJgpgziAXAbVABwnAlgFyxMJZABgBpiBdUkANwEMAbAVxiRACMBhAfQGMAPAHpYQAX1LpMufIRQBGclVqMWbLnyEAKLAGo5ASjESQGbHgJEycpfWatEHALIbhRyWZlEF16rdUP2ZwFBbT1DUSUYKABzeCJQADMAJwgAWyQyEBwIJAVlOzYABWxhDTcQZLSkACZqbKQAZl8VeyysBlhNYqx9UoFyyvTEWqycxEy-VrQACywXEXFElKGm0dzmgocZueDQgzEKUSA
#align(center, commutative-diagram(
  node-padding: (50pt, 50pt),
  node((0, 0), [$bC_cx^i$]),
  node((0, 1), [$bC_cx^(i+1)$]),
  node((1, 0), [$bM_cx^i$]),
  node((1, 1), [$bM_cx^(i+1).$]),
  arr((0, 0), (0, 1), [$Psi^i_cx$]),
  arr((1, 0), (1, 1), [$tilde(Psi)^i_cx$]),
  arr((1, 0), (0, 0), [$phi_cx^i$]),
  arr((1, 1), (0, 1), [$phi_cx^(i+1)$]),
))
By the functoriality of homology, for each dimension $k >= 0$, the following commutes for any pair of $1<= i < j <= l$:
// https://t.yw.je/#N4Igdg9gJgpgziAXAbVABwnAlgFyxMJZABgBpiBdUkANwEMAbAVxiRACMAJAfQGsACABQBjAMIA9LA<KEY>IRQBGcl<KEY>TVb6zVog48Bh<KEY>XXX<KEY>SLZNkgA
// #align(center, commutative-diagram(
//   node-padding: (50pt, 50pt),
//   node((0, 0), [$bH_k (bC^i_cx)$]),
//   node((0, 1), [$bH_k (bC^(i+1) _cx)$]),
//   node((1, 0), [$bH_k (bM^i _cx)$]),
//   node((1, 1), [$bH_k (bM^(i+1) _cx).$]),
//   arr((0, 0), (0, 1), [$bH_k Psi^i _cx$]),
//   arr((1, 0), (1, 1), [$bH_k tilde(Psi)^i _cx$]),
//   arr((1, 0), (0, 0), [$bH_k phi^i _cx$]),
//   arr((1, 1), (0, 1), [$bH_k phi^(i+1 ) _cx$], label-pos: right),
// ))

// https://t.yw.je/#N4Igdg9gJgpgziAXAbVABwnAlgFyx<KEY>BdUk<KEY>
#align(center, commutative-diagram(
  node-padding: (50pt, 50pt),
  node((0, 0), [$bH_k (bC^i)$]),
  node((0, 1), [$bH_k (bC^(i+1))$]),
  node((1, 0), [$bH_k (bM^i)$]),
  node((1, 1), [$bH_k (bM^(i+1))$]),
  node((0, 2), [$bH_k (bC^(j-1))$]),
  node((0, 3), [$bH_k (bC^(j))$]),
  node((1, 2), [$bH_k (bM^(j-1))$]),
  node((1, 3), [$bH_k (bM^(j))$]),
  arr((0, 0), (0, 1), [$bH_k Psi^i$]),
  arr((1, 0), (1, 1), [$bH_k tilde(Psi)^i$]),
  arr((1, 0), (0, 0), [$bH_k phi^i$]),
  arr((1, 1), (0, 1), [$bH_k phi^(i+1)$]),
  arr((0, 2), (0, 3), [$bH_k Psi^(j-1)$]),
  arr((1, 2), (0, 2), [$bH_k phi^(j-1)$]),
  arr((1, 3), (0, 3), [$bH_k phi^(j)$]),
  arr((1, 2), (1, 3), [$bH_k tilde(Psi)^(j-1)$]),
  arr((0, 1), (0, 2), [$...$]),
  arr((1, 1), (1, 2), [$...$]),
))
By @morse-equivalent, each vertical line is an isomorphism between homology groups, so each $bH_k tilde(Psi)^(i->j)$ would have an isomorphic image as $bH_k Psi^(i->j)$. The result thus follows from the definition of persistent homology.
]
// #TODO[don't know if we need the dot..]

= Conclusion

In this project, working with a finite simplicial complex $K$ and a field $FF$, we have obtained the following main results:
+ We have defined a cosheaf $cC$ over $K$ taking values in $VF$ (@def-cosheaf), defined the chain complex $bC_cx (K; cC)$ (@def-cosheaf-chain and @cosheaf-is-chain) and its induced homology groups $bH_cx (K; cC)$ (@cosheaf-homology-groups), and defined the constant cosheaf $underline(V)_K$ for any $FF$-vector space $V$ (@constant-cosheaf);
+ We have defined a morphism $Phi : cC -> cC'$ of cosheaves over $K$ (@morphism-of-cosheaves), shown that it induces maps on the chain complexes $bC_cx (K; cC) -> bC_cx (K; cC')$ (@morphism-induce-chain) and on homology groups $bH_cx (K; cC) -> bH_cx (K; cC')$(@morphism-induce-homology), defined when such a $Phi$ is a (strict) monomorphism, a (strict) epimorphism and an isomorphism (@def-mono), and identified its inverse if $Phi$ is an isomorphism (@iso-inverse);
+ We have given some examples of $K$ and $cC$ (@task-3-1, @task-3-2, and @task-3-3) and shown that there does not exist a strict epimorphism $Phi : FK -> cC$ which induces an isomorphism on homology for any $K$ and $cC$ (@task-3-4); 
+ We have defined a filtration ${cC^i}$ of a cosheaf $cC$  of $K$ and defined the persistent homology of $K$ with coefficients in ${cC^i}$(@def-filtration);
+ We have defined an acyclic partial matching $Sigma$ on $K$ which is compatible with a filtration ${cC^i}$ (@def-compatible) and offered an example (@fit-example-1);
+ We have defined the Morse chain complex $bC_cx^Sigma (K ; cC^i)$ of $Sigma$ with coefficients in ${cC^i}$ when $Sigma$ is compatible with ${cC^i}$ (@def-morse). After proving an 'induction principle' (@induction-principle) for Morse complexes, we verified that $bC_cx^Sigma (K ; cC^i)$ is a chain complex (@morse-is-chain) and shown that $bC_cx^Sigma (K ; cC^i)$ is chain homotopy equivalent to $bC_cx (K ; cC^i)$ (@morse-equivalent). By constructing relevant maps and showing the commutativity of @cube (@front-commute and @bottom-commute), we have deduced that $bC_cx^Sigma (K ; cC^i)$ and $bC_cx (K ; cC^i)$ induce the same persistent homology (@same-persistence).

As the Morse chain complex is constructed using only a subset of (critical) simplices in $K$, it has the potential to simplify the computation of the persistent homology with coefficients in a filtration ${cC^i}$. One shortcoming of the current method is that the condition which we have imposed for an acyclic partial matching $Sigma$ to be compatible with ${cC^i}$ is a rather strong one and thus may be difficult to satisfy in a practical setting.

#bibliography("bib.yml")