\section{Introduction}
 The notion of persistence diagram  of  \cite{cohen2007stability} was recently extended  by Patel to the setting of constructible persistence modules $F:\mathbf{R}\rightarrow \mathcal{C}$ where $\mathcal{C}$ is an essentially small, symmetric monoidal category with images \cite{patel2018generalized}. In a nutshell, the persistence diagram of  $F:\mathbf{R}\rightarrow \mathcal{C}$ is obtained via M\"obius inversion of the map sending each pair $s\leq t$ in $\mathbf{R}$ to the \emph{image} of the morphism $F(s\leq t)$ in $\mathcal{C}$. This map can be regarded as a generalization of both the \emph{rank invariant} \cite{carlsson2009theory} and the \emph{persistent homology group} \cite{cohen2007stability}.

In this paper we further generalize the notion of  rank invariant/persistence diagram to the setting of arbitrary poset-indexed functors $F:\mathbf{P}\rightarrow \mathcal{C}$, where, besides being symmetric, monoidal, essentially small and having images, the target category $\mathcal{C}$ is assumed to be (finitely) bicomplete. A motivation for considering such level of generality is, as suggested by Patel, the possibility of studying torsion in data, e.g. persistent homology groups with integer coefficients. Specifically, we identify an explicit formula for the generalized persistence diagram of $F$ in terms of the generalized rank invariant of $F$ that we will define.  We in particular prove that, given an \emph{interval decomposable} diagram of vector spaces, its rank invariant and its persistence diagram can be translated into each other, and either of them contains enough information to reconstruct the diagram up to isomorphism.

Due mainly to pedagogical reasons, we begin our presentation by defining the rank invariant and the persistence diagram of a zigzag diagram of vector spaces \cite{zigzag}. This construction, being based on categorical considerations,  is \emph{universal} across categories and thus,  we straightforwardly generalize it in order to define a notion of rank invariant and persistence diagram of any poset-indexed persistence modules valued in categories other than the category of vector spaces.

From a different perspective, our decision to focus the presentation first on the setting of zigzag diagrams is  motivated by extensive theoretical and algorithmic study on zigzag persistence \cite{botnan2018algebraic,botnan2015interval,zigzag,carlsson2019parametrized,curry2016classification,milosavljevic2011zigzag,elchesen2018reflection,oudot2015zigzag}, and the large number of concrete applications in mobile sensor networks, image processing, analysis of time-varying metric spaces/graphs that give rise to zigzag persistence \cite{adams2015evasion,corcoran,kim2017stable,kim2018CCCG,mata2015zigzag}.  In particular, in \cite{kim2017stable,kim2018CCCG}, zigzag persistence of graphs, partitions, or homology groups are induced as signatures of time-varying metric data. This motivates us to find stable invariants for zigzag persistence valued in other than the category of vector spaces.

\subsection{Our contributions}

By $\mathcal{C}$, we denote a symmetric monoidal, essentially small, (finitely-)bicomplete category with images.
\begin{enumerate}[label=(\roman*)]
\item We generalize the notion of rank invariant to arbitrary poset-indexed functors (i.e. generalized persistence modules \cite{bubenik2014categorification}).  In particular, our construction generalizes Patel's rank function \cite{patel2018generalized}: see Definition \ref{def:fully generalized rank invariant} and Example \ref{ex:fully general rank invariant} \ref{item:fully general rank invariant-1-parameter}. For any zigzag diagram of vector spaces, we show that our construction of the rank invariant is not only more faithful than the one introduced by V.~Puuska  \cite{puuska2017erosion}, but also becomes a \emph{complete} invariant: see Theorem \ref{thm:completeness}, Example \ref{ex:fully general rank invariant} \ref{item:fully general rank invariant-zigzag}, Remark \ref{rem:rk is complete}, and Appendix \ref{sec:puuska}. \label{item:rank invariant}
\end{enumerate}
In the sequel, by $\mathbf{P}$, we denote a connected, essentially finite poset (Definitions \ref{def:connected poset} and \ref{def:essentially}). Also, let $\mathbf{vec}$ be the category of vector spaces over a fixed field $\mathbb{F}$.
\begin{enumerate}[resume,label=(\roman*)]

\item We extend the notion of generalized persistence diagram by Patel \cite{patel2018generalized} to arbitrary functors $\mathbf{P}\rightarrow \mathcal{C}$. In particular, for any interval decomposable persistence module  $F:\mathbf{P}\rightarrow \mathbf{vec}$,  the persistence diagram/barcode of $F$ can be extracted from the rank invariant by the \emph{principle of inclusion-exclusion} in combinatorics (Proposition \ref{prop:completeness}). This implies that our construction of rank invariant is \emph{complete} invariant for interval decomposable persistence modules. Also, as a by-product, we obtain a novel necessary condition for the interval decomposability of persistence modules $\mathbf{P}\rightarrow \mathbf{vec}$: See Remark \ref{rem:implication2} and Example \ref{ex:Amit}.\label{item:generalized PD}

\item It is well known that a Reeb graph can be seen as a zigzag persistence in the category of sets  \cite{curry2016classification,de2016categorified}. In this respect,  we show that the $0$-th level set barcode of a Reeb graph can be computed in a purely set-theoretic setting \emph{without passing to the category of vector spaces} (Section \ref{sec:reeb graph}). As a corollary, we partially promote the semicontinuity theorem by Patel to a Lipschitz continuity theorem (Corollary \ref{cor:promotion}) and this continuity theorem further extends to a certain class of Reeb graphs (Theorem \ref{thm:stability for sets}). These results indicate that the semicontinuity theorem by Patel is open to further improvement.\label{item:semicontinuity}\label{item:equivalence}
\end{enumerate}
\subsection{Categorical view of the rank invariant}

Given an $F:\mathbf{P}\rightarrow \mathcal{C}$, by combining the limit cone of $F$ and the colimit cocone of $F$, one obtains the canonical limit-to-colimit map $\phi_F:\varprojlim F \rightarrow \varinjlim F$.

Consider the collection $\mathbf{Con}(\mathbf{P})$ of all subposets of $\mathbf{P}$ such that their Hasse diagrams are connected graphs (Definition \ref{def:interval poset}). For each $I\in \mathbf{Con}(\mathbf{P})$, we can consider the restricted diagram $F|_{I}:I\rightarrow \mathcal{C}$. Let us define $\mathrm{im}(F|_{I})$ to be the \emph{image}\footnote{The image of a morphism $f:a\rightarrow b$ is defined as the smallest subobject of $b$ such that $f$ factors through \cite[p.12]{mitchell1965theory}} of the canonical map $\phi_{F|_{I}}:\varprojlim F|_{I} \rightarrow \varinjlim F|_{I}$. As a generalization of the rank function in \cite{mccleary2018bottleneck,patel2018generalized}, we define the \emph{rank invariant} of $F$ as the function\footnote{$\mathcal{I}(\mathcal{C})$ denotes the collection of all isomorphism classes of $\mathcal{C}$.} $\mathrm{rk}(F):\mathbf{Con}(\mathbf{P})\rightarrow \mathcal{I}(\mathcal{C})$ assigning to each $I\in\mathbf{Con}(\mathbf{P})$ the isomorphism class of $\mathrm{im}(F|_I)$:
\begin{equation}\label{eq:our rank invariant}
    \mathrm{rk}(F)(I):= [\mathrm{im}(\phi_{F|_{I}})].
\end{equation}

Restricted to the case when $\mathcal{C}=\mathbf{vec}$, related ideas are being explored by several researchers: Botnan, Oppermann and Steen have been studying the rank of $\phi_F$ for counting ``thin" summands in the indecomposable decomposition of $F:\mathbf{P}\rightarrow \mathbf{Vec}$. We remark that their work is addressing a generalized version of one of our results (Lemma \ref{lem:meaning of rank}), see announcement in \cite{botnan2017talk}. Also, Chambers and Letscher \cite{chambers2018persistent} define persistent homology for a filtration over a directed graph as the image of the canonical map between the limit and colimit.

Botnan and Lesnick exploited the notion of \emph{left Kan extensions} for addressing  stability of barcode of a zigzag module \cite{botnan2018algebraic}. We remark that $\mathrm{rk}(F)$ above can be interpreted as an invariant of $F$ which is obtained by interconnecting the left and right Kan extensions of $F$ along a certain restriction functor; see Sections \ref{sec:magnus} and \ref{sec:mike}.

\paragraph{Organization.} In Section \ref{sec:prelim} we briefly review basic concepts from category theory and persistence theory, specifically zigzag persistence. In Section \ref{sec:the rank invariant} we define the rank invariant of a zigzag module (i.e. zigzag diagram of vector spaces) and show that there is a well defined procedure to translate the  barcode of a zigzag module into its rank invariant, and vice versa.  In Section \ref{sec:rank invariant in general} we define the rank invariant and the persistence diagram of a functor  $\mathbf{P}\rightarrow \mathcal{C}$ by generalizing ideas in the previous section. In Section \ref{sec:reeb graph} we propose a novel viewpoint on Reeb graphs and their $0$-th level set barcodes. This new perspective  provides a new method to compute the $0$-th level set barcodes of Reeb graphs without passing to the category of vector spaces. Also, we establish stability results for the persistence diagrams of merge trees and ``untwisted" Reeb graphs. In Section \ref{sec:discussion} we discuss possible extensions.

\tableofcontents

\section{Preliminaries}\label{sec:prelim}
In Section \ref{sec:category} we set up terminology and notation relevant to category theory. In Section \ref{sec:details about interval modules} we review the notion of poset-indexed persistence modules and their interval decomposability. Also, we introduce notation relevant to zigzag persistence modules.

\subsection{Category theory elements.}\label{sec:category}

\paragraph{Categories.} Consult \cite{awodey2010category, mac2013categories} for general definitions related to category theory. For any category $\mathcal{C}$, let $\mathrm{ob}(\mathcal{C})$ and $\hom(\mathcal{C})$ denote the class/set of all objects and that of all morphisms in $\mathcal{C}$, respectively. Let $I$ be a small category, i.e. $\mathrm{ob}(I)$ and $\hom(I)$ are sets. For any two functors $F,G:I\rightarrow \mathcal{C}$, we write $F\cong G$ if $F$ and $G$ are naturally isomorphic. A functor $F:I\rightarrow \mathcal{C}$ will sometimes be referred to as a \emph{diagram}. Since the domain $I$ is small, we also refer to $F$ as a \emph{small} diagram. In particular, if  $\mathrm{ob}(I)$ and $\hom(I)$ are finite sets, then $F:I\rightarrow \mathcal{C}$ will be called a finite diagram. A sub-diagram of $F$ means the restriction $F|_J$ to a full subcategory $J$ of $I$.  The following categories will be of main interest in this paper.
\begin{enumerate}[label=(\roman*)]
    \item By $\mathbf{Vec}$ and $\mathbf{vec}$, we mean the category of vector spaces and \emph{finite} dimensional vector spaces, respectively with linear maps over a fixed field $\mathbb{F}$.
    \item By $\mathbf{Set}$ and $\mathbf{set}$, we mean the category of sets and \emph{finite} sets, respectively with set maps.
\end{enumerate}

\subsection{Interval decomposability and barcodes}\label{sec:details about interval modules}

Given any poset $\mathbf{P}$, we regard $\mathbf{P}$ as the category: Objects are elements of $\mathbf{P}$. For any $p,q\in \mathbf{P}$, there exists a unique morphism $p\rightarrow q$  if  and only if $p\leq q$.

For $\mathbf{P}$ a poset and $\mathcal{C}$ an arbitrary category, $F:\mathbf{P}\rightarrow \mathcal{C}$ a functor, and $s\in \mathbf{P}$, let $F_s:=F(s)$. Also, for any pair $s\leq t$ in $\mathbf{P}$, let $\varphi_F(s,t):F_s\rightarrow F_t$ denote the morphism $F(s\leq t).$
Any functor $F:\mathbf{P}\rightarrow \mathbf{vec}$ is said to be a \emph{$\mathbf{P}$-indexed module}.

\paragraph{Interval modules and direct sums.}  We follow the notation/definition from \cite{botnan2018algebraic} in what follows.
\begin{definition}[Intervals]\label{def:intervals} Given a poset $\mathbf{P}$, an \emph{interval} $\mathcal{J}$ of $\mathbf{P}$ is any subset $\mathcal{J}\subset \mathbf{P}$ such that
	\begin{enumerate}[label=(\roman*)]
		\item $\mathcal{J}$ is non-empty.
		\item If $r,t\in \mathcal{J}$ and $r\leq s\leq t$, then $s\in \mathcal{J}$.
		\item (connectivity) For any $s,t\in \mathcal{J}$, there is a sequence $s=s_0,s_1,\cdots,s_l=t$ of elements of $\mathcal{J}$ with $s_i$ and $s_{i+1}$ comparable for $0\leq i\leq l-1$.\label{item:intervals3}
	\end{enumerate}
By $\mathbf{Int}(\mathbf{P})$, we denote the collection of all intervals of $\mathbf{P}$.
\end{definition}

\label{interval module}For $\mathcal{J}$ an interval of $\mathbf{P}$, the \emph{interval module} ${I}^{\mathcal{J}}:\mathbf{P}\rightarrow \mathbf{vec}$ is the $\mathbf{P}$-indexed module where

\[{I}_t^{\mathcal{J}}=\begin{cases}
\mathbb{F}&\mbox{if}\ t\in \mathcal{J},\\0
&\mbox{otherwise.}
\end{cases}\hspace{20mm} \varphi_{I^{\mathcal{J}}}(s,t)=\begin{cases} \mathrm{id}_\mathbb{F}& \mbox{if} \,\,s,t\in\mathcal{J},\ s\leq t,\\ 0&\mbox{otherwise.}\end{cases}\]

Let $F,G$ be $\mathbf{P}$-indexed modules. The \emph{direct sum $F\bigoplus G$ of $F$ and $G$} is the $\mathbf{P}$-indexed module defined as follows: for all $s\in \mathbf{P}$, $(F\bigoplus G)_s:=F_s\bigoplus G_s$ and for all $s\leq t$ in $\mathbf{P}$, the linear map $\varphi_{F\bigoplus G}(s,t):(F\bigoplus G)_s \rightarrow (F\bigoplus G)_t$ is defined by  \[\varphi_{F\bigoplus G}(s,t)(v,w):=\big(\varphi_F(s,t)(v),\varphi_G(s,t)(w)\big)\] for all $(v,w)\in (F\bigoplus G)_s$. We say that a $\mathbf{P}$-indexed module $F$ is \textit{decomposable} if $F$ is (naturally) isomorphic to $G_1\bigoplus G_2$ for some non-trivial $\mathbf{P}$-indexed modules $G_1$ and $G_2$, and we denote it by  $F\cong G_1\bigoplus G_2$. Otherwise, we say that $F$ is \textit{indecomposable}.

\begin{proposition}[{\cite[Proposition 2.2]{botnan2018algebraic}}] ${I}^\mathcal{J}$ is indecomposable.
\end{proposition}

\paragraph{Barcodes.} Recall that \textit{a multiset} is a collection of objects (called elements) in which elements may occur more than once. We call the number of instances of an element in a specific multiset \textit{the multiplicity} of the element. For example, $A=\left\{\!\!\left\{ x,x,y\right\}\!\!\right\}$ is a multiset and the multiplicity of $x$ is two. Also, this multiset $A$ is distinct from the multiset $\left\{\!\!\left\{ x,y \right\}\!\!\right\}$.

\begin{definition}[Interval decomposability]\label{def:interval decomposable}A $\mathbf{P}$-indexed module $F$ is \emph{interval decomposable} if there exists a multiset $\mathrm{barc}^{\Pb}(F)$ of intervals (Definition \ref{def:intervals}) of $\mathbf{P}$ such that
\[F\cong \bigoplus_{\mathcal{J}\in \mathrm{barc}^{\Pb}(F)}I^{\mathcal{J}}\ \ \ \]
\end{definition}

It is well-known that, by the theorem of Azumaya-Krull-Remak-Schmidt \cite{azumaya1950corrections}, such a decomposition is unique up to a permutation of the terms in the direct sum. Therefore, the multiset $\mathrm{barc}^{\Pb}(F)$ is unique if $F$ is interval decomposable  since a multiset is careless of the order of its elements.
\begin{definition}[Barcodes]\label{def:barcode}
We call $\mathrm{barc}^{\Pb}(F)$ in Definition \ref{def:interval decomposable} the \emph{barcode} of $F.$
\end{definition}

Given any two posets $\mathbf{P},\mathbf{P}'$, we assume that by default the product $\mathbf{P}\times\mathbf{P}'$ is equipped with the partial order where $(p,p')\leq (q,q')$ if and only if $p\leq p'$ and $q\leq q'$. We regard the extended real line $\overline{\mathbf{R}}:=\mathbf{R}\cup\{-\infty,\infty\}$ as a poset with the canonical order $\leq$. Also, by $\overline{\mathbf{R}}^\mathrm{op}$ we mean the opposite category of $\overline{\mathbf{R}}$, i.e. for any $p,q\in \overline{\mathbf{R}}$, there exists a morphism $p\rightarrow q$ if and only if $p\geq q.$ The following posets will be used throughout this paper:

\begin{figure}
    \centering
      \includegraphics[width=0.8\textwidth]{posets_new_combi.png}
    \caption{(A) The shaded region stands for the poset $\mathbf{U}$. For $\mathbf{u},\mathbf{u}'\in \mathbf{U}$ as marked in the figure, we have $\mathbf{u}\leq\mathbf{u}'$. Together with the vertical line segment on the left, the horizontal line segment on the top, and the point $(-\infty,\infty)$, the poset $\overline{\mathbf{U}}$ is illustrated. (B) The posets $\mathbf{ZZ}$ and $\mathbf{U}$. }
    \label{fig:U}
\end{figure}

\begin{definition}[Several posets]\label{def:posets}
\begin{enumerate}[label=(\roman*)]
    \item  The posets \[\mathbf{U}:=\left\{(u_1,u_2)\in \mathbf{R}^2: u_1\leq u_2\right\},\hspace{5mm}\overline{\mathbf{U}}:=\left\{(u_1,u_2)\in \overline{\mathbf{R}}^2: u_1\leq u_2\right\}\]are equipped with the partial order inherited from $\overline{\mathbf{R}}^{\mathrm{op}}\times \overline{\mathbf{R}}$ (see Figure \ref{fig:U}).\label{item:posets1}

    \item \label{item:ZZ}The poset $\mathbf{ZZ}=\{(i,j)\in \mathbf{Z}^2: j=i\ \mbox{or}\ j=i-1\}$ has the partial order inherited from $\mathbf{R}^{\mathrm{op}}\times \mathbf{R}$.

\end{enumerate}
\end{definition}

\begin{definition}[Zigzag module]Any functor $F:\mathbf{ZZ}\rightarrow \mathbf{vec}$ is called a \emph{zigzag module}.
\end{definition}

\begin{theorem}[Interval decomposability of 1-D persistence modules and zigzag modules {\cite{botnan2015interval,zigzag,crawley2015decomposition}}]\label{thm:interval decomposition1}\label{thm:interval decomposition0}  For any $\mathbf{P} \in \{\mathbf{R},\mathbf{Z},\mathbf{ZZ}\}$, $\mathbf{P}$-indexed modules are interval decomposable. Also, for each interval $I$ of $\mathbf{ZZ}$ (Definition \ref{def:intervals}), $I$-indexed modules are interval decomposable.
\end{theorem}

\paragraph{The barcode associated to a zigzag module.} By Theorem \ref{thm:interval decomposition0}, any zigzag module $M:\mathbf{ZZ}\rightarrow \mathbf{vec}$ admits a \emph{barcode} (Definition \ref{def:barcode}), which will be denoted by $\mathrm{barc}^{\ZZ}(M)$.

\begin{notation}[Intervals of $\mathbf{ZZ}$]\label{nota:intervals of zz} The notation introduced in \cite{botnan2018algebraic} is useful for describing barcodes of zigzag modules: Letting $\preceq$ (resp. $\prec$) denote the partial order (resp. the strict partial order) on $\mathbf{Z}^2$ (not on $\mathbf{Z}^{\mathrm{op}}\times \mathbf{Z}$), any interval of $\mathbf{ZZ}$ falls into  one of the following four types:
	\begin{align*}
	(b,d)_{\mathbf{ZZ}}&:=\{(i,j)\in \mathbf{ZZ}: (b,b)\prec(i,j)\prec(d,d)\}&&\mbox{for\   $b<d$ in $\mathbf{Z}\cup \{-\infty,\infty\}$},\\
	[b,d)_{\mathbf{ZZ}}&:=\{(i,j)\in \mathbf{ZZ}: (b,b)\preceq (i,j)\prec(d,d)\}&&\mbox{for    $b<d$ in  $\mathbf{Z}\cup \{\infty\}$},\\
	(b,d]_{\mathbf{ZZ}}&:=\{(i,j)\in \mathbf{ZZ}: (b,b)\prec (i,j)\preceq(d,d)\}&& \mbox{for    $b<d$ in  $\mathbf{Z}\cup \{-\infty\}$},\\
	[b,d]_{\mathbf{ZZ}}&:=\{(i,j)\in \mathbf{ZZ}: (b,b)\preceq (i,j)\preceq(d,d)\}&& \mbox{for   $b\leq d$ in $\mathbf{Z}$}.
	\end{align*}

See Figure \ref{fig:intervals} for examples. Specifically, we let $\langle b,d \rangle_{\mathbf{ZZ}}$ denote any of the above types of intervals. By utilizing this notation, the barcode of a zigzag module $M:\mathbf{ZZ}\rightarrow \mathbf{vec}$ can be expressed, for some index set $J$, as
\[\mathrm{barc}^{\ZZ}(M)=\left\{\!\!\left\{\langle b_j,d_j\rangle_\mathbf{ZZ}: M\cong \bigoplus_{j\in J}I^{\langle b_j,d_j \rangle_\mathbf{ZZ}} \right\}\!\!\right\}.\] Here, $\left\{\!\!\left\{\cdot\right\}\!\!\right\}$ is used instead of $\{\cdot\}$ to indicate $\mathrm{barc}^{\ZZ}(M)$ is a \emph{multiset.}

\end{notation}
\begin{figure}
	\begin{center}
		\begin{tikzpicture}[thick,scale=0.51, every node/.style={scale=0.6}]
		\fill[pink, opacity=0.4] (-0.5,-1.5)--(0.5,-1.5)--(0.5,-0.5)--(1.5,-0.5)--(1.5,0.5)--(0.5,0.5)--(-0.5,0.5);
		\fill (-2,-2) circle (0.7mm);
		\fill (-1,-2) circle (0.7mm);
		\fill (-1,-1) circle (0.7mm);
		\fill (0,-1) circle (0.7mm);
		\fill (0,0) circle (0.7mm);
		\fill (1,0) circle (0.7mm);
		\fill (1,1) circle (0.7mm);
		\fill (2,1) circle (0.7mm);
		\fill (2,2) circle (0.7mm);
		\fill (2.5,2.5) circle (0.4mm);
		\fill (2.6,2.6) circle (0.4mm);
		\fill (2.7,2.7) circle (0.4mm);
		\fill (-2.5,-2.5) circle (0.4mm);
		\fill (-2.6,-2.6) circle (0.4mm);
		\fill (-2.7,-2.7) circle (0.4mm);
		\draw[->,>=stealth'] (-1,-2)--(-1.9,-2);
		\draw[->,>=stealth'] (-1,-2)--(-1,-1.1);
		\draw[->,>=stealth'] (0,-1)--(-0.9,-1);
		\draw[->,>=stealth'] (0,-1)--(0,-0.1);
		\draw[->,>=stealth'] (1,0)--(0.1,0);
		\draw[->,>=stealth'] (1,0)--(1,0.9);
		\draw[->,>=stealth'] (2,1)--(1.1,1);
		\draw[->,>=stealth'] (2,1)--(2,1.9);
		\draw[->,>=stealth'] (-2,-2.5)--(-2,-2.1);
		\draw[->,>=stealth'] (2.5,2)--(2.1,2);
		\draw (-2,-2) node [anchor=south] {$(-2,-2)$};
		\draw (-1,-1) node [anchor=south] {$(-1,-1)$};
		\draw (0,0) node [anchor=south] {$(0,0)$};
		\draw (1,1) node [anchor=south] {$(1,1)$};
		\draw (2,2) node [anchor=south] {$(2,2)$};
		\draw (-0.5,-2) node [anchor=north] {$(-1,-2)$};
		\draw (0.5,-1) node [anchor=north] {$(0,-1)$};
		\draw (1.5,0) node [anchor=north] {$(1,0)$};
		\draw (2.5,1) node [anchor=north] {$(2,1)$};
		\draw (0,-4) node {\Large{$(-1,1)_\mathbf{ZZ}$}};
		\end{tikzpicture}
		\begin{tikzpicture}[thick,scale=0.51, every node/.style={scale=0.6}]
		\fill[pink, opacity=0.4] (-1.5,-1.5)--(0.5,-1.5)--(0.5,-0.5)--(1.5,-0.5)--(1.5,0.5)--(-0.5,0.5)--(-0.5,-0.5)--(-1.5,-0.5);
		\fill (-2,-2) circle (0.7mm);
		\fill (-1,-2) circle (0.7mm);
		\fill (-1,-1) circle (0.7mm);
		\fill (0,-1) circle (0.7mm);
		\fill (0,0) circle (0.7mm);
		\fill (1,0) circle (0.7mm);
		\fill (1,1) circle (0.7mm);
		\fill (2,1) circle (0.7mm);
		\fill (2,2) circle (0.7mm);
		\fill (2.5,2.5) circle (0.4mm);
		\fill (2.6,2.6) circle (0.4mm);
		\fill (2.7,2.7) circle (0.4mm);
		\fill (-2.5,-2.5) circle (0.4mm);
		\fill (-2.6,-2.6) circle (0.4mm);
		\fill (-2.7,-2.7) circle (0.4mm);
		\draw[->,>=stealth'] (-1,-2)--(-1.9,-2);
		\draw[->,>=stealth'] (-1,-2)--(-1,-1.1);
		\draw[->,>=stealth'] (0,-1)--(-0.9,-1);
		\draw[->,>=stealth'] (0,-1)--(0,-0.1);
		\draw[->,>=stealth'] (1,0)--(0.1,0);
		\draw[->,>=stealth'] (1,0)--(1,0.9);
		\draw[->,>=stealth'] (2,1)--(1.1,1);
		\draw[->,>=stealth'] (2,1)--(2,1.9);
		\draw[->,>=stealth'] (-2,-2.5)--(-2,-2.1);
		\draw[->,>=stealth'] (2.5,2)--(2.1,2);
		\draw (-2,-2) node [anchor=south] {$(-2,-2)$};
		\draw (-1,-1) node [anchor=south] {$(-1,-1)$};
		\draw (0,0) node [anchor=south] {$(0,0)$};
		\draw (1,1) node [anchor=south] {$(1,1)$};
		\draw (2,2) node [anchor=south] {$(2,2)$};
		\draw (-0.5,-2) node [anchor=north] {$(-1,-2)$};
		\draw (0.5,-1) node [anchor=north] {$(0,-1)$};
		\draw (1.5,0) node [anchor=north] {$(1,0)$};
		\draw (2.5,1) node [anchor=north] {$(2,1)$};
		\draw (0,-4) node {\Large{$[-1,1)_\mathbf{ZZ}$}};
		\end{tikzpicture}	\begin{tikzpicture}[thick,scale=0.51, every node/.style={scale=0.6}]
		\fill[pink, opacity=0.4] (-0.5,-1.5)--(0.5,-1.5)--(0.5,-0.5)--(1.5,-0.5)--(1.5,1.5)--(0.5,1.5)--(0.5,0.5)--(-0.5,0.5);
		\fill (-2,-2) circle (0.7mm);
		\fill (-1,-2) circle (0.7mm);
		\fill (-1,-1) circle (0.7mm);
		\fill (0,-1) circle (0.7mm);
		\fill (0,0) circle (0.7mm);
		\fill (1,0) circle (0.7mm);
		\fill (1,1) circle (0.7mm);
		\fill (2,1) circle (0.7mm);
		\fill (2,2) circle (0.7mm);
		\fill (2.5,2.5) circle (0.4mm);
		\fill (2.6,2.6) circle (0.4mm);
		\fill (2.7,2.7) circle (0.4mm);
		\fill (-2.5,-2.5) circle (0.4mm);
		\fill (-2.6,-2.6) circle (0.4mm);
		\fill (-2.7,-2.7) circle (0.4mm);
		\draw[->,>=stealth'] (-1,-2)--(-1.9,-2);
		\draw[->,>=stealth'] (-1,-2)--(-1,-1.1);
		\draw[->,>=stealth'] (0,-1)--(-0.9,-1);
		\draw[->,>=stealth'] (0,-1)--(0,-0.1);
		\draw[->,>=stealth'] (1,0)--(0.1,0);
		\draw[->,>=stealth'] (1,0)--(1,0.9);
		\draw[->,>=stealth'] (2,1)--(1.1,1);
		\draw[->,>=stealth'] (2,1)--(2,1.9);
		\draw[->,>=stealth'] (-2,-2.5)--(-2,-2.1);
		\draw[->,>=stealth'] (2.5,2)--(2.1,2);
		\draw (-2,-2) node [anchor=south] {$(-2,-2)$};
		\draw (-1,-1) node [anchor=south] {$(-1,-1)$};
		\draw (0,0) node [anchor=south] {$(0,0)$};
		\draw (1,1) node [anchor=south] {$(1,1)$};
		\draw (2,2) node [anchor=south] {$(2,2)$};
		\draw (-0.5,-2) node [anchor=north] {$(-1,-2)$};
		\draw (0.5,-1) node [anchor=north] {$(0,-1)$};
		\draw (1.5,0) node [anchor=north] {$(1,0)$};
		\draw (2.5,1) node [anchor=north] {$(2,1)$};
		\draw (0,-4) node {\Large{$(-1,1]_\mathbf{ZZ}$}};
		\end{tikzpicture}	\begin{tikzpicture}[thick,scale=0.51, every node/.style={scale=0.6}]
		\fill[pink, opacity=0.4] (-1.5,-1.5)--(0.5,-1.5)--(0.5,-0.5)--(1.5,-0.5)--(1.5,1.5)--(0.5,1.5)--(0.5,0.5)--(-0.5,0.5)--(-0.5,-0.5)--(-1.5,-0.5);
		\fill (-2,-2) circle (0.7mm);
		\fill (-1,-2) circle (0.7mm);
		\fill (-1,-1) circle (0.7mm);
		\fill (0,-1) circle (0.7mm);
		\fill (0,0) circle (0.7mm);
		\fill (1,0) circle (0.7mm);
		\fill (1,1) circle (0.7mm);
		\fill (2,1) circle (0.7mm);
		\fill (2,2) circle (0.7mm);
		\fill (2.5,2.5) circle (0.4mm);
		\fill (2.6,2.6) circle (0.4mm);
		\fill (2.7,2.7) circle (0.4mm);
		\fill (-2.5,-2.5) circle (0.4mm);
		\fill (-2.6,-2.6) circle (0.4mm);
		\fill (-2.7,-2.7) circle (0.4mm);
		\draw[->,>=stealth'] (-1,-2)--(-1.9,-2);
		\draw[->,>=stealth'] (-1,-2)--(-1,-1.1);
		\draw[->,>=stealth'] (0,-1)--(-0.9,-1);
		\draw[->,>=stealth'] (0,-1)--(0,-0.1);
		\draw[->,>=stealth'] (1,0)--(0.1,0);
		\draw[->,>=stealth'] (1,0)--(1,0.9);
		\draw[->,>=stealth'] (2,1)--(1.1,1);
		\draw[->,>=stealth'] (2,1)--(2,1.9);
		\draw[->,>=stealth'] (-2,-2.5)--(-2,-2.1);
		\draw[->,>=stealth'] (2.5,2)--(2.1,2);
		\draw (-2,-2) node [anchor=south] {$(-2,-2)$};
		\draw (-1,-1) node [anchor=south] {$(-1,-1)$};
		\draw (0,0) node [anchor=south] {$(0,0)$};
		\draw (1,1) node [anchor=south] {$(1,1)$};
		\draw (2,2) node [anchor=south] {$(2,2)$};
		\draw (-0.5,-2) node [anchor=north] {$(-1,-2)$};
		\draw (0.5,-1) node [anchor=north] {$(0,-1)$};
		\draw (1.5,0) node [anchor=north] {$(1,0)$};
		\draw (2.5,1) node [anchor=north] {$(2,1)$};
		\draw (-2.5,2.5) node {};
		\draw (0,-4) node {\Large{$[-1,1]_\mathbf{ZZ}$}};
		\end{tikzpicture}
	\end{center}
	\caption{\label{fig:intervals}The points falling into the shaded regions comprise the intervals $(-1,1)_\mathbf{ZZ}, [-1,1)_\mathbf{ZZ}, (-1,1]_\mathbf{ZZ}$ and $[-1,1]_\mathbf{ZZ}$ of the poset $\mathbf{ZZ}$, respectively in order.}
\end{figure}

\section{The rank invariant of a zigzag module}\label{sec:the rank invariant}

We aim at generalizing the definition of the rank invariant of standard persistence modules (Definition \ref{def:rank invariant for a persistence module}) to zigzag modules.

Recall the notions of cone and cocone from category theory (Definitions \ref{def:cone} and \ref{def:cocone}). The following observation is the first step toward defining the rank invariant of a zigzag module.

\begin{proposition}[Canonical map from a cone to a cocone]\label{prop:canonical}
Let $M:\mathbf{ZZ}\rightarrow\mathbf{Vec}$. Let $\left(L,(\pi_a)_{a\in \mathbf{ZZ}}\right)$ and $\left(C,(i_a)_{a\in \mathbf{ZZ}}\right)$ be any cone and cocone of $M$, respectively. Then for any $a,b\in \mathbf{ZZ}$, we have that $i_a\circ \pi_a= i_b\circ \pi_b.$
\end{proposition}

\begin{proof}
Let $a=c_1,c_2,\ldots,c_n=b$ be the unique sequence in $\mathbf{ZZ}$ such that $c_j$ and $c_{j+1}$ are comparable for $j=1,\ldots,n-1$. Let $V_j:=M_{c_j}$ for each $j$. Then, we have the combined commutative diagram of $\left(L,(\pi_{c_j})_{j=1,\ldots,n}\right)$ and $\left(C,(i_{c_j})_{j=1,\ldots,n}\right)$ as follows:
\[\begin{tikzcd}
		&&C&&\\ \\mathbb{V}_1\arrow[<->]{r}[description]{f_1}\arrow{rruu}[description]{i_{c_1}}&V_2\arrow{ruu}[description]{i_{c_2}}&V_3\arrow[<->]{l}[description]{f_2}\arrow[<->]{r}[description]{f_3}\arrow{uu}[description]{i_{c_3}}&\cdots\arrow[<->]{r}[description]{f_{n-1}}\arrow{luu}&V_n\arrow{lluu}[description]{i_{c_n}}\\ \\
		&&L\arrow{lluu}[description]{\pi_{c_1}}\arrow{luu}[description]{\pi_{c_2}}\arrow{uu}[description]{\pi_{c_3}}\arrow{ruu}\arrow{rruu}[description]{\pi_{c_n}}&&
		\end{tikzcd}
\]
Without loss of generality, assuming $f_1$ is a map from $V_1$ to $V_2$, we prove that $i_{c_1}\circ \pi_{c_1}= i_{c_2}\circ \pi_{c_2}$. This is clear by tracking the commutativity of the diagram above: \[i_{c_1}\circ \pi_{c_1} = (i_{c_2}\circ f_1)\circ \pi_{c_1} = i_{c_2}\circ (f_1\circ \pi_{c_1}) = i_{c_2}\circ \pi_{c_2}.\]
Similarly, for each $k=2,\ldots, n-1$, we have $i_{c_k}\circ\pi_{c_k}=i_{c_{k+1}}\circ \pi_{c_{k+1}},$ completing the proof.
\end{proof}

\begin{Remark}\label{rem:connectivity is the essence} Note that, in Proposition \ref{prop:canonical}, the uniqueness of the canonical map from $L$ to $C$ is purely because $\mathbf{ZZ}$ is connected (Definition \ref{def:intervals} \ref{item:intervals3}). Therefore, in Proposition \ref{prop:canonical}, the indexing poset $\mathbf{ZZ}$ can be replaced by any interval of $\mathbf{ZZ}$, or any other connected poset $\mathbf{P}$.
\end{Remark}

Recall that a limit (resp. colimit) of a functor $F$ is the terminal (resp. initial) object in the category of cones (resp. cocones) over $F$ (Definitions \ref{def:limit} and \ref{def:colimit}). Also, recall that every $\mathbf{vec}$-valued (resp. $\mathbf{Vec}$-valued) finite (resp. small) diagram has both a limit and a colimit in $\mathbf{vec}$ (resp. $\mathbf{Vec}$) \cite{mac2013categories}. Thus, by virtue of Proposition \ref{prop:canonical}, we can define:

\begin{definition}[The canonical LC map and the rank of a (finite) zigzag module]\label{def:canonical} Fix any interval $I$ of $\mathbf{ZZ}$ (Definition \ref{def:intervals}), and let $M:I \rightarrow\mathbf{vec}$. Consider the limit $\left(\varprojlim M,\ (\pi_k)_{k\in I}\right)$ and the colimit $\left(\varinjlim M,\ (i_k)_{k\in I}\right)$ of $M$. We define the \emph{canonical LC map}\footnote{The ``LC" is a shorthand for limit-to-colimit. } of $M$ as the linear map
\[\psi_M:\varprojlim M\longrightarrow \varinjlim M,\hspace{6mm} \mbox{where $\psi_M:=i_k\circ \pi_k$ for any $k\in I$}.\] We define the \emph{rank} of $M$ as the rank of the canonical LC map of $M$.
\end{definition}

In Definition \ref{def:canonical}, the rank of $M$ cannot exceed $\min_{\mathbf{a}\in I}\dim(M_\mathbf{a})$ and is thus finite. The example below justifies the use of the term ``rank" in Definition \ref{def:canonical}.

\begin{example}\label{ex:trivial cases}
\begin{enumerate}[label=(\roman*)]
    \item  A functor $F:[0,0]_{\mathbf{ZZ}} (=\{(0,0)\})\rightarrow \mathbf{vec}$  amounts to a vector space $F_{(0,0)}$ with the identity map $\mathrm{id}_{F_{(0,0)}}:F_{(0,0)}\rightarrow F_{(0,0)}$. In this case, the rank of $F$ is the dimension of $F_{(0,0)}$. \label{item:trivial cases1}
    \item A functor $G:(0,1]_{\mathbf{ZZ}}\rightarrow \mathbf{vec}$  amounts to the linear map $G_{(1,0)}\stackrel{g}{\longrightarrow}G_{(1,1)}$, where $g=\varphi_G((1,0)\leq (1,1))$. Note that $\varprojlim G \cong G_{(1,0)}$ and $\varinjlim G \cong G_{(1,1)}$ and the rank of $G$ is identical to that of $g$. \label{item:trivial cases2}
\end{enumerate}
\end{example}

Recall that $\mathbf{Int}(\mathbf{ZZ})$ denotes the collection of all intervals of $\mathbf{ZZ}$ (Definition \ref{def:intervals}).

\begin{definition}[Rank invariant of a zigzag module]\label{def:rank invariant}Given $M:\mathbf{ZZ} \rightarrow \mathbf{vec}$, the \emph{rank invariant} of $M$ is the map $\mathrm{rk}(M):\mathbf{Int}(\mathbf{ZZ}) \rightarrow \mathbf{Z}_+$ sending $I\in \mathbf{Int}(\mathbf{ZZ})$ to the rank of the restricted diagram $M|_{I}:I\rightarrow \mathbf{vec}$.
\end{definition}

We remark that the rank invariant of a one-dimensional persistence module can also be interpreted in the same way as in Definition \ref{def:rank invariant}: See Definition \ref{def:rank invariant for a persistence module} and Remark \ref{rem:rank invariant of a persistence module}. Also, in Appendix \ref{sec:puuska} we demonstrate that the rank invariant in Definition \ref{def:rank invariant} is more ``faithful" than the construction considered in \cite{puuska2017erosion}.

Let $\mathbf{P}$ and $\mathbf{Q}$ be any two posets and let $f:\mathbf{P}\rightarrow \mathbf{Q}$. We say that $f$ is \emph{order-reversing} if $p\leq p'$ in $\mathbf{P}$ implies that $f(p)\geq f(p')$ in $\mathbf{Q}$. Also, by $\mathbf{Z}_+$, we mean the poset of non-negative integers with the inequality $\leq$.

\begin{proposition}\label{prop:decreasing} Let $M:\mathbf{ZZ} \rightarrow \mathbf{vec}$. The rank invariant $\mathrm{rk}(M):\mathbf{Int}(\mathbf{ZZ})\rightarrow \mathbf{Z}_+$ is an order-reversing map.
\end{proposition}

Proposition \ref{prop:decreasing} is analogous to the fact that, given an $F:\mathbf{Z}\rightarrow \mathbf{vec}$,
\[\mathrm{rank} \ \varphi_F(i,j)\leq \mathrm{rank} \ \varphi_F(i',j')\  \mbox{for $i'\leq i \leq j \leq j'$ in $\mathbf{Z}$}.
\]

\begin{proof}
\label{proof:decreasing}Take any pair $I,J\in \mathbf{Int}(\mathbf{ZZ})$ with $I\subset J$. Notice that $\varprojlim M|_{J}$ and $\varinjlim M|_{J}$ are a cone and a cocone over $M|_{I}$, respectively (Remark \ref{rem:restriction}). Then by the terminal property of $\varprojlim M|_{I}$ and the initial property of $\varinjlim M|_{I}$, there exist unique morphisms $p:\varprojlim  M|_{J}\rightarrow \varprojlim M|_{I}$ and $i:\varinjlim M_{I}\rightarrow \varinjlim M|_{J}$ such that for each $a\leq b$ in $I$, the following diagram commutes:

\[\begin{tikzcd}&\varinjlim M|_{J}\\
&\varinjlim M|_{I} \arrow[dashed]{u}{i}\\
M_a\arrow{ru}[swap]{i_a}\arrow{ruu}{i'_a}\arrow{rr}[description]{\varphi_M(a\leq b)}&&M_b\arrow{lu}{i_b}\arrow{luu}[swap]{i'_b}\\
&\varprojlim M|_{I}\arrow{lu}[swap]{\pi_a}\arrow{ru}{\pi_b}\\
&\varprojlim M|_{J}\arrow{luu}{\pi'_a}\arrow{ruu}[swap]{\pi'_b}\arrow[dashed]{u}{p}
\end{tikzcd}
\]
Let $a\in I$ (and thus $a\in J$). Let $\psi_M(I)$ be the canonical LC map $\varprojlim M|_{I}\rightarrow \varinjlim M|_{I}$ and similarly define $\psi_M(J)$. Then \[\psi_M(J)=i'_a\circ \pi'_a = (i\circ i_a)\circ(\pi_a\circ p)=i\circ (i_a\circ \pi_a) \circ p=i\circ \psi_M(I)\circ p,\]which implies the rank of $\psi_M(J)$ is less than or equal to that of $\psi_M(I)$, as desired.   \end{proof}

Next we investigate what the rank of a (finite) zigzag module measures:

\begin{proposition}\label{prop:the meaning of rank ZZ}

Fix any $I\in \mathbf{Int}(\mathbf{ZZ})$ and consider a diagram $M:I\rightarrow \mathbf{vec}.$  The rank of the canonical LC map $\psi_M:\varprojlim M\rightarrow \varinjlim M$ is equal to the multiplicity of $I$ in $\mathrm{barc}^I(M)$.

\end{proposition}

We defer the proof of Proposition \ref{prop:the meaning of rank ZZ} to Appendix \ref{sec:the meaning of rank ZZ}.  Proposition \ref{prop:the meaning of rank ZZ} together with Lemma \ref{lem:bijection0} below will allow us to extract the rank invariant $\mathrm{rk}(M)$ from the barcode of $M:\mathbf{ZZ}\rightarrow \mathbf{vec}$.

\begin{lemma}[{\cite[Proposition 2.12]{zigzag}}]\label{lem:bijection0}
Let $I\in \mathbf{Int}(\mathbf{ZZ})$. Given any $M:\mathbf{ZZ}\rightarrow \mathbf{vec}$, there exists a bijection between intervals $I$ in  $\mathrm{barc}^{I}(M|_I)$ and intervals $K\supset I$ in $ \mathrm{barc}^{\ZZ}(M)$.
\end{lemma}

\begin{proposition}[Computation of $\mathrm{rk}(M)$ from $\mathrm{barc}^{\ZZ}(M)$]\label{prop:bridge}Let $M:\mathbf{ZZ}\rightarrow \mathbf{vec}$. For every $I\in \mathbf{Int}(\mathbf{ZZ})$,
\begin{align}
\mathrm{rk}(M)(I)&=\left(\mbox{The total multiplicity of intervals $J\in \mathrm{barc}^{\ZZ}(M)$ such that $I\subset J$}\right).\label{eq:bridge1}
\end{align}
\end{proposition}

\begin{proof}
Fix $I\in \mathbf{Int}(\mathbf{ZZ})$.  By Proposition \ref{prop:the meaning of rank ZZ} and Lemma \ref{lem:bijection0}, the value $\mathrm{rk}(M)(I)$ is equal to the total multiplicity of intervals in $\mathrm{barc}^{\ZZ}(M)$ which contain $I$.
\end{proof}

Note that from Proposition \ref{prop:bridge} it follows that  that $\mathrm{rk}(M)$ can be easily computed from $\mathrm{barc}^{\ZZ}(M)$. This is so despite the fact that, in appearance, the rank invariant $\mathrm{rk}(M)$ is defined  independently of the interval decomposition of $M$ (Definition \ref{def:rank invariant}).

In Appendix \ref{sec:the meaning of rank ZZ} we provide three different, independent proofs of Proposition \ref{prop:bridge}. We do this in this extended paper for pedagogical reasons.
 In particular, the first two proofs are based on \cite{botnan_communication,lesnick-communication} as well as on comments by an anonymous reviewer.

\begin{Remark}\label{rem:meaning2} Informally,  Proposition \ref{prop:bridge} implies that for $I\in \mathbf{Int}(\mathbf{ZZ})$, $\mathrm{rk}(M)(I)$ counts the number of independent persistence features of $M$ over the entire $I$ or beyond. Proposition \ref{prop:bridge} is analogous to the the following fact for $\mathbf{Z}$-indexed modules: Let $F:\mathbf{Z}\rightarrow \mathbf{vec}$ and let $a,b\in \mathbf{Z}$ with $a\leq b$. Then, the rank of $\varphi_F(a, b)$ is equal to the total number of intervals $J\in \mathrm{barc}^{\mathbf{Z}}(F)$ such that $[a,b]\subset J$.
\end{Remark}

Next, reciprocally, we show how to compute the barcode of $M$ from the rank invariant of $M$. This is accomplished by invoking Proposition \ref{prop:bridge} and the principle of inclusion-exclusion.

Let $I:=\langle a,b \rangle_{\mathbf{ZZ}}\in \mathbf{Int}(\mathbf{ZZ})$ with $a\neq -\infty$ (Notation \ref{nota:intervals of zz}). We define $I^-$ to be the interval obtained by adding one more point to $I$ from lower-left. Namely,
\[I^-:=\begin{cases} [a,b\rangle_{\mathbf{ZZ}},&\mbox{if}\  I=(a,b\rangle_{\mathbf{ZZ}},\\
(a-1,b\rangle_{\mathbf{ZZ}},&\mbox{if}\  I=[a,b\rangle_{\mathbf{ZZ}}.
\end{cases}
\]
Similarly, when $I=\langle a,b \rangle_{\mathbf{ZZ}}$ with $b\neq \infty$, define $I^+$ to be the interval obtained by adding one more point to $I$ from upper-right. When $I=\langle a,b \rangle_{\mathbf{ZZ}}$ with $a,b\in \mathbf{Z}$, we define $I^{\pm}$ to be the union of $I^-$ and $I^+$.

\begin{proposition}[Computation of $\mathrm{barc}^{\ZZ}(M)$ from $\mathrm{rk}(M)$]\label{prop:Mobius}
Let $M$ be a zigzag module. The multiplicity of $I$ in $\mathrm{barc}^{\ZZ}(M)$ is
\begin{equation}\label{eq:zz mobius}
\mathrm{rk}(M)(I)-\mathrm{rk}(M)(I^-)\\-\mathrm{rk}(M)(I^+)+\mathrm{rk}(M)(I^{\pm}).
\end{equation}
By convention, we set $\mathrm{rk}(M)(I^-)=\mathrm{rk}(M)(I^{\pm})=0$ if  $I=(-\infty,b\rangle_{\mathbf{ZZ}}$ for some $b\in \mathbf{Z}\cup\{+\infty\}$, and $\mathrm{rk}(M)(I^+)=\mathrm{rk}(M)(I^{\pm})=0$ if $I=\langle a,+\infty)_{\mathbf{ZZ}}$ for some $a\in \mathbf{Z}\cup\{-\infty\}$.

\end{proposition}

\begin{proof}
When $I=(-\infty,\infty)=\mathbf{ZZ}$, formula (\ref{eq:zz mobius}) reduces to $\mathrm{rk}(M)(I)$ and thus the claim directly follows from Proposition \ref{prop:bridge}.

Let $I=\langle b,\infty )_\mathbf{ZZ}$. Then formula (\ref{eq:zz mobius}) reduces to $\mathrm{rk}(M)(I)-\mathrm{rk}(M)(I^-)$. By Proposition \ref{prop:bridge}, $\mathrm{rk}(M)(I)$ is the total multiplicity of intervals $J\in \mathrm{barc}^{\ZZ}(M)$ which contain $I$. Observing that $\mathrm{rk}(M)(I^-)$ is equal to the total multiplicity of intervals $J\in \mathrm{barc}^{\ZZ}(M)$ which \emph{strictly} contain $I$, the claim follows. By a similar argument, the case of $I=(-\infty,d\rangle_{\mathbf{ZZ}}$, $d\in \mathbf{Z}$ is covered.

Assume that $I$ is a finite interval, i.e. $I=\langle a,b \rangle_{\mathbf{ZZ}}$ for $a,b\in \mathbf{Z}$. Again, by Proposition \ref{prop:bridge}, $\mathrm{rk}(M)(I)$ is the total multiplicity of intervals $J\in \mathrm{barc}^{\ZZ}(M)$ which contain $I$. Therefore, it suffices to prove that the last three terms in (\ref{eq:zz mobius}) sum up to
\[-\left(\mbox{The total multiplicity of intervals $J\in \mathrm{barc}^{\ZZ}(M)$ which \emph{strictly} contain $I$} \right).\]
Note that, any $J\in\mathbf{Int}(\mathbf{ZZ})$ strictly contains $I$ if and only if $J$ contains at least one of $I^-$ and $I^+$. Therefore, by the inclusion-exclusion principle and Proposition \ref{prop:bridge}, the value
\[\mathrm{rk}(M)(I^-)+\mathrm{rk}(M)(I^+)-\mathrm{rk}(M)(I^{\pm})\]
is equal to the total multiplicity of intervals $J\in \mathrm{barc}^{\ZZ}(M)$ which \emph{strictly} contain $I$, completing the proof.
\end{proof}

By virtue of Proposition \ref{prop:Mobius}, we can recover $\mathrm{barc}^{\ZZ}(M)$ from the rank invariant $\mathrm{rk}(M)$. We emphasize that $\mathrm{rk}(M)$ has a priori nothing to do with the algebraic decomposition of $M$ (Theorem \ref{thm:interval decomposition0}) in its construction. Proposition \ref{prop:Mobius} also implies:

\begin{theorem}[Completeness of the rank invariant for zigzag modules]\label{thm:completeness} Let $M,N:\mathbf{ZZ}\rightarrow \mathbf{vec}$ be any two zigzag modules with $\mathrm{rk}(M)=\mathrm{rk}(N)$. Then, $M\cong N$.
\end{theorem}

This theorem is analogous to the completeness of the rank invariant for one-dimensional persistence (Theorem \ref{thm:persistence module}).

\section{Rank invariant and persistence diagrams for persistence modules over posets}\label{sec:rank invariant in general}

We have considered the rank invariant of a zigzag module. In fact, most of definitions and propositions considered so far, if not all, need not be restricted to this setting. In Section \ref{subsec:rank invariant in general} we will generalize ideas in Section \ref{sec:the rank invariant}. For this, in Section \ref{sec:Patel0} we first briefly review category theoretical concepts and the notion of Grothendieck groups.

\subsection{More category theory elements and Grothendieck groups}\label{sec:Patel0}

Most of contents in this section can be found in \cite{mitchell1965theory,patel2018generalized,weibel2013k}.

\paragraph{Symmetric monoidal category with images.}\label{sec:terminology}
 A \emph{symmetric monoidal category} $(\mathcal{C},\square)$ is, in brief, a category $\mathcal{C}$ with a binary operation $\square$ on its object and an identity object $e\in \mathrm{ob}(C)$ satisfying the following properties:

\begin{itemize}
    \item (Symmetry) $a\square b \cong b\square a$, for all $a,b\in \mathrm{ob}(C)$.
    \item (Associativity) $a\square(b\square c)\cong (a\square b)\square c$, for all $a,b,c\in \mathrm{ob}(C)$.
    \item (Identity) $a\square e \cong a$, for all $a\in \mathrm{ob}(C)$.
\end{itemize}
We refer the reader to \cite[p.114]{weibel2013k} for the precise definition of a symmetric monoidal
category.

A morphism $f:a\rightarrow b$ is said to be a \emph{monomorphism} if $f$ is left-cancellative: for any morphisms $k_1, k_2: c \rightarrow a$, if $f\circ k_{1}=f\circ k_{2}$, then $k_{1}=k_{2}$. Such $f$ is often written as $f:a\hookrightarrow b$. On the other hand, a right-cancellative morphism $g:a\rightarrow b$ is said to be an \emph{epimorphism}, and often written as $g:a\twoheadrightarrow b$.

\begin{definition}\label{def:images}
A morphism $f:a\rightarrow b$ has an \emph{image} if there exist a monomorphism $h:\mathrm{im}(f)\rightarrow b$ and a morphism $g:a\rightarrow \mathrm{im}(f)$ such that $f=h\circ g$, satisfying the following property: For any monomorphism $h':z\rightarrow b$ and a morphism $g':a\rightarrow z$ with $f=h'\circ g'$, there is a unique morphism $u:\mathrm{im}(f)\rightarrow z$ such that the following diagram commutes:

\[\begin{tikzcd}a\arrow[->]{rr}{f} \arrow{rd}{g} \arrow{rdd}[swap]{g'}&&b\\
&\mathrm{im}(f) \arrow[hook]{ru}{h}\arrow[dashed]{d}{u}\\
& z \arrow[hook]{ruu}[swap]{h'}
\end{tikzcd}
\]
If, moreover, the morphism $g$ is an epimorphism, then $f$ is said to have an \emph{epimorphic image}.
\end{definition}

\begin{Remark}\label{rem:monic}The morphism $u$ in the diagram above is a monomorphism: Assume that there exist two morphisms $k_1,k_2:c\rightarrow \mathrm{im}(f)$ with $u\circ k_1=u\circ k_2$. Then,
\begin{align*}
    u\circ k_1 =u\circ k_2  &\implies h'\circ (u\circ k_1) = h'\circ (u\circ k_2)\\
    &\implies (h'\circ u)\circ k_1 = (h'\circ u)\circ k_2\\
    &\implies h\circ k_1 = h\circ k_2\\
    &\implies  k_1 = k_2&\mbox{since $h$ is a monomorphism.}
\end{align*}
\end{Remark}

A category in which every morphism has an image (resp. epimorphic image) is said to be a \emph{category with images (resp. category with epimorphic images)}. See \cite[p.12]{mitchell1965theory} for more about images.

\paragraph{Complete, cocomplete, essentially small categories} \cite{mac2013categories}.
 A category $\mathcal{C}$ is called \emph{complete} if every small diagram $F:I\rightarrow \mathcal{C}$ has a limit in $\mathcal{C}$. Likewise, a category $\mathcal{C}$ is called \emph{cocomplete} if every small diagram has a colimit in $\mathcal{C}$. If a category $\mathcal{C}$ is both complete and cocomplete, then $\mathcal{C}$ is called \emph{bicomplete}.\footnote{For example, besides $\mathbf{Set}$ and  $\mathbf{Vec}$, examples include the category of groups, the category of abelian groups, the category of topological spaces.} A category $\mathcal{C}$ is called \emph{essentially small} if the collection of isomorphism classes of objects in $\mathcal{C}$ is a set.

\begin{convention}\label{convention} Throughout this paper, $(\mathcal{C},\square)$ (or simply $\mathcal{C}$) will always be:
\begin{enumerate}[label=(\roman*)]
    \item essentially small,
    \item symmetric monoidal,
    \item with images,
    \item a full subcategory\footnote{A subcategory $\mathcal{C}'$ of a category $\mathcal{C}$ is \emph{full} if for all $a,b\in \mathrm{ob}(\mathcal{C})$, $\hom_{\mathcal{C}'}(a,b)=\hom_{\mathcal{C}}(a,b)$.} of a bicomplete category.\label{item:a full subcategory of a bicomplete category}
\end{enumerate}
\end{convention}
Note that we are just adding item \ref{item:a full subcategory of a bicomplete category} to the general setting of a category $\mathcal{C}$ in \cite{patel2018generalized}. In particular, $(\mathbf{set},\sqcup)$ (where $\sqcup$ stands for disjoint union) and $(\mathbf{vec},\oplus)$ (where $\oplus$ stands for direct sum) will be the categories of main interest. Specifically, in the both categories, every morphism has an epimorphic image. We also remark that $\mathbf{set}$ and $\mathbf{vec}$ are full subcategories of the bicomplete categories $\mathbf{Set}$ and $\mathbf{Vec}$, respectively.

\paragraph{Grothendieck groups.} We review the notion of Grothendieck groups from  \cite[Chapter II]{weibel2013k} and \cite[Section 6]{patel2018generalized}. Fix a category $(\mathcal{C},\square)$. Let $\mathcal{I}(\mathcal{C})$ be the set of all isomorphism classes of $\mathcal{C}$. For any $C\in \mathrm{ob}(\mathcal{C})$, let $[C]$ denote the isomorphism class of $C$ in $\mathcal{I}(\mathcal{C}).$ The binary operation in $\mathcal{I}(\mathcal{C})$ is defined as $[a]+[b]:=[a\square b]$. The group completion $\mathcal{A}(\mathcal{C})$ of $\mathcal{I}(\mathcal{C})$ with respect to $+$ is said to be the \emph{Grothendieck group} of $\mathcal{C}$ . Hence, the notions of addition $+$ and subtraction $-$ are well-defined in $\mathcal{A}(\mathcal{C})$. When $\mathcal{C}$ is an abelian category, there is another type of Grothendieck group $\mathcal{B}(\mathcal{C})$.\footnote{Define the relation $\sim$ on $\mathcal{A}(\mathcal{C})$ as $[b]\sim [a]+[c]$ if there exists a short exact sequence $0\rightarrow a\rightarrow b\rightarrow c\rightarrow 0$. Then, $\mathcal{B}(C)$ is defined as the quotient group $\mathcal{A}(\mathcal{C})/\sim$.   The category $\mathbf{vec}$ is an instance of abelian categories, and it holds that $\mathcal{A}(\mathbf{vec})=\mathcal{B}(\mathbf{vec})$ \cite[Example 6.2.1]{patel2018generalized}.} However, it is beyond the scope of this paper to give a complete treatment of $\mathcal{B}(\mathcal{C})$.

\begin{Remark}
\label{rem:counterpart} For the monoid $(\mathcal{I}(\mathbf{vec}),\bigoplus)$ (resp. $(\mathcal{I}(\mathbf{set}),\bigsqcup)$) of isomorphism classes, we have the isomorphism
\[(\mathcal{I}(\mathbf{vec}),\bigoplus)\cong (\mathbf{Z}_+,+)\ \mbox{(resp.  $(\mathcal{I}(\mathbf{set}),\bigsqcup)\cong (\mathbf{Z}_+,+))$},
\] which sends each isomorphism class $[V]\in\mathcal{I}(\mathbf{vec})$ to $\dim(V)$ (resp. $[A]\in\mathcal{I}(\mathbf{set})$ to $\abs{A}$). Extending this isomorphism, we obtain the group isomorphism $(\mathcal{A}(\mathbf{vec}),\bigoplus)$ $\cong(\mathbf{Z},+)$ (resp. $(\mathcal{A}(\mathbf{set}),\bigsqcup)\cong(\mathbf{Z},+)$.).
\end{Remark}

\subsection{Rank invariant and persistence diagrams for persistence modules over posets}\label{subsec:rank invariant in general}

 In this section we define the rank invariant and persistence diagram of a generalized persistence module $\mathbf{P}\rightarrow \mathcal{C}$ when $\mathbf{P}$ satisfies mild assumptions.

\paragraph{Hasse diagram and essentially finiteness.} We begin by reviewing relevant terminology from lattice theory \cite{birkhoff1940lattice}.

\begin{definition}[Locally finite posets]\label{def:locally finite} A poset $\mathbf{P}$ is said to be \emph{locally finite} if for all $p,q\in \mathbf{P}$ with $p\leq q$, the set $[p,q]:=\{r\in \mathbf{P}: p\leq r\leq q\}$ is finite.
\end{definition}

Let $\mathbf{P}$ be a poset and let $p,q\in \mathbf{P}$. We say that $p$ \emph{covers} $q$ if $q< p$ and there is no $r\in \mathbf{P}$ such that $q<r<p$. If either [$p$ covers $q$] or [$q$ covers $p$], then we write $p\asymp q$.

\begin{definition}[Hasse diagram of a poset]   The \emph{Hasse diagram} of a poset $\mathbf{P}$ is a simple graph on the vertex set $\mathbf{P}$, denoted by $\mathrm{Hasse}(\mathbf{P})$, where any two different vertices $p,q\in \mathbf{P}$ are adjacent if and only if $p \asymp q$.
\end{definition}

\begin{definition}[Connected posets]\label{def:connected poset} A poset $\mathbf{P}$ is said to be \emph{connected}, if for all $p,q\in \mathbf{P}$, there exists a sequence $p=p_0,\ldots,p_n=q$ in $\mathbf{P}$ such that $p_i$ and $p_{i+1}$ are comparable, i.e. $p_i\leq p_{i+1}$ or $p_{i+1}\leq p_i$,  for $i=0,\ldots,n-1$.
\end{definition}
 If $\mathbf{P}$ is connected and locally finite, then it is clear that $\mathrm{Hasse}(\mathbf{P})$ is a connected graph.

\begin{definition}[Diagram-connected subposets]\label{def:interval poset} Let $\mathbf{P}$ be any poset. We define $\mathbf{Con}(\mathbf{P})$ as the collection of all subposets $I$ of $\mathbf{P}$ such that $\mathrm{Hasse}(I)$ is connected.\footnote{The condition that $\mathrm{Hasse}(I)$ is connected is equivalent to that the induced subgraph of $\mathrm{Hasse}(\mathbf{P})$ on $I$ is a connected graph.} We equip $\mathbf{Con}(\mathbf{P})$ with the partial order given by \emph{co-finite} inclusion, i.e. a pair $I,J\in \mathbf{Con}(\mathbf{P})$ satisfies $I\leq J$ if and only if  $I\subset J$ and $\abs{J\setminus I}<\infty$.
\end{definition}

\begin{Remark}\label{rem:con(p)}\begin{enumerate}[label=(\roman*)]
    \item For every poset $\mathbf{P}$, $\mathbf{Con}(\mathbf{P})$ is locally finite. \label{item:con(p)1}
    \item Let $\mathbf{P}$ be a locally finite poset. Note that the collection $\mathbf{Int}(\mathbf{P})$ of all intervals of $\mathbf{P}$ (Definition \ref{def:intervals}) is contained in $\mathbf{Con}(\mathbf{P})$. Also, $\mathbf{Int}(\mathbf{P})$ can sometimes be equal to $\mathbf{Con}(\mathbf{P})$, e.g. when $\mathbf{P}=\mathbf{Z}$ or $\mathbf{P}=\mathbf{ZZ}$.\label{item:con(p)2}
\end{enumerate}
\end{Remark}

\begin{definition}[Neighborhood and perimeter]\label{def:perimeter} Let $\mathbf{P}$ be any  poset. Given any $I\in \mathbf{Con}(\mathbf{P})$, we define the \emph{neighborhood} of $I$ as
\[\mathrm{nbd}(I):=\{p\in \mathbf{P}\setminus I: \mbox{there exists}\  q\in I \,\,\mbox{such that}\,\,q\asymp p\}.
\]
The \emph{perimeter} of $I$ is defined as the cardinality $o_{I}$ of $\mathrm{nbd}(I)$.
\end{definition}

We remark that, for each interval $I$ of $\mathbf{Z}$, the perimeter of $I$ is either $0,1$ or $2$: If $I=\mathbf{Z}$, then the perimeter is $0$. For intervals of the form $I=[b,\infty)$, $b\in\mathbf{Z}$ or $I=(-\infty,d]$, $d\in \mathbf{Z}$, the perimeter of $I$ is $1$.  If $I=[b,d]$ for some $b,d\in \mathbf{Z}$, then perimeter of $I$ is $2$. Similarly, for the poset $\mathbf{ZZ}$, the perimeter of any interval of $\mathbf{ZZ}$ is either $0,1$ or $2$.

\begin{definition}[Essentially finite posets]\label{def:essentially} A poset $\mathbf{P}:=(\mathbf{P},\leq)$ is said to be \emph{essentially finite} if
\begin{enumerate}[label=(\roman*)]
    \item $(\mathbf{P},\leq)$ is locally finite, and
    \item For each $I\in \mathbf{Con}(\mathbf{P})$, the perimeter $o_I$ of $I$ is finite.
\end{enumerate}
\end{definition}

Examples of essentially finite posets include all finite posets, the integers $\mathbf{Z}$, the $d$-dimensional integer grid $\mathbf{Z}^d$, and $\mathbf{ZZ}$. %

\paragraph{Rank invariant for generalized persistence modules.} We extend the construction of the rank invariant for zigzag modules (Definition \ref{def:rank invariant}) to a more general setting.

Recall that the well-definedness of the canonical LC map of (finite) zigzag modules only depends on the connectivity of (intervals of) $\mathbf{ZZ}$ (Remark \ref{rem:connectivity is the essence}). Hence, we can define the notion of rank in a more general setting:

\begin{definition}[The rank of $F:\mathbf{P}\rightarrow \mathcal{C}$]\label{def:fully general rank} Let $\mathbf{P}$ be a connected poset. The \emph{rank} of $F:\mathbf{P}\rightarrow \mathcal{C}$ is defined as the isomorphism class of the image of the canonical LC map $\psi_F:\varprojlim F\rightarrow \varinjlim F$.
\end{definition}

In order to introduce generalized persistence diagrams in a more general setting (Definition \ref{def:generalized PD2}), we henceforth assume the essentially finiteness of the indexing poset $\mathbf{P}$.

\begin{definition}[Generalized rank invariant]\label{def:fully generalized rank invariant} Let $\mathbf{P}$ be any connected, essentially finite poset and let $F:\mathbf{P}\rightarrow \mathcal{C}$ be any functor. We define the rank invariant of $F$ as the map $$\mathrm{rk}(F):\mathbf{Con}(\mathbf{P})\rightarrow \mathcal{I}(\mathcal{C})$$
which sends each $I\in \mathbf{Con}(\mathbf{P})$ to the rank of the sub-diagram $F|_{I}$.
\end{definition}

In what follows, for any $F:\mathbf{P}\rightarrow \mathbf{vec}$, we will regard the codomain of $\mathrm{rk}(F)$ as $\mathbf{Z}_+$ by identifying $m\in \mathbf{Z}_+$ with $[\mathbb{F}^m]\in \mathcal{I}(\mathbf{vec})$.

The rank invariant in Definition \ref{def:fully generalized rank invariant} is in general a refinement of the rank invariant that have been considered in the literature \cite{carlsson2009theory,cerri2013betti,patel2018generalized,puuska2017erosion}:
\begin{example}\label{ex:fully general rank invariant}
\begin{enumerate}[label=(\roman*)]
    \item (1-parameter persistence) Consider the integers $\mathbf{Z}$. We have $\mathbf{Con}(\mathbf{Z})=\mathbf{Int}(\mathbf{Z})$ and the generalized rank invariant of a diagram $F:\mathbf{Z}\rightarrow \mathbf{vec}$ coincides with the standard rank invariant \cite{carlsson2009theory,cohen2007stability}. This directly follows from the following observation: for any $a,b\in \mathbf{Z}$ with $a\leq b$, the rank of $F(a\leq b)$ coincides with the rank of $F|_{[a,b]}$ given in Definition \ref{def:fully general rank}. This observation is still valid even if the target category of $F$ is other than $\mathbf{vec}$, implying that the rank invariant of $\mathbf{Z}\rightarrow \mathcal{C}$ in Definition \ref{def:fully generalized rank invariant} is essentially equal to that of \cite{patel2018generalized}. \label{item:fully general rank invariant-1-parameter}
    \item (Zigzag persistence)  Consider the zigzag poset $\mathbf{ZZ}$. Note that $\mathbf{Con}(\mathbf{ZZ})=\mathbf{Int}(\mathbf{ZZ})$. The generalized rank invariant of a diagram $F:\mathbf{ZZ}\rightarrow \mathbf{vec}$ contains more information than the rank invariant defined in \cite{puuska2017erosion}. See Appendix \ref{sec:puuska}.\label{item:fully general rank invariant-zigzag}
    \item (Multiparameter persistence) Consider the $2$-dimensional grid poset $\mathbf{Z}^2$ and a functor $F:\mathbf{Z}^2\rightarrow \mathbf{vec}$. For any $(a,b),(c,d)\in \mathbf{Z}^2$ with $(a,b)\leq (c,d)$, the rank of $F((a,b)\leq(c,d))$ coincides with the rank of the restricted diagram $F|_{[(a,b),(c,d)]}$, in the sense of Definition \ref{def:fully general rank}. However, the standard rank invariant does not record the rank of $F|_{I}$ when $I$ is not in the form of $I=[(a,b),(c,d)]$. See Figure \ref{fig:refinement} for an illustrative example. This implies that the generalized rank invariant is a refinement of the standard rank invariant for 2-parameter persistence modules $\mathbf{Z}^2\rightarrow \mathbf{vec}$. Similar argument applies to diagrams $\mathbf{Z}^d\rightarrow \mathbf{vec}$ for $d> 2$.\label{item:fully general rank invariant-multiparameter}
\end{enumerate}
\end{example}

\begin{figure}
    \centering
    \includegraphics[width=0.4\textwidth]{staircase_rank.png}
    \caption{Consider $I\in\mathbf{Con}(\mathbf{Z}^2)$ consisting of 6 points in $\mathbf{Z}^2$, depicted as above. The standard rank invariant of $F:\mathbf{Z}^2\rightarrow \mathbf{vec}$ does not record the rank of $F|_I$, whereas the generalized rank invariant of $F$ does.}
    \label{fig:refinement}
\end{figure}

It is well-known that there exists a translation-invariant order $\leq $ on the Grothendieck group $\mathcal{A}(\mathcal{C})$ of $\mathcal{C}$, see \cite[Section 6.1]{patel2018generalized} and \cite{weibel2013k}. For example, both $(\mathcal{A}(\mathbf{vec}),\leq)$ and $(\mathcal{A}(\mathbf{set}),\leq)$ are isomorphic to $(\mathbf{Z},\leq)$.  In analogy with the case of standard persistent modules and zigzag modules, if we assume that the target $\mathcal{C}$ satisfies certain properties, then the generalized rank invariant is also order-reversing. To establish this result, we first introduce a proposition which is a slight extension of \cite[Lemma 3.4]{puuska2017erosion}:

\begin{proposition}\label{lem:order reversing property}Let $\mathcal{C}$ be an essentially small, symmetric monoidal with \emph{epimorphic} images (Definition \ref{def:images}). Also, assume that, for all $a,b\in \mathrm{ob}(\mathcal{C})$,
\begin{enumerate}[label=(\roman*)]
    \item $a\hookrightarrow b\Rightarrow [a]\leq [b]$ in $\mathcal{A}(\mathcal{C})$,\label{item:injection}
    \item $a\twoheadrightarrow b \Rightarrow [b]\leq [a]$ in $\mathcal{A}(\mathcal{C})$.\label{item:surjection}
\end{enumerate}
Let $f: a \rightarrow b$, $g: a' \rightarrow a$, $h: b \rightarrow b'$ be morphisms in $\mathcal{C}$ and denote $f' = h\circ f\circ g.$ Then, $\left[\mathrm{im}(f')\right] \leq \left[\mathrm{im} (f)\right]$ in $\mathcal{A}(\mathcal{C})$.
\end{proposition}

\begin{proof}By the universal properties of images (which are epimorphic), we have the following commutative diagram:
\begin{equation}\label{eq:big rank diagram}
\begin{tikzcd}
  a' \arrow[rrrrr, "f'"]\arrow[dr, "g"]\arrow[dddrrr, two heads, to path=|- (\tikztotarget)]&&&&& b'\\
  & a \arrow[rr, "f"]\arrow[d, two heads]&& b\arrow[urr, "h"]\\
  & \mathrm{im}(f) \arrow[rr, two heads, "e"']\arrow[urr, hook, swap, "m_1"] &&\mathrm{im}\left(h\circ m_1\right) \arrow[uurr, hook]\\
  &&& \mathrm{im}(f')\arrow[u, hook, "m_2"]\arrow[uuurr, hook, to path=-| (\tikztotarget)]
\end{tikzcd}
\end{equation}
In particular, by the epimorphism $e$ and the monomorphism $m_2$ (Remark \ref{rem:monic}) in the diagram, we have $\left[\mathrm{im}(f')\right]\leq \left[\mathrm{im}\left(h\circ m_1\right) \right]\leq \left[\mathrm{im} (f)\right]$, as desired.
\end{proof}

\begin{proposition}[Order-reversing property of the generalized rank invariant]\label{prop:order reversing property}
Let $\mathcal{C}$ be a category satisfying all the assumptions in Proposition \ref{lem:order reversing property}. Also, assume that $\mathcal{C}$ is a full subcategory of a bicomplete category $\mathcal{D}$ with epimorphic images such that

\begin{enumerate}[label=(\roman*)]
\item  for any monomorphism $f:a\hookrightarrow b$ in $\mathcal{D}$, if $b\in \mathrm{ob}(\mathcal{C})$, then $a\in \mathrm{ob}(\mathcal{C})$.\label{item:mono}
\item  for any epimorphism  $g:c\twoheadrightarrow d$ in $\mathcal{D}$, if $c\in \mathrm{ob}(\mathcal{C})$, then $d\in \mathrm{ob}(\mathcal{C})$.\label{item:epi}
\end{enumerate}

Let $\mathbf{P}$ be any connected, essentially finite poset and let $F:\mathbf{P}\rightarrow \mathcal{C}$ be a functor. Then, whenever $I$ and $I'$ in $\mathbf{Con}(\mathbf{P})$ are such that $I\subset I'$, it holds that $\mathrm{rk}(F)(I')\leq \mathrm{rk}(F)(I)$.
\end{proposition}

We remark that $\mathbf{vec}$, $\mathbf{set}$, and $\mathbf{ab}$ (the category of finitely generated abelian groups) all satisfy conditions in Proposition \ref{prop:order reversing property}. In particular, they are the full subcategories of the bicomplete categories $\mathbf{Vec}$, $\mathbf{Set}$, and $\mathbf{Ab}$ (the category of abelian groups), respectively. The order-reversing property of the rank invariant can sometimes be useful for the efficient computation of persistence diagrams we will define (Definition \ref{def:generalized PD2} and Example \ref{ex:Amit}).

\begin{proof}[Proof of Proposition \ref{prop:order reversing property}]Fix $I,I'\in \mathbf{Con}(\mathbf{P})$ such that $I\subset I'$. By the same argument as the proof of Proposition \ref{prop:decreasing}, we may assume that, for the canonical LC-maps $\psi_F(I),\psi_F(I')$ associated to the restricted diagrams $F|_{I},F|_{I'}$ respectively, there exist morphisms $i,p$ such that $\psi_F(I')=i\circ \psi_F(I) \circ p$.

We first show that $\mathrm{im}(\psi_F(I))$ is belongs to $\mathrm{ob}(\mathcal{C})$, not $\mathrm{ob}(\mathcal{D})\setminus \mathrm{ob}(\mathcal{C})$. Recall that $\psi_F(I)$ is a composition $\varprojlim F|_I \stackrel{p_s}{\rightarrow} F_s \stackrel{i_s}{\rightarrow} \varinjlim F|_I$ for any $s\in I$. By the universal property of $\mathrm{im}(i_s\circ p_s)(=\mathrm{im}(\psi_F(I)))$ and $\mathrm{im}(i_s)$, there exist monomorphisms $\mathrm{im}(i_s\circ p_s)\hookrightarrow \mathrm{im}(i_s)\hookrightarrow \varinjlim F|_I$. Since $F_s\in \mathrm{ob}(\mathcal{C})$, by assumption \ref{item:epi}, $\mathrm{im}(i_s)$ is an object of $\mathcal{C}$. Then, by assumption \ref{item:mono}, $\mathrm{im}(i_s\circ p_s)$ is also an object of $\mathcal{C}$. By the same argument, $\mathrm{im}(\psi_F(I'))$ is also an object of $\mathcal{C}$. Note that $i$ and $p$ are morphisms of $\mathcal{D}$, but not $\mathcal{C}$. Nevertheless, a diagram of the form in (\ref{eq:big rank diagram}) can still be utilized to induce $\mathrm{rk}(F)(I')\leq \mathrm{rk}(F)(I)$, invoking assumptions \ref{item:mono} and \ref{item:epi} in the statement of Proposition \ref{prop:order reversing property}.

\end{proof}

\paragraph{Persistence diagrams for generalized persistence modules.} In order to define persistence diagrams for generalized persistence modules, the following notation is useful.

\begin{notation}[$n$-th entourage]\label{nota:I^n} Let $\mathbf{P}$ be a connected, essentially finite poset and let $I\in \mathbf{Con}(\mathbf{P})$. Fix $n\in \mathbf{N}$. By $I^n$, we denote the set of all $J\subset \mathbf{P}$ such that $I\subset J\subset I\cup\mathrm{nbd}(I)$ and $\abs{J\cap \mathrm{nbd}(I)}=n$. In other words, each $J\in I^n$ is obtained by adding $n$ points of $\mathrm{nbd}(I)$ to $I$. We refer to $I^n$ as the \emph{$n$-th entourage} of $I$.
\end{notation}

\begin{Remark}  Let $o_I$ be the perimeter of $I$ (Definition \ref{def:perimeter}).
\begin{enumerate}[label=(\roman*)]
\item For example, $I^1 = \{I\cup\{p\}:p \in \mathrm{nbd}(I) \},$ and $\abs{I^1} = o_I$. In general, for $n\leq o_I$, one has $\abs{I^n} = \binom{o_I}{n}$, whereas for $n>o_I$, $I^n=\emptyset$.

\item  Any  $J\in I^n$ belongs to $\mathbf{Con}(\mathbf{P})$.
\end{enumerate}
\end{Remark}

Proposition \ref{prop:Mobius} is a motive for:

\begin{definition}[Generalized persistence diagram of  $\mathbf{P}\rightarrow \mathcal{C}$]\label{def:generalized PD2} Let $\mathbf{P}$ be a connected, essentially finite poset. Given an $F:\mathbf{P}\rightarrow \mathcal{C}$, let us define the persistence diagram $\mathrm{dgm}^{\mathbf{P}}(F):\mathbf{Con}(\mathbf{P})\rightarrow \mathcal{A}(\mathcal{C})$ of $F$ by sending each $I\in \mathbf{Con}(\mathbf{P})$ to
\begin{equation}\label{eq:mobius formula}
    \mathrm{dgm}^{\mathbf{P}}(F)(I):=\mathrm{rk}(F)(I)-\sum_{J\in I^1}\mathrm{rk}(F)(J)+\sum_{K\in I^2}\mathrm{rk}(F)(K)-\ldots+(-1)^{o_I}\sum_{L\in I^{o_I}}\mathrm{rk}(F)(L).
\end{equation}
\end{definition}

At the end of this section we will show that $\mathrm{dgm}^{\mathbf{P}}(F)$ is the M\"obius inversion of $\mathrm{rk}(F)$ over the poset $\mathbf{Con}^{\mathrm{op}}(\mathbf{P})$, generalizing the framework of \cite{patel2018generalized}. Now, by invoking the principle of inclusion-exclusion, we prove that the barcode of interval decomposable persistence modules (Definition \ref{def:barcode}) can be obtained via formula (\ref{eq:mobius formula}):

\begin{proposition}[The persistence diagram recovers the barcode]\label{prop:completeness} Let $\mathbf{P}$ be any connected, essentially finite poset and let  $F:\mathbf{P}\rightarrow \mathbf{vec}$ be interval decomposable.  For  $I\in \mathbf{Int}(\mathbf{P})$, the value in (\ref{eq:mobius formula}) is equal to the multiplicity of $I$ in $\mathrm{barc}^{\Pb}(F)$.
\end{proposition}

See Figure \ref{fig:inclusion-exclusion} for illustrative examples of applications of Proposition \ref{prop:completeness}. We will obtain a proof of Proposition  \ref{prop:completeness} via an elementary argument resting upon the inclusion-exclusion principle and Lemmas \ref{lem:bijection} and \ref{lem:meaning of rank} below. This proposition can also be obtained as a corollary to Propositions \ref{prop:original mobius} and \ref{prop:coincide}, based on standard results from incidence algebra.

\begin{figure}
    \centering
    \includegraphics[width=\textwidth]{inclusion_exclusion_new.pdf}
    \caption{(A) Let $\leftrightarrow$ denote $\leq$ or $\geq$. Given any $\mathbf{vec}$-diagram $M$ indexed by $\{1\leftrightarrow 2\leftrightarrow 3\leftrightarrow 4\}$, $M$ is interval decomposable. The multiplicity of the interval $[2,3]$  in the barcode of $M$ is equal to $\mathrm{rank}(M|_{[2,3]})-\mathrm{rank}(M|_{[2,4]})-\mathrm{rank}(M|_{[1,3]})+\mathrm{rank}(M|_{[1,4]})$. (B) Given any interval decomposable persistence module $N$ over the grid $\{1,2,3\}\times\{1,2,3\}$, the multiplicity of the interval  indicated by the LHS in the barcode of $N$ can be computed in a similar way.}
    \label{fig:inclusion-exclusion}
\end{figure}

\begin{Remark}\label{rem:rk is complete}
Since the barcode of an interval decomposable $F:\mathbf{P}\rightarrow \mathbf{vec}$ is a complete invariant of $F$, Proposition \ref{prop:completeness} implies that the generalized rank invariant of $F$ (Definition \ref{def:fully generalized rank invariant}) is also a complete invariant for interval decomposable persistence modules.
\end{Remark}

The following lemma is a straightforward extension of Lemma \ref{lem:bijection0} and thus we omit its proof.

\begin{lemma}\label{lem:bijection}
Let $\mathbf{P}$ be any connected poset. Let $F:\mathbf{P}\rightarrow \mathbf{vec}$ be any interval decomposable persistence module (Definition \ref{def:interval decomposable}). Let $J\in \mathbf{Con}(\mathbf{P})$. Then, there exists a bijection between intervals $J$ in $\mathrm{barc}^{J}(F|_J)$ and intervals $K\supset J$ in $\mathrm{barc}^{\Pb}(F)$
\end{lemma}

Note that given any connected poset $\mathbf{P}$, $\mathbf{P}$ itself is an interval of $\mathbf{P}$ (Definition \ref{def:intervals}). The following lemma is a straightforward extension of Proposition \ref{prop:the meaning of rank ZZ}, and thus we omit its proof.

\begin{lemma}[The meaning of rank]\label{lem:meaning of rank} Let $\mathbf{P}$ be any connected poset. Let $F:\mathbf{P}\rightarrow \mathbf{vec}$ be any interval decomposable persistence module (Definition \ref{def:interval decomposable}). The rank of the canonical LC map $\phi:\varprojlim F \rightarrow \varinjlim F$ is equal to the multiplicity of $\mathbf{P}$ in $\mathrm{barc}^{\Pb}(F)$.
\end{lemma}

\begin{Remark}\label{rem:implication}Lemmas \ref{lem:bijection} and  \ref{lem:meaning of rank} imply the following: For any interval decomposable $F:\mathbf{P}\rightarrow \mathbf{vec}$ and $J\in \mathbf{Con}(\mathbf{P})$, $\mathrm{rk}(F)(J)$ is equal to the total multiplicity of intervals $K\in\mathrm{barc}^{\Pb}(F)$ such that $K\supset J$. Note that this is a generalization of Proposition \ref{prop:bridge}.
\end{Remark}

\begin{proof}[Proof of Proposition \ref{prop:completeness}] Let $\mathrm{barc}^{\Pb}(F)=\left\{\!\!\left\{ J_c: F\cong \bigoplus_{c\in C} I^{J_c}\right\}\!\!\right\}$ for some indexing set $C$. Let $a_0(I)$ be the cardinality of the set $\{c\in C: I\subset J_c\}$. Also, let $a_1(I)$ be the cardinality of the set $\{c\in C: I\subsetneq J_c\}.$ Since the difference $a_0(I)-a_1(I)$ is the multiplicity of $I$ in $\mathrm{barc}^{\Pb}(F)$, it suffices to show that $a_0(I)-a_1(I)$ is identical to the value given by formula (\ref{eq:mobius formula}). First, by Remark \ref{rem:implication},
$a_0(I)=\mathrm{rk}(F)(I)$.

Next we compute $a_1(I)$. For any $K\in \mathbf{Con}(\mathbf{P})$, let
$B_F(K):=\left\{ c\in C: K\subset J_c \right\}.$

Let $K\in \mathbf{Con}(\mathbf{P})$ be such that $I\subsetneq K$. We claim that $K$ must include at least one point of $\mathrm{nbd}(I)$ by the following reasoning: Pick any $k\in K\setminus I$ and any $p\in I$. Since the induced subgraph of $\mathrm{Hasse}(\mathbf{P})$ on $K$ is connected, there exist $p=q_0,q_1,\ldots,q_m=k$ in $K$ such that $q_i$ and $q_{i+1}$ are adjacent (i.e. $q_i\asymp q_{i+1}$) in the subgraph for all $i$. Since $p=q_0\in I$ and $q_m=k\in K\setminus I$, there must be $i\in\{1,\ldots,m\}$ such that $q_i$ belongs to $\mathrm{nbd}(I)$. This observation leads to the equality \[\{c\in C: I\subsetneq J_c\}=\bigcup_{K\in I^1} B_F(K)\ \mbox{(see Notation \ref{nota:I^n})},\] and hence $a_1(I)=\abs{\bigcup_{K\in I^1} B_F(K)}$.
By the principle of inclusion-exclusion and invoking Remark \ref{rem:implication}, we have: %
\begin{align*}
    a_1(I)&=\sum_{J\in I^1}\abs{B_F(J)}-\sum_{K\in I^2}\abs{B_F(K)}+\ldots+(-1)^{o_I-1}\sum_{L\in I^{o_I}}\abs{B_F(L)}
    \\&=\sum_{J\in I^1}\mathrm{rk}(F)(J)-\sum_{K\in I^2}\mathrm{rk}(F)(K)+\ldots+(-1)^{o_I-1}\sum_{L\in I^{o_I}}\mathrm{rk}(F)(L),
\end{align*}
completing the proof.
\end{proof}

\paragraph{M\"obius function and another interpretation of Definition \ref{def:generalized PD2}.} Let $\mathbf{Q}$ be a locally finite poset. The M\"obius function $\mu_{\mathbf{Q}}:\mathbf{Q}\times\mathbf{Q}\rightarrow \mathbf{Z}$ of $\mathbf{Q}$ is defined\footnote{More precisely, the codomain of $\mu_{\mathbf{Q}}$ is the multiple of $1$ in a specified base ring rather than $\mathbf{Z}$.} recursively \cite{rota1964foundations} as

\begin{equation}\label{eq:induction}
    \mu_{\mathbf{Q}}(p,q)=\begin{cases}1,& \mbox{$p=q$,}\\ -\sum_{p\leq r< q}\mu_{\mathbf{Q}}(p,r),& \mbox{$p<q$,} \\ 0,& \mbox{otherwise.} \end{cases}
\end{equation}

\begin{proposition}[M\"obius inversion formula {\cite[Proposition 2 (p.344)]{rota1964foundations}}]\label{prop:original mobius} Let $\mathbf{Q}$ be a locally finite poset and let $k$ be a field. Suppose that an element $0\in \mathbf{Q}$ exists with the property that $0\leq q$ for all $q\in \mathbf{Q}$. Consider a pair of functions $f,g:\mathbf{Q}\rightarrow k$ with the property that
\[g(q)=\sum_{r\leq q} f(r).\]
Then, $\displaystyle f(q)=\sum_{r\leq q} g(r)\cdot \mu_{\mathbf{Q}}(r,q)$ for $q\in \mathbf{Q}$.
\end{proposition}

Formula (\ref{eq:mobius formula}) is in fact the M\"obius inversion of the rank invariant $\mathrm{rk}(F)$ over the poset $\mathbf{Con}^{\mathrm{op}}(\mathbf{P})$, generalizing the framework of \cite{patel2018generalized}:

\begin{proposition}\label{prop:coincide}  Let $\mathbf{P}$ be a connected, essentially finite poset and let $F:\mathbf{P}\rightarrow \mathcal{C}$. Let $\mu:\mathbf{Con}^{\mathrm{op}}(\mathbf{P})\times \mathbf{Con}^{\mathrm{op}}(\mathbf{P})\rightarrow \mathbf{Z}$ be the M\"obius function of the poset $\mathbf{Con}(\mathbf{P})^{\mathrm{op}}$. Then, for $I\in \mathbf{Con}^{\mathrm{op}}(\mathbf{P})$
\[\mathrm{dgm}^{\mathbf{P}}(F)(I)= \sum_{J\supset I}\mathrm{rk}(F)(J)\cdot\mu(J,I).\]
\end{proposition}
We prove Proposition \ref{prop:coincide} at the end of this section.

\begin{Remark}\label{rem:implication2} Let $\mathbf{P}$ be a connected, essentially finite poset and let $F:\mathbf{P}\rightarrow \mathbf{vec}$ be interval decomposable. Note that $\mathbf{P}\in \mathbf{Con}^{\mathrm{op}}(\mathbf{P})$ satisfies the property that $\mathbf{P}\supset \mathbf{Q}$ for all $\mathbf{Q}\in \mathbf{Con}^{\mathrm{op}}(\mathbf{P})$. Therefore, Proposition \ref{prop:original mobius} together with Remark \ref{rem:implication} and Proposition  \ref{prop:coincide} imply that if $I\in \mathbf{Con}(\mathbf{P})\setminus \mathbf{Int}(\mathbf{P})$, then  $\mathrm{dgm}^{\mathbf{P}}(F)(I)=0$.

This in turn implies the following: Given any $G:\mathbf{P}\rightarrow \mathbf{vec}$, (1) if there exists $I\in \mathbf{Con}(\mathbf{P})\setminus \mathbf{Int}(\mathbf{P})$ such that $\mathrm{dgm}^{\mathbf{P}}(G)(I)\neq 0$, then $G$ is \emph{not} interval decomposable. (2) If there exists $I\in \mathbf{Int}(\mathbf{P})$ such that $\mathrm{dgm}^{\mathbf{P}}(G)(I)<0$, then $G$ is \emph{not} interval decomposable: See Example \ref{ex:Amit}. (3) The converse of the previous statement is not true: See Example \ref{ex:Alex}.
\end{Remark}

\begin{example}\label{ex:Amit} Consider the poset $\mathbf{P}=\{a,b,c,d\}$ equipped with the relation $\leq:=\{(a,b),(c,b),(d,b)\}\subset \mathbf{P}\times \mathbf{P}$. Then, $\mathrm{Hasse}(\mathbf{P})$ is shown as in (A) below. Consider $F:\mathbf{P}\rightarrow \mathbf{vec}$ given as in (B) below,
\begin{center}
\begin{tikzcd}
  & a \arrow[d, dash] \\
    & b  \\
  c \arrow[ru, dash] && d \arrow[lu, dash]\\
  & \mbox{(A)}
 \end{tikzcd}
 \hspace{15mm}
 \begin{tikzcd}
  & k \arrow[d, hook, "i_1"] \\
    & k^2  \\
  k \arrow[ru, hook, "i_2"] && k \arrow[lu, hook, "i_1+i_2"]\\
  & \mbox{(B)}
 \end{tikzcd}
\end{center}
where $i_1,i_2:k\rightarrow k^2$ are the canonical inclusions into the first factor and the second factor of $k^2$, respectively. We show that $F$ is \emph{not} interval decomposable.

By Remark \ref{rem:implication2}, it suffices to show that, for $I:=\{b\}$, one has $\mathrm{dgm}^\mathbf{P}(F)(I)<0$. Observe that $I^1=\{\{a,b\},\{b,c\},\{b,d\}\}$, $I^2=\{\{a,b,c\},\{a,b,d\},\{b,c,d\}\}$, and $I^3=\{\{a,b,c,d\}\}=\{\mathbf{P}\}$, $I^n=\{\emptyset\}$ for $n>3$. Note that:

\begin{itemize}
    \item $\mathrm{rk}(F)(I)=2$, which is the dimension of $F(b)=k^2$ (cf. Example \ref{ex:trivial cases} \ref{item:trivial cases1}).
    \item $\mathrm{rk}(F)(J)=1$ for every $J\in I^1$ (cf. Example \ref{ex:trivial cases} \ref{item:trivial cases2}).
    \item $\mathrm{rk}(F)(J)=0$ for every $J\in I^2$: the sub-diagram $F|_J$ amounts to a zigzag module of length 3 \cite{carlsson2009zigzag}. It is not difficult to check that the barcode of $F|_J$ does not include the full interval $J$. This implies, by Lemma \ref{lem:meaning of rank}, $\mathrm{rk}(F)(J)=\mathrm{rk}(F|_J)(J)=0$.
    \item $\mathrm{rk}(F)(\mathbf{P})=0$: Fix $J\in I^2$. By Proposition \ref{prop:order reversing property}, $0\leq \mathrm{rk}(F)(\mathbf{P})\leq \mathrm{rk}(F)(J)=0$, and hence $\mathrm{rk}(F)(\mathbf{P})=0$.
\end{itemize}
Therefore, formula (\ref{eq:mobius formula}) gives that $\mathrm{dgm}^{\mathbf{P}}(F)(I)=2-(1+1+1)+(0+0+0)-0=-1$, completing the proof.
\end{example}

The non-negativity of the persistence diagram of a $G:\mathbf{P}\rightarrow \mathbf{vec}$ does not imply the interval-decomposability of $G$:

\begin{example}\label{ex:Alex} Let $\mathbf{P}$ and $F:\mathbf{P}\rightarrow \mathbf{vec}$ respectively be the same as Example \ref{ex:Amit}. Let $G$ be the direct sum of $F$ and the interval module $\mathcal{J}^{\{b\}}:\mathbf{P}\rightarrow \mathbf{vec}$ supported by $\{b\}$. Note that $\mathrm{rk}(G)=\mathrm{rk}(F)+\mathrm{rk}(\mathcal{J}^{\{b\}})$ and
\[\mathrm{dgm}^{\mathbf{P}}(G)(I)=\begin{cases}0,& I=\{b\} \\ \mathrm{dgm}^{\mathbf{P}}(F)(I),&\mbox{otherwise.}
\end{cases}
\]
In particular, observe that $\mathrm{dgm}^{\mathbf{P}}(G)$ is non-negative even though $G$ is not interval decomposable. Also, note that, for $H=I^{\{a,b\}}\bigoplus I^{\{b,c\}}\bigoplus I^{\{b,d\}}$, we have $\mathrm{rk}(G)=\mathrm{rk}(H)$ and in turn $\mathrm{dgm}^{\mathbf{P}}(G)=\mathrm{dgm}^{\mathbf{P}}(H)$. This shows that the generalized rank invariant and persistence diagram are \emph{not} complete invariants beyond the class of interval decomposable persistence modules. The following is also noteworthy: for the intervals $I=\{a,b\},\ \{b,c\},\ \{b,d\}$,   $G$ does not admit $\mathcal{J}^I$ as a summand even though $\mathrm{dgm}^{\mathbf{P}}(G)(I)=1$.
\end{example}

In order to prove Proposition \ref{prop:coincide}, we will exploit the poset structure of $\mathbf{Con}^{\mathrm{op}}(\mathbf{P})$. To this end, we briefly review the notion of \emph{lattice}. See  \cite{birkhoff1940lattice} for a comprehensive treatment on this subject.

Let $\mathbf{L}$ be a poset, and let $S \subset \mathbf{L}$. An element $u \in \mathbf{L}$ is said to be an upper bound of $S$ if $s \leq u$ for all $s \in S.$ An upper bound $u$ of $S$ is said to be its least upper bound, or \emph{join} if $u \leq x$ for each upper bound $x$ of $S$. If a join of $S$ exists, then it is unique. The concepts of lower bound and greatest lower bound are defined in a dual way. In particular, a greatest lower bound is said to be a \emph{meet}.

\begin{definition}[Lattices]\label{def:lattice}Let $\mathbf{L}$ be a poset. $\mathbf{L}$ is said to be a \emph{join-semi lattice} if for every pair $a,b\in \mathbf{L}$, the set $\{a,b\}$ has a join in $\mathbf{L}$. Dually, $\mathbf{L}$ is said to be a \emph{meet-semi lattice} if for every pair $a,b\in \mathbf{L}$, the set $\{a,b\}$ has a meet in $\mathbf{L}$. If $\mathbf{L}$ is both join-semi lattice and meet-semi lattice, then $\mathbf{L}$ is said to be a \emph{lattice}.
\end{definition}

Let $\mathbf{P}$ be a connected,  essentially finite poset. Even though $\mathbf{Con}^{\mathrm{op}}(\mathbf{P})$ is in general not a lattice, it is locally a lattice:

\begin{lemma}[$\mathbf{Con}^{\mathrm{op}}(\mathbf{P})$ is locally a lattice]\label{lem:lattice} Let $\mathbf{P}$ be a connected, essentially finite poset. Let $I,J\in \mathbf{Con}^{\mathrm{op}}({\mathbf{P}})$ with $J\supset I$. Then $[J,I]:=\{K\in \mathbf{Con}^{\mathrm{op}}(\mathbf{P}): J\supset K \supset I\}$ is a finite lattice.
\end{lemma}

\begin{proof}By Remark \ref{rem:con(p)}, $\mathbf{Con}(\mathbf{P})$ is locally finite and thus $[J,I]$ is finite. Fix any $K_1,K_2 \in [J,I]$. Observe that $K_1\cup K_2$ is the greatest lower bound for $\{K_1,K_2\}$ in the subposet $[J,I]$ of $\mathbf{Con}^{\mathrm{op}}(\mathbf{P})$. Also, observe that the least upper bound for $\{K_1,K_2\}$ is the union of all subposets in the subcollection
$\{L\in \mathbf{Con}^{\mathrm{op}}(\mathbf{P}):  K_1\cap K_2 \supset L \supset I \}$ of $[J,I]$ (note that this subcollection contains $I$ and hence not empty).
This shows that $[J,I]$ is a lattice.
\end{proof}

An \emph{atom} in a poset is an element that covers a minimal element. A \emph{dual atom} is an element that is covered by a maximal element \cite{rota1964foundations}.

\begin{proposition}[{\cite[Corollary (P. Hall), p.349]{rota1964foundations}}]\label{prop:Hall}Let $\mathbf{L}$ be a finite lattice with $0,1\in \mathbf{L}$ such that $0\leq l \leq 1$ for all $l\in \mathbf{L}$. If $0$ is not the meet of dual atoms of $\mathbf{L}$, or if $1$ is not the join of atoms, then $\mu_{\mathbf{L}}(0,1)=0$.
\end{proposition}

Let $\mathbf{P}$ be a connected, essentially finite poset and let $I,J\in \mathbf{Con}^{\mathrm{op}}(\mathbf{P})$  with $J\supset I$. Observe that, in the finite lattice $\mathbf{L}=[J,I]$ which is a subposet of $\mathbf{Con}^{\mathrm{op}}(\mathbf{P})$, all dual atoms belong to the first entourage $I^1$ of $I$ (Notation \ref{nota:I^n}).

\begin{proof}[Proof of Proposition \ref{prop:coincide}]
Invoking formula (\ref{eq:induction}), by elementary induction, it follows that for any $n\in\{1,\ldots,o_I\}$ and  for any $J\in \mathbf{Con}^{\mathrm{op}}(\mathbf{P})$ with $J\in I^n$, $\mu(J,I)=(-1)^n$.

Now pick any $J\in \mathbf{Con}^{\mathrm{op}}(\mathbf{P})$ such that $J\supset I$ and $J\notin \bigcup_{n=1}^{o_I}I^n$. This implies that $J$ is not the union of elements in $I^1$ and in turn implies that $J$ is not the meet of dual atoms of $[J,I].$ By \cite[Proposition 4  (p.345)]{rota1964foundations}, the restriction of the M\"obius function of $\mathbf{Con}^{\mathrm{op}}(\mathbf{P})$ to $[J,I]\times [J,I]$ is equal to the M\"obius function of the subposet $[J,I]$. Lemma \ref{lem:lattice} and Proposition \ref{prop:Hall} now directly imply that $\mu(J,I)=0$.
\end{proof}

\section{Computing the 0-th level set barcode of a Reeb graph within $\mathbf{set}$-category}\label{sec:reeb graph}

In this section we propose a novel method to compute the $0$-th level set barcode of a Reeb graph within the category of sets (Section \ref{sec:reeb graph barcode}). This will be possible via a geometric interpretation of $\mathbf{ZZ}$-indexed $\mathbf{set}$-diagrams (Section \ref{sec:local analysis of reeb graphs}). An improvement of a semicontinuity theorem by Patel will also follow thereby (Section \ref{sec:set-stability}).  %

\subsection{Local analysis of Reeb graphs}\label{sec:local analysis of reeb graphs}

\paragraph{Reeb graphs.} Let $f:M\rightarrow \mathbf{R}$ be a Morse(-type) function (Definition \ref{def:morse type}) on a manifold. The Reeb graph of $f$ is a descriptor for the evolution of connected components of the level sets $f^{-1}(r)$ as $r\in \mathbf{R}$ varies \cite{reeb1946points}. There have been not only numerous applications of Reeb graphs in shape analysis and visualization \cite{shinagawa1991surface,BGSF08} or in dynamic/high-dimensional data analysis \cite{buchin2013trajectory,ge2011data,kim2017stable,kim2018CCCG}, but also a vast body of theoretical study on Reeb graphs \cite{de2016categorified,stefanou2019reeb}, approximation/computation of Reeb graphs \cite{dey2013reeb,Salman12,harvey2010randomized}, metrics on Reeb graphs \cite{bauer2014measuring,bauer2015strong,bauer2018reeb,carriere2017local}, and generalizations \cite{mapper,dey2016multiscale}.

By a Reeb graph, we will refer to  a ``constructible" topological graph $X$ equipped with a notion of ``height" represented by a continuous function $f:X\rightarrow \mathbf{R}$. While we defer the rigorous definition of Reeb graphs to Appendix (Definitions \ref{def:morse type} and \ref{def:Reeb graph}), it is well-known that any diagram $M:\mathbf{ZZ}\rightarrow \mathbf{set}$ amounts to a Reeb graph and vice versa as we will see below in more detail \cite{curry2016classification,de2016categorified}.

\begin{definition}[Reeb-graph-realization of a zigzag diagram in $\mathbf{set}$]\label{def:realization} Let $M:\mathbf{ZZ}\rightarrow \mathbf{set}$. We define the \emph{Reeb graph corresponding to $M$} as the pair $(\mathbf{Reeb}(M),\pi)$ consisting of a topological graph $\mathbf{Reeb}(M)$ and a map $\pi:\mathbf{Reeb}(M)\rightarrow \mathbf{R}$, described subsequently (referring to Example \ref{ex:Reeb}  may help the understanding of the description below).

\begin{enumerate}
    \item For   $(i,i)\in \mathbf{ZZ}$, let each element in $M_{(i,i)}$ become a vertex which lies over $i\in \mathbf{Z} (\subset \mathbf{R})$.
    \item For $(i,i-1) \in \mathbf{ZZ}$, let each element in $M_{(i,i-1)}$ become an edge which lies over the interval $[i-1,i]\subset \mathbf{R}$.
    \item For each comparable pair $(i,i-1)\leq (i,i)$ (resp.  $(i,i-1)\leq (i-1,i-1)$) in $\mathbf{ZZ}$, the attaching map between the vertex set and the edge set is specified by $M((i,i-1)\leq (i,i))$ (resp. $M((i,i-1)\leq (i-1,i-1))$).
 \end{enumerate}
 The space $\mathbf{Reeb}(M)$ is the quotient of the disjoint union of the spaces $M_{(i,i)}\times \{i\}$  and $ M_{(i,i-1)}\times [i-1, i]$ for all $i\in \mathbf{Z}$ with respect to the identifications $(M((i,i-1)\leq (i,i))(e),i)\sim (e,i)$ and  $(M((i,i-1)\leq (i-1,i-1))(e),i-1)\sim (e,i-1)$. The map $\pi:\mathbf{Reeb}(M)\rightarrow \mathbf{R}$ is defined as the projection onto the second factor.

For any interval $I$ of $\mathbf{ZZ}$, one can define the Reeb graph corresponding to a diagram $I\rightarrow \mathbf{set}$ in the same way.
\end{definition}

\begin{example}\label{ex:Reeb}%
Consider $M:\mathbf{ZZ}\rightarrow \mathbf{set}$ specified as follows:
\begin{equation*}
    M_{(1,1)}=\{v_1,v_2\},\hspace{3mm}M_{(2,1)}=\{e_1,e_2\},\hspace{3mm} M_{(2,2)}=\{v_3,v_4\},\hspace{3mm}M_{(3,2)}=\{e_3,e_4\},\hspace{3mm} M_{(3,3)}=\{v_5,v_6\},
\end{equation*}
and other $M_{(i,j)}$ are the empty set. The four maps \[\begin{tikzcd}M_{(1,1)}\arrow[<-]{rr}{\varphi_M ((2,1),(1,1))}&& M_{(2,1)}\arrow[->]{rr}{\varphi_M ((2,1),(2,2))}&&M_{(2,2)}\arrow[<-]{rr}{\varphi_M ((3,2),(2,2))}&& M_{(3,2)}\arrow[->]{rr}{\varphi_M ((3,2),(3,3))}&&M_{(3,3)}\end{tikzcd}\]
are defined as follows:
\[\begin{tikzcd}v_1&&\arrow[mapsto]{ll}{} e_1\arrow[->,mapsto]{rr}{}&&v_3&&\arrow[mapsto]{ll}{} e_3\arrow[mapsto]{rr}{}&&v_5 \\
v_2&&\arrow[mapsto]{ll}{}e_2\arrow[->,mapsto]{rr}{}&&v_4&&\arrow[mapsto]{llu}{} e_4\arrow[mapsto]{rr}{}&&v_6.
\end{tikzcd}\]
The Reeb graph corresponding to $M$ is depicted in Figure \ref{fig:Reeb}.
\end{example}

\begin{figure}
    \centering
    \includegraphics[width=0.5\textwidth]{Reeb2.pdf}
    %
    \caption{The Reeb graph $(\mathbf{Reeb}(M),\pi)$ corresponding to $M$ in Example \ref{ex:Reeb}, where $\pi:\mathbf{Reeb}(M)\rightarrow \mathbf{R}$ is the projection map to the horizontal real axis.}
    \label{fig:Reeb}
\end{figure}

Definition \ref{def:realization} describes how to turn a functor $M:\mathbf{ZZ}\rightarrow \mathbf{set}$ into a Reeb graph. In this respect, we will refer to any $M:\mathbf{ZZ}\rightarrow \mathbf{set}$ as a \emph{Reeb graph}.  On the other hand, any Reeb graph can be expressed as a $\mathbf{set}$-valued  zigzag diagram over $\mathbf{R}$ \cite{curry2016classification}. This zigzag diagram over $\mathbf{R}$ is in turn equivalent to a $\mathbf{ZZ}$-index $\mathbf{set}$-diagram up to rescaling--- this idea  has already implicitly appeared in \cite{botnan2018algebraic,curry2013sheaves}. This means that the entire combinatorial information of a Reeb graph $X$ can be encoded into a certain $M:\mathbf{ZZ}\rightarrow \mathbf{set}$. In particular, the $0$-th level set barcode of $X$ \cite{carlsson2009zigzag} can be extracted from $M$ up to rescaling of intervals.

\paragraph{Local analysis of Reeb graphs.} We illustrate how to extract topological/combinatorial information from limits and colimits of interval restrictions of a Reeb graph $M:\mathbf{ZZ}\rightarrow \mathbf{set}$.  For $k,l\in \mathbf{ZZ}$, assume that $x\in M_{k}$ and $y\in M_{l}$. We write $x\sim y$ if $k$ and $l$ are comparable and one of $x$ and $y$ is mapped to the other via the internal map between $M_k$ and $M_l$.

 We can explicitly represent the limit and colimit of $M$ as follows.
\begin{enumerate}[label=(\roman*)]
    \item The limit of $M$ is the pair $\left(L,(\pi_k)_{k\in\mathbf{ZZ}}\right)$, where
    \[L:=\left\{(x_k)_{k\in \mathbf{ZZ}}\in \prod_{k\in\mathbf{ZZ}} M_k: \ \mbox{for comparable $k,l\in\mathbf{ZZ}$,}\  x_{k}\sim x_{l} \right\},\]and each $\pi_k:L\rightarrow M_k$ is the canonical projection. \label{item:set-limit construction}
    \item The colimit of $M$ is the pair $\left(C,(i_k)_{k\in\mathbf{ZZ}}\right)$ described as follows:
    \begin{equation}\label{eq:set colimit construction}
        C:=\left(\coprod_{k\in\mathbf{ZZ}}M_k\right)\big/\approx,
    \end{equation}
    where $\approx$ is the equivalence relation generated by the relations $x_k\sim x_{l}$ for $x_k\in M_k$ and $x_{l}\in M_{l}$ with $k,l$ being comparable. For the quotient map $q:\coprod_{k\in\mathbf{ZZ}}M_k\rightarrow C$, each $i_k$ is the composition $M_k\hookrightarrow \coprod_{k\in\mathbf{ZZ}}M_k \stackrel{q}{\rightarrow} C$. \label{item:set-colimit construction}
\end{enumerate}

Let $I\in \mathbf{Int}(\mathbf{ZZ})$. For any diagram $N:I\rightarrow \mathbf{set}$, we can construct the limit and colimit of $N$ in the same way; namely, in items \ref{item:set-limit construction} and \ref{item:set-colimit construction} above, replace $M$ and $\mathbf{ZZ}$ by $N$ and $I$, respectively. In what follows, we use those explicit constructions  whenever considering limits and colimits of (interval restrictions of) $\mathbf{ZZ}$-indexed $\mathbf{set}$-diagrams.

\begin{definition}[Supports and full components]\label{def:full component} Let $I\in \mathbf{Int}(\mathbf{ZZ})$ and let $N:I\rightarrow \mathbf{set}$. Let $c\in \varinjlim N$. We define the support $\mathrm{supp}(c)$ of $c$ as
\[\mathrm{supp}(c):=\{k\in I:  \exists x_k\in N_k, \ i_k(x_k)=c\}.\]
In particular, if $\mathrm{supp}(c)=I$, we call $c$ a \emph{full component} of $N$.
\end{definition}

Now, extending ideas in \cite{de2016categorified}, we geometrically interpret elements of limits, colimits and images of the canonical LC maps of (interval restrictions of) $\mathbf{ZZ}$-indexed $\mathbf{set}$-diagrams.

Recall that, for $b,d\in \mathbf{Z}\ \mbox{with $b< d$}$, $\langle b,d \rangle_{\mathbf{ZZ}}$ stands for an interval of $\mathbf{ZZ}$ (Notation \ref{nota:intervals of zz}). Similarly, for $b,d\in\mathbf{R}$ with $b< d$, $\langle b,d \rangle$ will stand for one of the intervals $(b,d),[b,d],(b,d],[b,d)$. The terminology introduced in Definition \ref{def:full components} below will be illustrated in Example \ref{ex:Reeb2}.

\begin{definition}[Local analysis of a Reeb graph]\label{def:full components}
Consider any $M:\mathbf{ZZ}\rightarrow \mathbf{set}$ and fix $I:=\langle b,d \rangle_{\mathbf{ZZ}} \in \mathbf{Int}(\mathbf{ZZ})$. %
\begin{enumerate}[label=(\roman*)]
    \item Each element in  $\varinjlim M|_{I}$ is said to be a $\langle b,d \rangle$-component.
    \item Each element in  $\varprojlim M|_{I}$ is said to be a $\langle b,d \rangle$-section.\footnote{Recall that a right-inverse of a morphism is called a section \cite{mac2013categories}.}\label{item:full components2}
    \item If $c\in \varinjlim M|_{I}$ and $\mathrm{supp}(c)=I$, then $c$ is said to be a $\langle b,d \rangle$-\emph{full}-component.
    \item Each element in the image of the canonical LC map $\psi_{M|_{I}}:\varprojlim M|_{I}\rightarrow \varinjlim M|_{I}$ is said to be a $\langle b,d \rangle$-full-component of $M$ \emph{with a section}.  \label{item:full components4}
\end{enumerate}

\end{definition}

\begin{example}[Geometric interpretation of Definition \ref{def:full components}]\label{ex:Reeb2} We consider examples of all the items in Definition \ref{def:full components} in a geometric viewpoint. For $M:\mathbf{ZZ}\rightarrow \mathbf{set}$ in Example \ref{ex:Reeb} (Figure \ref{fig:Reeb}), note the following:
\begin{enumerate}[label=(\roman*)]
    \item There are the two $[1,3]$-components: The connected component containing the vertex $v_1$ and the one containing $v_2$. Also, there are the two $[1,2]$-components: these components correspond to the restrictions of the previous two components to $\pi^{-1}([1,2])$. \label{item:I-component}
    \item The 5-tuples $(v_1,e_1,v_3,e_3,v_5)$ and $(v_1,e_1,v_3,e_4,v_6)$ are $[1,3]$-sections. These tuples deserve to be called by such a name since there indeed exist continuous maps $s_1:[1,3]\rightarrow \mathbf{Reeb}(M)$ and $s_2:[1,3]\rightarrow \mathbf{Reeb}(M)$ satisfying (1) $\pi\circ s_1=\pi\circ s_2=\mathrm{id}_{[1,3]}$, and (2) $\mathrm{im}(s_1),\mathrm{im}(s_2)$ lie on $v_1e_1v_3e_3v_5$ and $v_1e_1v_3e_4v_6$ respectively in $\mathbf{Reeb}(M)$.\label{item:Reeb2 2}
    \item There exists only one $[1,3]$-full-component; among the two $[1,3]$-components considered in item \ref{item:I-component}, the one containing $v_1$ is the unique $[1,3]$-full-component.\label{item:Reeb2 3}
    \item Via the canonical LC map, each $[1,3]$-section is mapped to the unique $[1,3]$-full-component, which contains the image of the $[1,3]$-section.  This demonstrates why the connected component containing $v_1$ is called a $[1,3]$-full-component of $M$ \emph{with a section (cf. Example \ref{ex:non-isomorphic}).} \label{item:Reeb2 4}
    \end{enumerate}
\end{example}

\subsection{Computing the 0-th level set barcode of a Reeb graph without homology}\label{sec:reeb graph barcode}

In this section we propose a novel method to compute the $0$-th level set barcode of a Reeb graph within the category of sets.

\paragraph{The $0$-th level set barcode of a Reeb graph.} The $0$-th level set barcode of a Reeb graph (Definition \ref{def:0-th levelset barcode}) captures the lifetime of all homological features in the Reeb graph \cite{bauer2014measuring}.
Whereas measuring the interleaving distance (or equivalently functional distortion distance) between Reeb graphs is not easy \cite[Section 5]{de2016categorified}, \cite{bauer2015strong}, the computation of the bottleneck distance between the $0$-th level set barcodes of Reeb graphs can be efficiently carried out \cite{kerber2017geometry}. Moreover, the bottleneck distance between the $0$-th level set barcodes of Reeb graphs is a tight lower bound for the interleaving distance between Reeb graphs up to multiplicative constant 2 \cite{bauer2014measuring,botnan2018algebraic}.

\begin{definition}[The linearization functor]\label{def:free} Let $L_{\F}:\mathbf{Set}\rightarrow \mathbf{Vec}$ be the \emph{linearization functor}:  For any set $S$, $L_{\F}(S)$ consists of formal linear combination $\sum_{i}a_is_i$, ($a_i\in \mathbb{F}, s_i\in S$) of finite terms of elements in
$S$ over the field $\mathbb{F}$. Also, given a set map $f:S\rightarrow T$ , $L_{\F}(f)$ is the linear map from $L_{\F}(S)$ to $L_{\F}(T)$ obtained by linearly extending $f$.
\end{definition}

Throughout this section, we identify both of the Grothendieck groups $\mathcal{A}(\mathbf{vec})$ and $\mathcal{A}(\mathbf{set})$ with the integer group $(\mathbf{Z},+)$ (Remark \ref{rem:counterpart}). Let us recall the $0$-th level set barcode of a Reeb graph \cite{carlsson2009zigzag,botnan2018algebraic}:
\begin{definition}[The 0-th level set barcode of a Reeb graph]\label{def:0-th levelset barcode} Given $M:\mathbf{ZZ}\rightarrow \mathbf{set}$, consider $L_{\F}\circ M:\mathbf{ZZ}\rightarrow \mathbf{vec}$. The $0$-th level set barcode of $M$ refers to $\mathrm{barc}^{\ZZ}(L_{\F}\circ M)$.
\end{definition}

\paragraph{New method for computing the 0-th level set barcode of a Reeb graph.} In order to establish a method to compute the 0-th level set barcode of a Reeb graph \emph{without matrix operations} \cite{carlsson2009zigzag,milosavljevic2011zigzag}, we introduce a new invariant for Reeb graphs.

Given $M:\mathbf{ZZ}\rightarrow \mathbf{set}$ and $I\in \mathbf{Int}(\mathbf{ZZ})$, we denote the number of full components of $M|_I$ by $\mathrm{full}(M|_I)$ (Definition \ref{def:full component}).

\begin{definition}[Full function of a Reeb graph] \label{def:full function}
Given $M:\mathbf{ZZ}\rightarrow \mathbf{set}$, the \emph{full function} $\mathrm{Full}(M):\mathbf{Int}(\mathbf{ZZ})\rightarrow \mathbf{Z}_{\geq 0}$ is defined as $I\mapsto \mathrm{full}\left(M|_{I}\right).$
\end{definition}

One can observe that $\mathrm{Full}(M)(\langle b,d \rangle_{\mathbf{ZZ}})$ is equal to the number of connected components of $\pi^{-1}\langle b,d \rangle (\subset \mathbf{Reeb}(M))$ \emph{whose images via $\pi$ are $\langle b,d \rangle$}. For instance, consider  $M:\mathbf{ZZ}\rightarrow \mathbf{set}$ whose corresponding Reeb graph is depicted as in Figure \ref{fig:Curry} (A). $\mathrm{Full}(M)([2,3)_{\mathbf{ZZ}})$ is $2$, and both of the two connected components of $\pi^{-1}[2,3)$ cover $[2,3)$ via $\pi$. On the other hand, $\mathrm{Full}(M)((1,3)_{\mathbf{ZZ}})$ is $1$ and only one of the connected components of $\pi^{-1}(1,3)$ covers the entire $(1,3)$ via $\pi$.

The following proposition is the core observation for establishing a new method to compute the $0$-th level set barcodes of Reeb graphs.

\begin{proposition}\label{thm:full is rank}For any $M:\mathbf{ZZ}\rightarrow \mathbf{set}$,  \[\mathrm{Full} (M)=\mathrm{rk}_\mathbf{vec}(L_{\F}\circ M).\]
\end{proposition}

We prove Proposition \ref{thm:full is rank} at the end of this section. By Theorem \ref{thm:interval decomposition0}, Propositions \ref{prop:Mobius}, \ref{prop:completeness}, and \ref{thm:full is rank}, we directly have:

\begin{corollary}\label{cor:new formula for 0th}For any $M:\mathbf{ZZ}\rightarrow \mathbf{set}$ and $I\in \mathbf{Int}(\mathbf{ZZ})$, the multiplicity of $I$ in $\mathrm{barc}^{\ZZ}(L_{\F}\circ M)$ is
\[\mathrm{full}(M)(I)-\mathrm{full}(M)(I^-)-\mathrm{full}(M)(I^+)+\mathrm{full}(M)(I^{\pm}),
\]
which is also equal to $\mathrm{dgm}_{\mathbf{vec}}^\mathbf{ZZ}(L_{\F}\circ M)(I)$.
\end{corollary}

We illustrate how to utilize Proposition \ref{thm:full is rank} for computing the $0$-th level set barcode of a Reeb graph:

\begin{example}\label{ex:non-isomorphism thm} Consider  $M:\mathbf{ZZ}\rightarrow \mathbf{set}$ whose corresponding Reeb graph is depicted as in Figure \ref{fig:Curry} (A). By Corollary \ref{cor:new formula for 0th}, we have that
\begin{align*}
    &\mathrm{dgm}_{\mathbf{vec}}^\mathbf{ZZ}(L_{\F}\circ M)([2,3)_{\mathbf{ZZ}})\\
    &=\mathrm{full}(M)([2,3)_{\mathbf{ZZ}})-\mathrm{full}(M)((1,3)_{\mathbf{ZZ}})-\mathrm{full}(M)([2,3]_{\mathbf{ZZ}})+\mathrm{full}(M)((1,3]_{\mathbf{ZZ}})\\
    &=2-1-1+1\\
    &=1.
\end{align*}
By applying the same strategy to the other intervals of $\mathbf{ZZ}$, we have: \[\mathrm{dgm}_{\mathbf{vec}}^\mathbf{ZZ}(L_{\F}\circ M)(I)=\begin{cases}
1,&I\in \{[2,3)_{\mathbf{ZZ}},(2,3]_{\mathbf{ZZ}},[1,4]_{\mathbf{ZZ}}\},
\\0,&\mbox{otherwise.}
\end{cases}
\]
\end{example}
We remark that the Reeb graph in Example \ref{ex:non-isomorphism thm} was introduced in \cite[Figure 12]{adams2015evasion} along the way to address the problem of searching for evasion paths in mobile sensor network. The authors pointed out that one could make a wrong guess at the $0$-th level set barcode of this Reeb graph, before careful homological consideration. See also \cite[Section 10]{curry2013sheaves}.
\begin{figure}
    \centering
    \includegraphics[width=0.95\textwidth]{Reeb_Curry.png}
    \caption{(A) A Reeb graph $(\mathbf{Reeb}(M),\pi)$ which corresponds to $M$ in Example \ref{ex:non-isomorphism thm}. (B) Pre-images  $\pi^{-1}(I)$ for 4 different choices of intervals $I\subset \mathbf{R}$. Blue components are the full components over the corresponding intervals.}
    \label{fig:Curry}
\end{figure}

Given a $M:\mathbf{ZZ}\rightarrow \mathbf{set}$, we also have another persistence diagram $\mathrm{dgm}_{\mathbf{set}}^\mathbf{ZZ}(M)$, which has nothing to do with the linearization functor $L_{\F}$. Next we show that $\mathrm{dgm}_{\mathbf{set}}^\mathbf{ZZ}(M)$ is not necessarily equal to $\mathrm{dgm}^\mathbf{ZZ}_\mathbf{vec}(L_{\F}\circ M)$:

\begin{example}\label{ex:non-isomorphic} Consider  $M:\mathbf{ZZ}\rightarrow \mathbf{set}$ whose corresponding Reeb graph is depicted as in Figure \ref{fig:Curry} (A). From Definition \ref{def:full components} \ref{item:full components4}, recall $\mathrm{rk}(M)(\langle b,d\rangle_{\mathbf{ZZ}})$ counts the number of $\langle b,d\rangle$-full components \emph{with a section.} We claim that
\begin{equation}\label{eq:claim}
    \mbox{for $I\in \mathbf{Int}(\mathbf{ZZ})$,} \hspace{8mm} \mathrm{rk}(M)(I)=\begin{cases} 0,&I \supsetneq [2,3]_{\mathbf{ZZ}}\\
\mathrm{full}(M|_I),&\mbox{otherwise.}
\end{cases}
\end{equation}

Assume that $I:=\langle b,d\rangle_{\mathbf{ZZ}}\in \mathbf{Int}(\mathbf{ZZ})$ strictly contains $[2,3]_{\mathbf{ZZ}}$. Then, $\pi^{-1}\langle b,d\rangle$ has one connected component and it does not has a section, i.e. there is no map $s:\langle b,d \rangle \rightarrow \mathbf{Reeb}(M)$ such that $\pi\circ s = \mathrm{id}_{\langle b,d \rangle}$. On the other hand, if $I$ does not strictly contain $[2,3]_{\mathbf{ZZ}}$, then every $\langle b,d\rangle$-full-connected component has a section. These observations prove the claim in (\ref{eq:claim}). Now by Definition \ref{def:generalized PD2} we have:
\[\mathrm{dgm}_{\mathbf{set}}^{\mathbf{ZZ}}(M)(I)=\begin{cases} 1,&I=[2,3)_{\mathbf{ZZ}}\ \mbox{or}\ I=(2,3]_{\mathbf{ZZ}}\\ -1,&I=[2,3]_{\mathbf{ZZ}}\\0,&\mbox{otherwise}.
\end{cases}
\]
\end{example}

\begin{Remark}
\begin{enumerate}[label=(\roman*)]
    \item The persistence diagram of a $\mathbf{ZZ}$-indexed $\mathbf{set}$-diagram is not a complete invariant. For example, assume that $N:\mathbf{ZZ}\rightarrow \mathbf{set}$ is defined as
    \[N|_{[2,3]_{\mathbf{ZZ}}}=M|_{[2,3]_{\mathbf{ZZ}}}, \hspace{10mm} N_{s}=\emptyset\ \mbox{for $s\notin [2,3]_{\mathbf{ZZ}}$}.\]
It is not difficult to check that $\mathrm{dgm}_{\mathbf{set}}^{\mathbf{ZZ}}(M)= \mathrm{dgm}_{\mathbf{set}}^{\mathbf{ZZ}}(N)$, even if $M$ and $N$ are not isomorphic.
    \item For every $M:\mathbf{ZZ}\rightarrow \mathbf{set}$, $\mathrm{rk}(M)(I)\leq \mathrm{rk}(L_{\F}\circ M)(I)$ for all $I=\langle b,d\rangle_{\mathbf{ZZ}}$. This directly follows from the fact that $\mathrm{rk}(M)(I)$ counts $\langle b,d\rangle$-full-components \emph{with a section}, whereas $\mathrm{rk}(L_{\F}\circ M)(I)$ counts $\langle b,d\rangle$-full-components.
\end{enumerate}
\end{Remark}

In Section \ref{sec:set-stability} we will discuss the stability of $\mathrm{dgm}_{\mathbf{set}}^\mathbf{ZZ}(M)$ under perturbations of $M:\mathbf{ZZ}\rightarrow \mathbf{set}$.

\paragraph{Extended persistence and a proof of Proposition \ref{thm:full is rank}.} For proving Proposition \ref{thm:full is rank}, we briefly review the notion of \emph{extended persistence}. See \cite{CEH09} for details.

Let $X$ be a topological space and let $f:X\rightarrow \mathbf{R}$ be a Morse-type function (Definition \ref{def:morse type}) where $S:=\{s_1,s_2,\ldots,s_n\}$ is the collection of critical points of $f$. Let us select a set of indices $t_i$ which satisfy
\[-\infty<t_0<s_1<t_1<s_2<\ldots<t_{n-1}<s_n<t_n<\infty.
\]

For $1\leq i\leq j\leq n$, let $X_i^j:=f^{-1}([t_i,t_j])$. For $k\in\mathbf{Z}_+$, consider the following diagram of absolute and relative homology groups:
\[\begin{tikzcd}
\mathrm{H}_k(X_0^0)\arrow{r}{}&\mathrm{H}_k(X_0^1)\arrow{r}{}&\cdots\arrow{r}{}&\mathrm{H}_k(X_0^{n-1})\arrow{r}{}&\mathrm{H}_k(X_0^n)\arrow{d}{\rotatebox{90}{$\,\cong$}}
\\
\mathrm{H}_k(X_0^n,X_0^n)&\arrow{l}{}\mathrm{H}_k(X_0^n,X_1^n)&\arrow{l}{}\cdots&\arrow{l}{}\mathrm{H}_k(X_0^n,X_{n-1}^n)&\arrow{l}{}\mathrm{H}_k(X_0^n,X_n^n),
\end{tikzcd}\]
where each horizontal arrow stands for the map induced by the inclusion.
The collection of pairs arising from this diagram are recorded in the so-called \emph{$k$-th extended persistence diagram}. There are three different types of pairs: ordinary pairs arise between the elements in the top row of the sequence, relative pairs between the elements in the bottom row, and extended pairs span both rows. In particular, in the $k$-th extended persistence diagram,
\begin{enumerate}[label=(\roman*)]
    \item an ordinary pair of $X_0^i$ and $X_0^j$ ($i<j<n$) is recorded as $[s_i,s_{j+1})$,
    \item a relative pair of $(X_{0}^n,X_{i}^n)$ and $(X_{0}^n,X_{j}^n)$ ($i<j<n$) is recorded as $[\bar{s}_{j+1},\bar{s}_{i})$,
    \item an extended pair of $X_0^i$ and $(X_{0}^n,X_{j}^n)$ is recorded as  $[s_i,\bar{s}_j)$.

\end{enumerate}

\begin{proof}[Proof of Proposition \ref{thm:full is rank}] Fix $I:=\langle b,d \rangle_{\mathbf{ZZ}} \in\mathbf{Int}(\mathbf{ZZ})$. We will prove that
\begin{equation}\label{eq}
    \mathrm{Full}(M)(I)=\mathrm{rk}_{\mathbf{vec}}(L_{\F}\circ M) (I).
\end{equation}
By Lemma \ref{lem:meaning of rank}, $\mathrm{rk}_{\mathbf{vec}}(L_{\F}\circ M)(I)$ is equal to the multiplicity of $I$ in $\mathrm{barc}^I(L_{\F}\circ M|_I)$. Let $(\mathbf{Reeb}(M|_I),\pi)$ be the Reeb graph corresponding to $M|_I$. By the bijection given in \cite[EP Equivalence Theorem (Table 1)]{carlsson2009zigzag}, the copies of $I=\langle b,d \rangle_{\mathbf{ZZ}}$ in $\mathrm{barc}^{\ZZ}(L_{\F}\circ M|_I)$ one-to-one correspond to the copies of $[b,\bar{d})$ in the $0$-th extended persistence diagram of $(\mathbf{Reeb}(M|_I),\pi)$.  Also, the copies of $[b,\bar{d})$ in the $0$-th extended persistence diagram of $(\mathbf{Reeb}(M|_I),\pi)$ one-to-one correspond to the connected components of $\mathbf{Reeb}(M|_I)$ whose image via $\pi$ is $[b,d]\subset \mathbf{R}$ \cite[p.83]{CEH09}. These connected components are exactly the full components of $M|_I$ in the sense of Definition \ref{def:full component}. Therefore, we have the equality in (\ref{eq}).
\end{proof}

\subsection{The stability of $\mathbf{set}$-persistence diagrams for merge trees and untwisted Reeb graphs}\label{sec:set-stability}

Patel's semicontinuity theorem \cite{patel2018generalized} states that the so-called \emph{type $\mathcal{A}$ persistence diagram} of $F:\mathbf{R}\rightarrow \mathcal{C}$ is stable to all \emph{sufficiently small} perturbations of $F$. In this section we promote this theorem to a complete continuity theorem when $\mathcal{C}=\mathbf{set}$. Also, in turn we establish a stability result for $\mathbf{set}$-persistence diagrams of a certain class of Reeb graphs.

Again, throughout this section, we identify both of the Grothendieck groups $\mathcal{A}(\mathbf{vec})$ and $\mathcal{A}(\mathbf{set})$ with the integer group $(\mathbf{Z},+)$ (Remark \ref{rem:counterpart}).

\paragraph{Bottleneck stability for merge trees.}

A ``constructible" persistence
module $F:\mathbf{R}\rightarrow \mathbf{set}$ is often said to be a \emph{merge tree} \cite{morozov2013interleaving}; see Definition \ref{def:constructible} in Appendix. In particular, in order to compute the Patel's persistence diagram of $F$, it suffices to consider a certain re-indexed functor $D(F):\mathbf{Z}\rightarrow \mathbf{set}$ of $F$. Such a re-indexing method is described in Appendix \ref{sec:patel}; see the paragraph \emph{Re-indexing a constructible persistence module by $\mathbf{Z}$}. In a nutshell, one can encode all the combinatorial information of a merge tree into a \emph{discrete} merge tree:

\begin{definition}A functor $F:\mathbf{Z}\rightarrow \mathbf{set}$ is said to be a \emph{(discrete) merge tree}.
\end{definition}

Recall from Section \ref{sec:reeb graph barcode} that, given an $M:\mathbf{ZZ}\rightarrow \mathbf{set}$, the two persistence diagrams $\mathrm{dgm}^{\mathbf{ZZ}}_{\mathbf{set}}(M)$ and $\mathrm{dgm}^{\mathbf{ZZ}}_{\mathbf{vec}}(L_{\F}\circ M)$ do not coincide in general. That is not the case for merge trees:

\begin{proposition}\label{prop:isomorphism-merge tree} For any $F:\mathbf{Z}\rightarrow \mathbf{set}$, we have $\mathrm{rk}(F)=\mathrm{rk}(L_{\F}\circ F)$ and therefore, $\mathrm{dgm}_{\mathbf{set}}^{\mathbf{Z}}(F)=\mathrm{dgm}_{\mathbf{vec}}^{\mathbf{Z}}(L_{\F}\circ F)$.
\end{proposition}

Before proving Proposition \ref{prop:isomorphism-merge tree}, note the following: given a set map $f:A\rightarrow B$, it directly follows from the definition of the linearization functor $L_{\F}$ that the cardinality of $\mathrm{im}(f)$ is equal to the rank of $L_{\F}(f):L_{\F}(A)\rightarrow L_{\F}(B)$.

\begin{proof}[Proof of Proposition \ref{prop:isomorphism-merge tree}] Let $I:=[a,b]\in \mathbf{Int}(\mathbf{Z})$. Then,
\[\mathrm{rk}(F)(I)=\abs{\mathrm{im} (\varphi_F(a\leq b))}=\mathrm{rank}\left({L_{\F}(\varphi_F(a\leq b))}\right)=\mathrm{rk}(L_{\F}\circ F)(I).
\]
Since, $\mathrm{dgm}_{\mathbf{set}}^{\mathbf{Z}}(F)$ (resp. $\mathrm{dgm}_{\mathbf{vec}}^{\mathbf{Z}}(L_{\F}\circ F)$) is the M\"obius inversion of $\mathrm{rk}(F)$ (resp. $\mathrm{rk}(L_{\F}\circ F)$) over the poset $(\mathbf{Int}(\mathbf{Z}),\supset)=(\mathbf{Con}(\mathbf{Z}),\supset)$ (Definition \ref{def:generalized PD2}), we also have $\mathrm{dgm}_{\mathbf{set}}^{\mathbf{Z}}(F)=\mathrm{dgm}_{\mathbf{vec}}^{\mathbf{Z}}(L_{\F}\circ F)$.
\end{proof}

We remark that the stability of $\mathrm{dgm}_{\mathbf{vec}}^{\mathbf{Z}}(L_{\F}\circ F)$ under perturbations of $F$ was established in \cite{morozov2013interleaving}, whereas the semicontinuity of $\mathrm{dgm}_{\mathbf{set}}^{\mathbf{Z}}(F)$ was established in \cite[Theorem 8.1]{patel2018generalized}\footnote{This theorem states that, when $\mathcal{C}$ is essentially small symmetric monoidal category with images, the persistence diagram of $F:\mathbf{R}\rightarrow \mathcal{C}$ is stable to all \emph{sufficiently small} perturbations of $F$.} (we remark that both of those works use $\mathbf{R}$ as the indexing poset). Now, by virtue of Proposition \ref{prop:isomorphism-merge tree}, \cite[Theorem 8.1]{patel2018generalized} can be improved to a complete stability theorem: Let $d_\mathrm{B}$ be the bottleneck distance, and let $d_{\mathrm{I}}^{\mathcal{C}}$ be the interleaving distance between functors $\mathbf{Z}\rightarrow \mathcal{C}$ (Definitions \ref{def:interleaving_general} and \ref{def:bottleneck distance} in Appendix). We have:

\begin{corollary}\label{cor:promotion}For $F,G:\mathbf{Z}\rightarrow \mathbf{set}$,
\[d_\mathrm{B}\left(\mathrm{dgm}_{\mathbf{set}}^\mathbf{Z}(F),\mathrm{dgm}_{\mathbf{set}}^\mathbf{Z}(G)\right)\leq d_{\mathrm{I}}^\mathbf{set}(F,G).
\]
\end{corollary}
Though this corollary directly follows from Proposition \ref{prop:isomorphism-merge tree} and arguments similar to those is \cite{morozov2013interleaving}, we provide another concise proof:
\begin{proof}We have:
\begin{align*}
    d_\mathrm{B}\left(\mathrm{dgm}_{\mathbf{set}}^{\mathbf{Z}}(F),\mathrm{dgm}_{\mathbf{set}}^{\mathbf{Z}}(G)\right)&=d_\mathrm{B}\left(\mathrm{dgm}_{\mathbf{vec}}^{\mathbf{Z}}(L_{\F}\circ F),\mathrm{dgm}_{\mathbf{vec}}^{\mathbf{Z}}(L_{\F}\circ G)\right)&\mbox{by Proposition \ref{prop:isomorphism-merge tree}}\\
    &= d_{\mathrm{I}}^\mathbf{vec}(L_{\F}\circ F,L_{\F}\circ G)&\mbox{see below}\\
    &\leq d_{\mathrm{I}}^\mathbf{set}(F,G)&\mbox{by functoriality of $L_{\F}$.}
    \end{align*}
The second equality follows from the celebrated isometry theorem \cite{chazal2016structure,lesnick}.
\end{proof}
We remark that Corollary \ref{cor:promotion} is true even for constructible functors $F,G:\mathbf{R}\rightarrow\mathbf{set}$ (Definition \ref{def:constructible} in Appendix), which can be proved via trivial re-indexing of $F,G$ by $\mathbf{Z}$.

\paragraph{Decomposition of a Reeb graph and untwisted Reeb graphs.} We define \emph{untwisted Reeb graphs}, a generalization of merge trees, and extend Corollary \ref{cor:promotion} to untwisted Reeb graphs.

A Reeb graph $M:\mathbf{ZZ}\rightarrow \mathbf{set}$ is said to be \emph{empty} if $M_s=\emptyset$ for all $s\in \mathbf{ZZ}$. Let $N,N':\mathbf{ZZ}\rightarrow \mathbf{set}$. The \emph{disjoint union} $N\coprod N':\mathbf{ZZ}\rightarrow \mathbf{set}$ is defined as follows: for all $s\in \mathbf{ZZ}$, $(N\coprod N')_{s}:=N_s\sqcup N_s'$ and for all $s\leq t$ in $\mathbf{ZZ}$, $\varphi_{N\coprod N'}(s,t):(N\coprod N')_s \rightarrow (N\coprod N')_t$ is defined as $\varphi_{N}(s,t)\sqcup \varphi_{N'}(s,t)$. We say that a nonempty $M:\mathbf{ZZ}\rightarrow \mathbf{set}$ is \textit{decomposable} if $M$ is isomorphic to $N \coprod N'$ for some nonempty  $N,N':\mathbf{ZZ}\rightarrow \mathbf{set}$. Otherwise, we say that $M$ is \textit{indecomposable}. We have similar definitions even when the indexing poset $\mathbf{ZZ}$ is replaced by any $I\in\mathbf{Int}(\mathbf{ZZ})$.

The decomposition of a nonempty $M:\mathbf{ZZ}\rightarrow \mathbf{set}$ into indecomposables parallels the topological decomposition of a Reeb graph into path-connected components. We can explicitly decompose $M$ as follows: Let $J:=\varinjlim M$, which is a nonempty set (not necessarily finite). According to the canonical construction in equation (\ref{eq:set colimit construction}), each $j\in J$ is a subset of the disjoint union $\coprod_{k\in \mathbf{ZZ}} M_{k}$. Note that $M\cong \coprod_{j\in C}N^j$, where each $N^j$ is defined as $N^j_k=\{m\in M_k: m\in j\}$ for $s\in \mathbf{ZZ}$ and the internal morphisms of $N$ are the canonical restrictions of the internal morphisms of $M$. Now we directly have:

\begin{proposition} Any nonempty $M:\mathbf{ZZ}\rightarrow \mathbf{set}$ decomposes into a disjoint union of indecomposables $\mathbf{ZZ}\rightarrow \mathbf{set}$, and the decomposition is unique up to a permutation of summands.
\end{proposition}

\begin{Remark}\label{rem:Reeb graph decomposition}
\begin{enumerate}[label=(\roman*)]
\item Recall that a nonempty $M:\mathbf{ZZ}\rightarrow \mathbf{set}$ gives rise to a Reeb graph $(\mathbf{Reeb}(M),\pi)$ (Definition \ref{def:realization}). Given an indecomposable decomposition $M\cong \coprod_{j\in J} N^j$, the path-connected components $(\mathbf{Reeb}(M),\pi)$ are precisely $\mathbf{Reeb}(N^j)$, $j\in J$ equipped with the restrictions of $\pi$.  \label{item:Reeb graph decomposition1}

\item Note that, given any nonempty $M:\mathbf{ZZ}\rightarrow \mathbf{set}$, the following are equivalent: (a) a nonempty $M$ is indecomposable, (b) $\mathbf{Reeb}(M)$ (Definition \ref{def:realization}) contains only one path-connected component, (c) $\varinjlim M$ is a singleton.  \label{item:Reeb graph decomposition2}
\item Given $M:\mathbf{ZZ}\rightarrow \mathbf{set}$ with $M\cong \coprod_{j\in J} N^j$, we have $\mathrm{rk}(M)=\sum_{j\in J}\mathrm{rk}(N^j)$.  \label{item:Reeb graph decomposition3}
\end{enumerate}
\end{Remark}

Let $M:\mathbf{ZZ}\rightarrow \mathbf{set}$ be nonempty indecomposable. Then, $\varinjlim M$ is a singleton by Remark \ref{rem:Reeb graph decomposition} \ref{item:Reeb graph decomposition2}. By $\mathrm{supp}(M)$, we denote the support of the unique element of $\varinjlim M$ (Definition \ref{def:full component}).

\begin{definition}[Untwisted Reeb graphs]\label{def:untwisted}
A nonempty $M:\mathbf{ZZ}\rightarrow \mathbf{set}$ is said to be \emph{untwisted} if the following holds: For $I\in \mathbf{Int}(\mathbf{ZZ})$ such that $M|_{I}$ is nonempty, if $M|_I\cong \coprod_{j\in J} N^j$ for some indexing set $J$ and nonempty indecomposables $N^j:I\rightarrow \mathbf{set}$, then $\varprojlim N^j|_{\mathrm{supp}(N^j)}\neq \emptyset$ for each $j\in J$.
\end{definition}

Examples of untwisted Reeb graphs include $M$ in Example \ref{ex:Reeb} and merge trees\footnote{Every $\mathbf{Z}$-indexed $\mathbf{set}$-diagram $F$ can be converted into a $\mathbf{ZZ}$-indexed diagram $D(F)$ which contains the same combinatorial information as $F$ (refer to the paragraph \emph{Re-indexing $\mathbf{Z}$-indexed diagram by $\mathbf{ZZ}$} in Appendix \ref{sec:patel}). In this respect, every merge tree can be viewed as a Reeb graph.}, while non-examples include the Reeb graph of Figure \ref{fig:Curry} (A). Let us characterize untwisted Reeb graphs:

\begin{proposition}\label{prop:characterization of untwisted reeb graphs}
Let $M:\mathbf{ZZ}\rightarrow \mathbf{set}$ be nonempty and let $(\mathbf{Reeb}(M),\pi)$ be the corresponding Reeb graph (Definition \ref{def:realization}). The following are equivalent:
\begin{enumerate}[label=(\roman*)]
    \item $M$ is untwisted.\label{item:characterization1}
    \item $\mathrm{rk}(M)=\mathrm{rk}(L_{\F}\circ M)$  (and thus, $\mathrm{dgm}_{\mathbf{set}}^\mathbf{ZZ}(M)=\mathrm{dgm}_{\mathbf{vec}}^\mathbf{ZZ}(L_{\F}\circ M)$).\label{item:characterization2}
    \item  For each real interval $\langle b,d \rangle$ such that  $\pi^{-1}(\langle b,d\rangle)$ is nonempty, the restriction of $\pi$ to each connected component of $\pi^{-1}(\langle b,d\rangle)$ has a section. \label{item:characterization3}

\end{enumerate}

\end{proposition}

\begin{proof}
We will utilize geometric insight of Example \ref{ex:Reeb2} and Remark \ref{rem:Reeb graph decomposition} throughout the proof.

\ref{item:characterization1}$\Rightarrow$\ref{item:characterization3}: It suffices to consider an interval $\langle b,d \rangle\subset \mathbf{R}$ such that $b,d\in\mathbf{Z}\cup\{-\infty,\infty\}$ and $\pi^{-1}(\langle b,d \rangle)$ is nonempty. Let $I:=\langle b,d\rangle_{\mathbf{ZZ}}$ and consider the restricted diagram $M|_I$. Note that the assumption $\pi^{-1}(\langle b,d \rangle)\neq \emptyset$ implies that $M|_I$ is nonempty. Now assume that $M|_I$ has an indecomposable decomposition $M|_I\cong \coprod_{j\in J} N^{j}$.  Note that $\mathbf{Reeb}(N^j)$ are exactly the connected components of $\mathbf{Reeb}(M|_I)$. Also, there exists a canonical bijection from $\varprojlim N^j|_{\mathrm{supp}(N^j)}$ to the sections of the restriction $\pi|_{\mathbf{Reeb}(N^j)}$ (cf. Example \ref{ex:Reeb2} \ref{item:Reeb2 2}). For each $j\in J$, since $\varprojlim N^j|_{\mathrm{supp}(N^j)}\neq \emptyset$, $\pi|_{\mathbf{Reeb}(N^j)}$ has at least one section.

\ref{item:characterization3}$\Rightarrow$\ref{item:characterization2}:
Fix $I=\langle b,d \rangle_{\mathbf{ZZ}}$. By assumption, every $\langle b,d \rangle$-full-component has a section. Invoking that $\mathrm{rk}(L_{\F}\circ M)(I)$ is the number of $\langle b,d \rangle$-full-components (Proposition \ref{thm:full is rank}), whereas $\mathrm{rk}(M)(I)$ stands for the number of $\langle b,d \rangle$-full-components \emph{with a section} (Definition \ref{def:full components} \ref{item:full components4} and Example \ref{ex:Reeb2} \ref{item:Reeb2 4}), we have $\mathrm{rk}(M)(I)=\mathrm{rk}(L_{\F}\circ M)(I)$.

\ref{item:characterization2}$\Rightarrow$\ref{item:characterization1}:  Fix any $I\in \mathbf{Int}(\mathbf{ZZ})$ such that $M|_{I}$ is nonempty and assume that $M|_I\cong \coprod_{j\in J} N^j$ for some indexing set $J$ and nonempty indecomposables $N^j:I\rightarrow \mathbf{set}$.

Fix $j\in J$ and let $K:=\mathrm{supp}(N^j)=\langle b,d \rangle_{\mathbf{ZZ}}$. By assumption, the number of $\langle b,d \rangle$-full-components $\mathrm{rk}(M)(K)$ of $\mathbf{Reeb}(M)$ is equal to the number $\mathrm{rk}(L_{\F}\circ M)(K)$ of $\langle b,d \rangle$-full-components of $\mathbf{Reeb}(M)$ \emph{which has a section.} Therefore, every $\langle b,d \rangle$-full-component has a section. By the choice of $K$, $\mathbf{Reeb}(N^j)$ is a $\langle b,d \rangle$-full-component and thus $\mathbf{Reeb}(N^j)$ has a section. This means that $\varprojlim N^j|_{K} \neq \emptyset$, as desired.

\end{proof}

\paragraph{Bottleneck stability for untwisted Reeb graphs.} We extend the stability result in Corollary \ref{cor:promotion} to a class of \emph{untwisted Reeb graphs} in a similar vein.

An \emph{interleaving} distance $d_{\mathrm{I}}^{\mathcal{C}}$ between zigzag modules $\mathbf{ZZ}\rightarrow \mathcal{C}$ is defined when $\mathcal{C}$ is cocomplete (Definition \ref{def:interleaving by botnan} in Appendix). The following theorem can be proved in the same way as Corollary \ref{cor:promotion} except utilizing the algebraic stability of zigzag modules (Theorem \ref{thm:bottleneck stability} in Appendix) by Botnan and Lesnick in lieu of the isometry theorem.

\begin{theorem}\label{thm:stability for sets}For any untwisted Reeb graphs $M,N:\mathbf{ZZ}\rightarrow \mathbf{set}$,
\begin{equation}\label{eq:stability for reeb graphs}
    d_\mathrm{B}\left(\mathrm{dgm}_\mathbf{set}^\mathbf{ZZ}(M),\mathrm{dgm}_\mathbf{set}^\mathbf{ZZ}(N)\right)\leq  2\cdotd_{\mathrm{I}}^\mathbf{Set}(M,N).
\end{equation}
\end{theorem}

\begin{proof}We have:
\begin{align*}
    d_\mathrm{B}\left(\mathrm{dgm}_{\mathbf{set}}^{\mathbf{ZZ}}(M),\mathrm{dgm}_{\mathbf{set}}^{\mathbf{ZZ}}(N)\right)&=d_\mathrm{B}\left(\mathrm{dgm}_{\mathbf{vec}}^{\mathbf{ZZ}}(L_{\F}\circ M),\mathrm{dgm}_{\mathbf{vec}}^{\mathbf{ZZ}}(L_{\F}\circ N)\right)&\mbox{by Proposition \ref{prop:characterization of untwisted reeb graphs}}\\
    &\leq 2\cdot d_{\mathrm{I}}^\mathbf{Vec}(L_{\F}\circ M,L_{\F}\circ N)&\mbox{Theorem \ref{thm:bottleneck stability}}\\
    &\leq 2\cdotd_{\mathrm{I}}^\mathbf{Set}(M,N)&\mbox{by functoriality of $L_{\F}$.}
    \end{align*}
\end{proof}

We remark that the inequality in (\ref{eq:stability for reeb graphs}) is tight:  $\mathrm{dgm}_\mathbf{set}^\mathbf{ZZ}(M)$ and $\mathrm{dgm}_\mathbf{set}^\mathbf{ZZ}(N)$ are equal to $\mathrm{dgm}_\mathbf{vec}^\mathbf{ZZ}(L_{\F}\circ M)$ and $\mathrm{dgm}_\mathbf{vec}^\mathbf{ZZ}(L_{\F}\circ N)$ respectively and the tightness of the following inequality is known \cite{botnan2018algebraic}:
\[ d_\mathrm{B}\left( \mathrm{dgm}_\mathbf{vec}^\mathbf{ZZ}(L_{\F}\circ M), \mathrm{dgm}_\mathbf{vec}^\mathbf{ZZ}(L_{\F}\circ N)\right)\leq  2\cdotd_{\mathrm{I}}^\mathbf{set}(M,N).
\]
We provide a concrete example of which the both sides in (\ref{eq:stability for reeb graphs}) coincide:
\begin{example}[Tightness]\label{ex:tight}Let $M:\mathbf{ZZ}\rightarrow \mathbf{set}$ be defined as
\[M_{(0,0)}=\{v_1\},\ M_{(1,1)}=\{v_2\},\ \ M_{(1,0)}=\{e_1,e_2\}\]
and any other $M_{(i,j)}$ is the empty set. The maps $\varphi_M((1,0),(0,0)),\varphi_M((1,0),(1,1))$ are the unique surjections See Figure \ref{fig:tightness} (A).  One can check that $\mathrm{dgm}_{\mathbf{set}}^\mathbf{ZZ}(M)(I)= 1$ if $I=[1,2]_{\mathbf{ZZ}}$ or $I=(1,2)_{\mathbf{ZZ}}$, and $\mathrm{dgm}_{\mathbf{set}}^\mathbf{ZZ}(M)(I)= 0$ otherwise.

On the other hand, define $N:\mathbf{ZZ}\rightarrow \mathbf{set}$ as
\[N_{(0,0)}=\{v_1\},\ N_{(1,1)}=\{v_2\},\ \ N_{(1,0)}=\{e_1\}\] and any other $N_{(i,j)}$ is the empty set.  The maps $\varphi_N((1,0),(0,0)),\varphi_N((1,0),(1,1))$ are the unique bijections. See Figure \ref{fig:tightness} (B).  One can check that $\mathrm{dgm}_{\mathbf{set}}^\mathbf{ZZ}(N)(I)= 1$ if $I=[1,2]_{\mathbf{ZZ}}$ and $\mathrm{dgm}_{\mathbf{set}}^\mathbf{ZZ}(N)(I)= 0$ otherwise. Checking that \[d_\mathrm{B}\left(\mathrm{dgm}^{\ZZ}_\mathbf{set}(M),\mathrm{dgm}^{\ZZ}_\mathbf{set}(N)\right)=1/2,\hspace{2mm}\mbox{and}\ d_{\mathrm{I}}^{\mathbf{set}}(M,N)=1/4,\]
demonstrates the tightness of the inequality in (\ref{eq:stability for reeb graphs}).
\end{example}

\begin{figure}
    \centering
    \includegraphics[width=0.8\textwidth]{tightness.png}
    \caption{Illustration for Example \ref{ex:tight}. (A) The Reeb graph corresponding to $M$. (B)  The Reeb graph corresponding to $N$. Observe that for every interval $I\in\mathbf{R}$, the preimages $\pi_M^{-1}(I)$ and $\pi_N^{-1}(I)$ consist solely of connected components which allow a section. This demonstrate that $M$ and $N$ are untwisted.}
    \label{fig:tightness}
\end{figure}

\section{Discussion}\label{sec:discussion}

We have extended the notions of rank invariant and generalized persistence diagram due to Patel \cite{patel2018generalized} to the setting of generalized persistence modules $\mathbf{P}\rightarrow \mathcal{C}$, when $\mathbf{P}$ and $\mathcal{C}$ satisfy mild assumptions.
The rank invariant and persistence diagram defined in this paper generalize those in \cite{carlsson2009zigzag,carlsson2009theory,cohen2007stability,patel2018generalized,botnan2018algebraic,ZC05}. In particular, our construction of the rank invariant yields a complete invariant for interval decomposable persistence modules $\mathbf{P}\rightarrow \mathbf{vec}$ (which include the case of zigzag modules). Along the way, the $0$-th level set barcode of a Reeb graph has been interpreted with a novel viewpoint. This leads to the promotion of a Patel's theorem and opens up the possibility of the existence of another efficient algorithm for computing the $0$-th level set barcode of a Reeb graph or a Morse-type function.

Many questions remain unanswered: (1) To what extent can we generalize the stability results about persistence diagrams/barcodes beyond the results in Section \ref{sec:set-stability} and those in  \cite{CCG09,cohen2007stability,botnan2018algebraic,patel2018generalized,mccleary2018bottleneck}? In particular, for arbitrary $M:\mathbf{ZZ}\rightarrow \mathbf{set}$, how to address the stability of $\mathrm{dgm}_{\mathbf{set}}^{\mathbf{ZZ}}(M)$ given that $\mathrm{dgm}_{\mathbf{set}}^{\mathbf{ZZ}}(M)$ could take negative values?\footnote{We saw such a case in Example \ref{ex:non-isomorphic}. Non-positive persistence diagrams also appear in \cite{betthauser2019graded}.} (2) For persistence modules $\mathbf{P}\rightarrow \mathbf{vec}$ which are \emph{not} interval decomposable, how faithful is the rank invariant?

(3) We wonder whether interval modules can be characterized in terms of persistence diagrams as follows: Given an \emph{indecomposable} $F:\mathbf{P}\rightarrow \mathbf{vec}$, if $\mathrm{dgm}^{\mathbf{P}}(F)$ vanishes on $\mathbf{Con}(\mathbf{P})\setminus \mathbf{Int}(\mathbf{P})$ and has non-negative values on $\mathbf{Int}(\mathbf{P})$, is $F$ an interval module? This question is motivated from Example \ref{ex:Alex}.
(4) In order to compute level set barcodes of Morse-type functions, algorithms in \cite{carlsson2009zigzag,milosavljevic2011zigzag} make use of a sequence of operations on matrices. Utilizing the results in Section \ref{sec:reeb graph barcode}, can we establish more efficient algorithms for computing the $0$-th level set barcodes?

\newpage