1 Introduction

1.1 Previous Works

The problem of reconstructing shapes from point clouds has been well studied in computer graphics, computational geometry, machine learning, and other areas. Reconstruction methods aim at building an approximation of a shape from a set of data points that sample it. The resulting object may then be measured or used for certain tasks such as rendering, storing, searching in a database, and so on. In this context, it is desirable that the result of the reconstruction reflects the topology of the original shape. During the past two decades, a lot of research went into finding sampling conditions which guarantee a topologically correct reconstruction. First sampling conditions were assuming shapes to be compact smooth surfaces embedded in the Euclidean three-dimensional space and data points to be noise-free [1, 35, 8, 16]. Since then, much effort has been put into weakening sampling conditions so that a wider class of shapes can be reconstructed from sparser and less accurate samples.

An important step has been to allow noise in the sample. Maybe one of the simplest noise model supposes that each point of the sample lies within some distance of the sampled shape (the sample is accurate) and each point of the sampled shape lies within some distance of a sample point (the sample is dense). When both distances are bounded by the same value \(\varepsilon \), we say that the Hausdorff distance between the shape and the sample is upper bounded by \(\varepsilon \). First sampling conditions were assuming the Hausdorff distance to be less than a fraction the reach of the shape [24]. The reach of \(\mathcal A \) is the infimum of distances between points in \(\mathcal A \) and points in its medial axis. Unfortunately, the reach vanishes for shapes with sharp concave edges and, therefore, is not suitable for expressing sampling conditions for non-smooth manifolds or stratified objects. To deal with this problem, Boissonnat and Oudot [9] considered Lipschitz manifolds while Chazal et al. [10] considered a large class of non-smooth compact sets called sets with a positive \(\mu \)-reach. The \(\mu \)-reach of \(\mathcal A \) is the infimum of distances between points in \(\mathcal A \) and points in its \(\mu \)-medial axis which for \(\mu \in (0,1]\) is a stable subset of the medial axis defined in [10]. More recently, authors in [7] proved under sampling conditions weaker than the one in [10] that an \(r\)-offset of the sample provides a topologically correct reconstruction of any shape with a positive \(\mu \)-reach for some suitable value of the parameter \(r\). It should be noted that this reconstruction can be computed efficiently (i.e., in polynomial time). In this paper, we ask the following question: can we weaken further these sampling conditions and still be able to construct a topologically correct reconstruction of a shape from a sample of it?

The starting point of this work was the observation made in [14] that Betti numbers of a shape \(\mathcal A \) can be derived efficiently from the point set \(\mathcal S \), as long as its Hausdorff distance to \(\mathcal A \) remains smaller than a fourth the weak feature size of \(\mathcal A \). The weak feature size is another notion of feature size equal to the infimum of distances between points in \(\mathcal A \) and critical points of the distance function to \(\mathcal A \). As critical points form a subset of the \(\mu \)-medial axis, the weak feature size is larger than the \(\mu \)-reach for all values of \(\mu \in (0,1]\). Hence, conditions for computing efficiently the Betti numbers of a shape \(\mathcal A \) are significantly milder than the conditions known for building efficiently a topologically correct approximation of \(\mathcal A \). We refer to the mild sampling condition sufficient for inferring Betti numbers as the weak sampling condition. This condition is tight.

1.2 Optimal Reconstruction

We call any algorithm that would be able to produce a topologically correct reconstruction under the weak sampling condition an optimal reconstruction algorithm. We explain in Sect. 3 that, even though no realistic version of an optimal reconstruction algorithm is known today, the weak sampling condition ensures that the sample contains in principle enough information on the sampled shape to produce without ambiguity a topologically correct reconstruction of it. Starting from this observation, we give in Sect. 4 a “naive” algorithm which, at the expense of not being efficient, produces a reconstruction with the correct Betti numbers under conditions slightly stronger than the weak sampling condition.

The main question we pursue is: can we do better? More precisely, does there exist a polynomial time optimal reconstruction algorithm? This problem is closely related to the persistence-sensitive simplification of real-valued functions, whose goal is to filter out topological noise in sub-level sets. Indeed, reconstruction can be thought of as the simplification of distance functions to the samples. For functions defined on triangulated \(2\)-manifolds, polynomial algorithms have been devised [19, 22]. Still, persistence-sensitive simplification of functions in higher dimension remains elusive.

1.3 Homological Simplification

In Sect. 5, we focus on the test at the heart of our naive algorithm. This test requires to answer the following question: given 2 two-dimensional simplicial complexes \(L \subset K\), does there exist a simplicial complex \(X\) containing \(L\) and contained in \(K\) such that the maps induced by the inclusions \(L \hookrightarrow X\) and \(X \hookrightarrow K\) on all modulo \(2\) homology groups are, respectively, surjective and injective. We call this problem the homological simplification of the pair \((K,L)\) and prove that it is NP-complete. Although this result is negative, we believe that it casts new light on the problem of finding a topologically correct reconstruction under weak sampling conditions and opens further research tracks as mentioned in Sect. 6.

1.4 Outline

Section 2 presents the necessary background. Section 3 defines what we mean by an optimal reconstruction algorithm. Section 4 presents an algorithm which can be regarded as an approximation of an optimal reconstruction algorithm. This algorithm requires to be able to solve a problem, which we prove is NP-hard in Sect. 5. Section 6 concludes the paper.

2 Background

The goal of this section is to recall three closely related concepts useful for expressing sampling conditions in shape reconstruction. Given a shape \(\mathcal A \), we define the reach \(r_1(\mathcal A )\), the \(\mu \)-reach \(r_\mu (\mathcal A )\) for any \(\mu \in (0,1]\) and the weak feature size \(\mathrm {wfs} (\mathcal A )\). As we shall see, these quantities are related by the following inequality: \(r_1(\mathcal A ) \le r_\mu (\mathcal A ) \le \mathrm {wfs} (\mathcal A )\). All three concepts can be derived from the critical function of the shape. This leads us to introduce the critical function, which requires first to define the norm of the gradient to the distance function.

The distance function to a compact set plays a central role in several recent works related to topologically guaranteed reconstruction [10, 17, 21]. For a compact set \(\mathcal A \subset \mathbb R ^N\), the distance function \(d_\mathcal{A } : \mathbb R ^N \rightarrow \mathbb R ^+\) maps every point \(q \in \mathbb R ^N\) to

$$\begin{aligned} d_\mathcal{A }(q)&= \min _{a\in \mathcal A } \Vert a-q\Vert . \end{aligned}$$

Although not differentiable, \(d_\mathcal{A }\) admits several notions of extended gradient [13, 21]. For our purpose, we shall introduce a real-valued function \(\Psi _\mathcal{A } : \mathbb R ^N\setminus \mathcal A \rightarrow [0,1]\) which coincides with the norm of the gradient defined in [21]. Let \(\frac{\text{ d}}{\text{ d}t^+}(\cdot )_{|t=0}\) denote the right derivative with respect to the variable \(t\) at \(t=0\). For \(q\in \mathbb R ^N\setminus \mathcal A \) and \(v\in \mathbb S ^{N-1}\), one can check [21] that the quantity \(\frac{\text{ d}}{\text{ d}t^+} d_\mathcal{A }(q+tv)_{|t=0}\) is well-defined and belongs to \([-1,1]\). We define \(\Psi _\mathcal{A }\) as:

$$\begin{aligned} \Psi _\mathcal{A } (q)&= \max \big \{ 0, \sup _{v \in \mathbb S ^{N-1}} {\tfrac{\text{ d}}{\text{ d}t^+} d_\mathcal{A }(q+tv)_{|t=0}} \big \}. \end{aligned}$$

Roughly speaking, \(\Psi _\mathcal{A } (q)\) quantifies at which maximal speed the distance function to \(\mathcal A \) can increase in a neighborhood of \(q\). We are now ready to recall the definition of the critical function \(\chi _\mathcal{A }\) introduced in [10]. The critical function maps every positive real number \(\rho >0\) to the infimum of \(\Psi _\mathcal{A }\) over the set of points at distance \(\rho \) from \(\mathcal A \):

$$\begin{aligned} \chi _\mathcal{A } (\rho )&= \inf _{d_\mathcal{A }(q) = \rho } {\Psi _\mathcal{A } (q) }. \end{aligned}$$

The critical function is lower semi-continuous [10] and allows us to define two quantities, the \(\mu \)-reach and the weak feature size of \(\mathcal A \) denoted, respectively, \(r_\mu (\mathcal A )\) and \(\mathrm {wfs} (\mathcal A )\):

$$\begin{aligned} r_\mu (\mathcal A )&= \inf \left\{ \rho >0, \, \chi _\mathcal{A } (\rho ) < \mu \right\} , \\ \mathrm {wfs} (\mathcal A )&= \inf \left\{ \rho >0, \, \chi _\mathcal{A } (\rho ) =0 \right\} . \end{aligned}$$

The reach of \(\mathcal A \) is equal to \(r_1(\mathcal A )\). From the definition, it is clear that \(r_1(\mathcal A ) \le r_\mu (\mathcal A ) \le \mathrm {wfs} (\mathcal A )\) for any \(\mu \in (0,1]\). Figure 1 shows the critical function \(\chi _\mathcal{A }\) for a simple shape \(\mathcal A \) in the Euclidean plane, which consists of the points at distance \(R\) from a full rectangle of width \(\ell \) and length \(L\).

Fig. 1
figure 1

Left The shape \(\mathcal A \) is the outer closed thick curve and its medial axis consists of the five thin inner segments. Right Critical function \(\chi _\mathcal A \). We have \(r_\mu (\mathcal A ) = R\) for \(\mu > \frac{1}{\sqrt{2}}\) and \(r_\mu (\mathcal A ) = R+\frac{l}{2} = \mathrm {wfs} (A)\) for \(\mu \le \frac{1}{\sqrt{2}}\)

To shed light on these notions, it is useful to make some connections with the medial axis. The medial axis of \(\mathcal A \) is the set of points \(q \notin \mathcal A \) which have at least two closest points in \(\mathcal A \). Alternatively, it is the locus of points \(q\) for which \(\Psi _\mathcal A (q) < 1\). Any point \(q\) for which \(\Psi _\mathcal A (q) = 0\) is called a critical point of the distance function and lies on the medial axis. The reach is the minimum of distances between points in \(\mathcal A \) and points in its medial axis. The weak feature size is the minimum of distances between points in \(\mathcal A \) and critical points.

For instance, the function \(\Psi _\mathcal{A }\) of the shape \(\mathcal A \) depicted in Fig. 1 evaluates to 0 on the horizontal line of the medial axis which constitutes the only critical points in this case, evaluates to \(\frac{1}{\sqrt{2}}\) on the other points of the medial axis and evaluates to 1 on all points of the plane that neither belong to \(\mathcal A \) nor to its medial axis.

For completeness, we also recall the related notion of local feature size, introduced by Amenta et al. [2] for reconstructing smooth shapes. The local feature size is a real-valued function which maps every point of \(\mathcal A \) to its distance to the medial axis. Notice that the local feature size and its infimum, the reach, vanish on non-smooth objects as soon as they contain a sharp concave corner or edge. For this reason, we will focus in Sect. 3.2 on sampling conditions based on the weak feature size and \(\mu \)-reaches which apply to a large class of non-smooth shapes.

Given \(\eta >0\), the \(\eta \)-offset of \(\mathcal A \) is the set of points at distance \(\eta \) or less from \(\mathcal A \), \(\mathcal A ^\eta = d_\mathcal{A }^{-1} \left([0,\eta ]\right)\). As in Morse theory, topological changes in offsets occur only at critical values. More precisely, as stated in [12, 20]:

Lemma 1

(Topological Stability of Offsets) If \(0<x<y< \mathrm {wfs} (\mathcal A )\), then the inclusion map \(\mathcal A ^{x} \hookrightarrow \mathcal A ^{y}\) is a homotopy equivalence.

3 The Quest for an Optimal Reconstruction Algorithm

Section 3.1 contains our definition of a (homological) faithful reconstruction, which formalizes what we mean by a “topologically correct reconstruction.” Section 3.2 compares two algorithms for inferring information on a shape \(\mathcal A \) known through a finite sample \(\mathcal S \). The first algorithm outputs the Betti numbers of \(\mathcal A \) and the second algorithm outputs a faithful approximation of \(\mathcal A \). We then define in Sect. 3.3 an optimal reconstruction algorithm as one that would produce the output of the second algorithm with the input and precondition of the first algorithm.

3.1 Faithful Reconstructions

To prepare our definition of an optimal reconstruction algorithm, we first introduce in this section the notions of faithful reconstruction and faithful homological reconstruction. For the second notion, we shall consider a fixed field \(F\) and take coefficients in \(F\) for homology [23, Chap. 1]. Hence, the property of being a faithful homological reconstruction will depend on the choice of \(F\).

Definition 1

(Faithful (homological) reconstruction) We say that a subset \(\mathcal R \subset \mathbb R ^N\) is a faithful reconstruction of the compact set \(\mathcal A \subset \mathbb R ^N\) if there exist real numbers \(x,y\) such that \(0<x<y<\mathrm {wfs} (\mathcal A )\) and the following two properties hold:

  • \(\mathcal A ^{x} \subset \mathcal R \subset \mathcal A ^{y}\)

  • the inclusion maps \(\mathcal A ^{x} \hookrightarrow \mathcal R \) and \(\mathcal R \hookrightarrow \mathcal A ^{y}\) are homotopy equivalences.

We say that \(\mathcal R \) is a faithful homological reconstruction when the last condition is relaxed to:

  • the inclusion maps \(\mathcal A ^{x} \hookrightarrow \mathcal R \) and \(\mathcal R \hookrightarrow \mathcal A ^{y}\) induce isomorphisms on all homology groups.

For any \(0 < \eta < \mathrm {wfs} (\mathcal A )\), the \(\eta \)-offset of \(\mathcal A \) is clearly a faithful reconstruction of \(\mathcal A \). A faithful reconstruction is always a faithful homological reconstruction. As expected, the converse is not true: a punctured Poincaré sphere nested between a point and a ball is an example where inclusions are not homotopy equivalences but yet induce isomorphisms on homology groups (Cohen-Steiner, Personal communication, 2008). Interestingly, this example does not embed in \(\mathbb R ^3\).

Note that in the above definition, if one of the two inclusion maps \(\mathcal A ^{x} \hookrightarrow \mathcal R \) or \(\mathcal R \hookrightarrow \mathcal A ^{y}\) is a homotopy equivalence, so is the other one. Indeed, by Lemma 1, \(\mathcal A ^x \hookrightarrow \mathcal A ^y\) is a homotopy equivalence and we can conclude by applying Lemma 2 below. A similar statement can be made for the second part of the definition.

Lemma 2

Consider three nested spaces \(\mathcal A \subset \mathcal B \subset \mathcal C \). If two of the three inclusions \(i: \mathcal A \hookrightarrow \mathcal B \), \(j: \mathcal B \hookrightarrow \mathcal C \) and \(k=j \circ i: \mathcal A \hookrightarrow \mathcal C \) are homotopy equivalences, then the third one is a homotopy equivalence also.

Proof

Let us write \(f \simeq g\) if the two maps \(f\) and \(g\) are homotopic. We consider the three cases in turn. If \(i\) and \(j\) are homotopy equivalences with homotopy inverses \(i^{\prime }\) and \(j^{\prime }\), respectively, then \(i^{\prime } \circ j^{\prime }\) is clearly a homotopy inverse of \(k = j \circ i\). If \(j\) and \(k\) are homotopy equivalences with homotopy inverses \(j^{\prime }\) and \(k^{\prime }\), respectively, then using \(k = j \circ i\) we get that \(j^{\prime } \circ k = j^{\prime } \circ j \circ i \simeq i\) and \(k^{\prime } \circ j\) is a homotopy inverse of \(i \simeq j^{\prime } \circ k \). Similarly, if \(i\) and \(k\) are homotopy equivalences with homotopy inverses \(i^{\prime }\) and \(k^{\prime }\), respectively, then using \( k = j \circ i\) we get that \(k \circ i^{\prime } = j \circ i \circ i^{\prime } \simeq j\) and \(i \circ k^{\prime }\) is a homotopic inverse of \(j \simeq k \circ i^{\prime }\).\(\square \)

The following observation will be useful: If \(x\) and \(y\) are two real numbers such that \(\mathcal A ^{x} \subset \mathcal R \subset \mathcal A ^{y}\) with \(0 < x < y < \mathrm {wfs} (\mathcal A )\), then \(\mathcal X \) is a faithful homological reconstruction of \(\mathcal A \) if and only if \(\mathcal A ^x \hookrightarrow \mathcal R \) induces isomorphisms on all homology groups. This is a direct consequence of Lemmas 1 and 2.

3.2 Comparing Existing Algorithms

In this section, we present two algorithms and compare theirs inputs, preconditions, and outputs. Specifically, given as input a finite sample \(\mathcal S \) of an unknown shape \(\mathcal A \), the first algorithm recovers the Betti numbers of \(\mathcal A \) and the second algorithm constructs a faithful approximation of \(\mathcal A \). Each algorithm relies on a key theorem that states sampling conditions ensuring correctness. Both algorithms are polynomial in the size of the sample. Recall that the Hausdorff distance between two compact sets \(\mathcal A \) and \(\mathcal B \) of \(\mathbb R ^N\) is defined by:

$$\begin{aligned} d_H(\mathcal A , \mathcal B ) = \left\Vert d_\mathcal{B }-d_\mathcal{A } \right\Vert_\infty = \sup _{q\in \mathbb R ^N} {\left| d_\mathcal{B }(q)-d_\mathcal{A }(q) \right|}. \end{aligned}$$

3.2.1 Algorithm for Computing Betti Numbers

A powerful tool for inferring Betti numbers from geometric approximations is topological persistence [18]. Theorem 3 below is a corollary of the Persistence Stability Theorem [14] and can also be derived by flow based arguments [12]. Before stating it, we need the following definition.

Definition 2

(Persistent Betti numbers) Let \(\mathcal A \subset \mathbb R ^N\) be a compact set and let \(0 \le x \le y\). The pth (x,y)-persistent Betti number of \(\mathcal A \) is the rank of the homomorphism induced by inclusion \(\mathcal A ^x \hookrightarrow \mathcal A ^y\):

$$\begin{aligned} \beta _p^{x,y}(\mathcal A ) = \mathrm{rank} \left( \mathbf H _p(\mathcal A ^x)\hookrightarrow \mathbf H _p(\mathcal A ^y) \right) \end{aligned}$$

It is noteworthy that the \((x,y)\)-persistent Betti numbers are finite whenever \(x<y\) (de Silva, Personal communication, 2009).

Theorem 3

(Homology Inference [12, 14]) Let \(\mathcal A \) and \(\mathcal S \) be two compact subsets of \(\mathbb R ^N\) and suppose there exists a real number \(\alpha >0\) such that

$$\begin{aligned} d_H(\mathcal S ,\mathcal A ) < \alpha < \tfrac{1}{4} \mathrm {wfs} (\mathcal A ) \end{aligned}$$

Then \(\beta _p (\mathcal A ) = \beta _p^{\alpha ,3\alpha }(\mathcal S )\).

The above theorem leads immediately to a polynomial time algorithm for inferring Betti numbers of a shape \(\mathcal A \) when the sample \(\mathcal S \) of \(\mathcal A \) is finite. Indeed, writing \(K_\alpha (\mathcal S )\) for the \(\alpha \)-complex of \(\mathcal S \), the persistent Betti numbers can be expressed as

$$\begin{aligned} \beta _p^{\alpha ,3\alpha }(\mathcal S ) = \mathrm {rank} \left( \mathbf H _p(K_\alpha (\mathcal S ) )\hookrightarrow \mathbf H _p(K_{3\alpha }(\mathcal S )) \right). \end{aligned}$$

In particular, they can be computed in time cubic the size of \(K_{3\alpha }(\mathcal S )\). Since for a fixed dimension, the size of \(\alpha \)-complexes is polynomial in the number of vertices, it follows that \(\beta _p (\mathcal A )\) can also be computed in polynomial time the size of the sample.

3.2.2 Algorithm for Computing a Faithful Reconstruction

Suppose we want to reconstruct a shape \(\mathcal A \) from a sample \(\mathcal S \). A standard way to do this is to output an \(r\)-offset of \(\mathcal S \). In practice, this computation can be replaced by the computation of \(K_r(\mathcal S )\), which shares the same homotopy type. Both computations can be done in polynomial time if the sample is finite. Assuming the shape has a positive \(\mu \)-reach, it has been proved in [7, 10] that if the Hausdorff distance between \(\mathcal A \) and \(\mathcal S \) is less than a fraction the \(\mu \)-reach of \(\mathcal A \), then this method provides indeed a faithful reconstruction of \(\mathcal A \) for some suitable value of the parameter \(r\). Precisely, setting

$$\begin{aligned} \lambda (\mu ) = \tfrac{\mu ^2}{5\mu ^2+12} \quad \mathrm{and} \quad I_\mu (\alpha ) = \big \{ \tfrac{4\alpha }{\mu ^2} \big \}, \end{aligned}$$

we have:

Theorem 4

(Reconstruction Theorem [7, 10]) Let \(\mathcal A \) and \(\mathcal S \) be two compact subsets of \(\mathbb R ^N\) and suppose there exist two real numbers \(\alpha >0\) and \(\mu \in (0,1]\) such that

$$\begin{aligned} d_H(\mathcal S ,\mathcal A ) < \alpha < \lambda (\mu ) r_\mu (\mathcal A ). \end{aligned}$$

Then \(\mathcal S ^{r}\) is a faithful reconstruction of \(\mathcal A \) for all \(r \in I_\mu (\alpha )\).

The same theorem has been established in [7] but with a larger constant \(\lambda (\mu )\), a different interval of admissible values \(I_\mu (\alpha )\) and different proof techniques. In both cases, \(\lambda (\mu ) < \frac{1}{4}\) and \(\lim _{\mu \rightarrow 0} \lambda (\mu ) = 0\).  

3.2.3 Comparing Sampling Conditions

Table 1 summarizes inputs, preconditions, and outputs of the two polynomial time algorithms described above and inspired by Theorems 3 and 4. Note that the precondition of the first algorithm is significantly weaker than the precondition of the second one especially when \(\mu \) is small because \(r_\mu (\mathcal A ) \le \mathrm {wfs} (\mathcal A )\), \(\lambda (\mu ) < \frac{1}{4}\) and \(\lambda (\mu )\) tends to zero as \(\mu \rightarrow 0\). The gap between the two preconditions leads to the question whether the precondition of the second algorithm can be weakened and replaced by the precondition of the first algorithm. This question motivates our definition of an optimal reconstruction algorithm in the next section.

Table 1 Input, precondition, and output of two polynomial time algorithms derived from Theorem 3 and Theorem 4

3.3 Optimal Reconstruction Algorithms

Note that the precondition required by the first algorithm which we call the weak precondition is equivalent to saying that the following set is non-empty:

$$\begin{aligned} W(\mathcal S ,\alpha ) = \big \{ \mathcal A \,\mathrm{compact\;set\;of}\;\mathbb R ^N \mid d_H(\mathcal S ,\mathcal A ) < \alpha < \tfrac{1}{4} \mathrm {wfs} (\mathcal A ) \big \} \not = \emptyset . \end{aligned}$$

By Theorem 3, all shapes in \(W(\mathcal S ,\alpha )\) share the same Betti numbers and the first algorithm returns the Betti numbers of any \(\mathcal A \in W(\mathcal S ,\alpha )\). We claim that if the input \((\mathcal S ,\alpha )\) of the first algorithm satisfies the weak precondition, that is, if \(W(\mathcal S ,\alpha ) \ne \emptyset \), then the output of the second algorithm is completely determined as well. To explain this, let us first recall the following theorem from [12]:

Theorem 5

[12] Let \(\mathcal A \) and \(\mathcal B \) be two compact subsets of \(\mathbb R ^N\) and \(\alpha >0\) a real number such that

$$\begin{aligned} d_H(\mathcal A ,\mathcal B ) < 2 \alpha < \tfrac{1}{2}\min \left\{ \mathrm {wfs} (\mathcal A ), \, \mathrm {wfs} (\mathcal B ) \right\} . \end{aligned}$$

Then \(\mathcal B ^{2 \alpha }\) is a faithful reconstruction of \(\mathcal A \).

We provide below a quick proof.

proof

Consider the following diagram in which arrows represent inclusion maps between spaces:

figure a1

 

It is not too hard to prove that if the horizontal arrows are homotopy equivalences, then the other arrows are homotopy equivalences also. Note that we can always find \(\delta >0\) such that \( d_H(\mathcal A ,\mathcal B ) < 2 \alpha -\delta \). Setting \(X_0 = \mathcal X ^{\delta }\), \(X_1 = \mathcal X ^{2\alpha }\) and \(X_2 = \mathcal X ^{4\alpha -\delta }\) for \(X \in \{A,B\}\), we get immediately that \(\mathcal B ^{2\alpha }\) is a faithful reconstruction of \(\mathcal A \).\(\square \)

Suppose \(\mathcal A \) and \(\mathcal B \) both belong to \(W(\mathcal S ,\alpha )\). Applying a triangular inequality, we get that \(\mathcal A \), \(\mathcal B \), and \(\alpha \) fulfill conditions of Theorem 5 and, therefore, \(\mathcal B ^{2\alpha }\) is a faithful reconstruction of \(\mathcal A \). Hence, any \(2\alpha \)-offset of a shape \(\mathcal B \in W(\mathcal S ,\alpha )\) is a faithful reconstruction of any shape \(\mathcal A \in W(\mathcal S ,\alpha )\). For this reason, we say that if the pair \((\mathcal S ,\alpha )\) satisfies the weak precondition, then it carries in principle enough information about the unknown shape \(\mathcal A \) to determine without ambiguity a faithful reconstruction of it.

Furthermore, the weak precondition is tight. To explain what this means, let us introduce the set

$$\begin{aligned} W(\mathcal S ,\alpha ,\eta ) = \big \{ \mathcal A \text{ compact} \text{ set} \text{ of} \mathbb R ^N \mid d_H(\mathcal S ,\mathcal A ) < \alpha < \tfrac{1}{4} (\mathrm {wfs} (\mathcal A ) - \eta ) \big \}. \end{aligned}$$

For negative values of \(\eta \), the set \(W(\mathcal S ,\alpha ,\eta )\) is a superset of \(W(\mathcal S ,\alpha )\). We claim that for any \(\eta <0\), \(W(\mathcal S ,\alpha ,\eta )\) may contain objects that do not have the same homology. To construct such an example, consider the two shapes \(\mathcal O \) and \(\mathcal U \) described in [12] and the sample \(\mathcal S \) pictured in Fig. 2. By construction, we have \(\mathrm {wfs} (\mathcal O )=2\), \(\mathrm {wfs} (\mathcal U )=+\infty \) and adjust the angle between the two bars in shape \(\mathcal U \) so that \(d_H(S,\mathcal O )=d_H(S,\mathcal U ) < \frac{1}{2}-\frac{\eta }{8}\) for some \(\eta < 0\). Both \(\mathcal O \) and \(\mathcal U \) belong to \(W(\mathcal S ,\frac{1}{2}-\frac{\eta }{4},\eta )\) but \(\beta _1(\mathcal O ) \not = \beta _1(\mathcal U )\). Therefore, the weak precondition is the weakest among the preconditions expressed in terms of Hausdorff distance and critical functions that allows us to retrieve a faithful reconstruction without ambiguity.

Fig. 2
figure 2

The angle between the two bars in shape \(\mathcal U \) is adjusted such that \(d_H(\mathcal S ,\mathcal O ) = d_H(\mathcal S ,\mathcal U ) < \frac{1}{2}-\frac{\eta }{8}\)

We are now ready to define what we mean by an optimal reconstruction algorithm.

Definition 3

(Optimal reconstruction algorithm) We call optimal reconstruction algorithm any algorithm that takes as input a pair \((\mathcal S ,\alpha )\) satisfying the weak precondition, that is, such that \(W(\mathcal S ,\alpha )\ne \emptyset \), and outputs a set which is a faithful reconstruction of all the shapes in \(W(\mathcal S ,\alpha )\).

The main question motivating this work is whether there exists a polynomial time optimal reconstruction algorithm. Given as input a pair \((\mathcal S , \alpha )\) satisfying the weak precondition, the previous discussion suggests the following strategy for computing a faithful reconstruction: enumerate all compact sets in \(\mathbb R ^N\) and return the \(2\alpha \)-offset of the first compact set \(\mathcal B \) that belongs to \(W(\mathcal S ,\alpha )\). Indeed, by Theorem 5, we know that the output \(\mathcal B ^{2\alpha }\) is a faithful reconstruction of every shape \(\mathcal A \in W(\mathcal S ,\alpha )\). Of course, this procedure is unrealistic and the goal of the next section is to present an effective version of it. To achieve this goal, we will replace the search of a faithful reconstruction by the search of a faithful homological reconstruction and strengthen slightly the weak precondition, assuming instead that \(W(\mathcal S ,\alpha ,\eta )\ne \emptyset \) for some arbitrarily small \(\eta > 0\).

4 Naive Algorithms for Homological Reconstruction

In this section, we describe a naive algorithm that outputs a faithful homological reconstruction under conditions slightly stronger than the weak precondition. We call it “naive” since it has an unbounded time complexity. The idea is to explore a set of cubical sets, refining the size of the cubes until we find a solution.

We proceed in four steps. Given a set \(\mathcal S \) that samples a shape \(\mathcal A \), we first prove the existence of a cubical set that can be derived from the sample \(\mathcal S \) and which is a faithful reconstruction of the shape \(\mathcal A \). Second, we discuss a simple test to decide whether a cubical set is a faithful homological reconstruction of a shape. Based on this test, we then give a reconstruction algorithm for shapes with a positive \(\mu \)-reach (NAIVE_1) and finally, derive a reconstruction algorithm for shapes with a lower bounded weak feature size (NAIVE_2).

4.1 Cubical Sets

Let us start with some definitions. An \(\varepsilon \)-voxel is a closed cube with edge length \(\varepsilon \) and whose vertices belong to the lattice \(\varepsilon \mathbb Z ^N\). We call any finite union of \(\varepsilon \)-voxels an \(\varepsilon \)-cubical set. Let \(\mathcal S \subset \mathbb R ^N\) be a compact set and consider three real numbers \(\alpha >0\), \(\mu \in (0,1]\) and \(\eta > 0\). The goal of this section is to prove the existence of cubical sets that are faithful reconstructions of all shapes in the set

$$\begin{aligned} W(\mathcal S ,\alpha ,\eta ,\mu ) = \big \{ \mathcal A \text{ compact} \text{ set} \text{ of} \mathbb R ^N \mid d_H(\mathcal S ,\mathcal A ) < \alpha < \tfrac{1}{4} (r_\mu (\mathcal A ) - \eta ) \big \}. \end{aligned}$$

We proceed in three phases. First, we recall a result from [6] that states the existence of cubical sets that are faithful reconstructions of shapes with a positive reach (Lemma 6). We then deduce the existence of cubical sets that are faithful reconstructions of shapes with a positive \(\mu \)-reach (Lemma 7) before proving the same for shapes in \(W(\mathcal S ,\alpha ,\eta ,\mu )\) (Lemma 8).

Lemma 6

(Corollary 3 in [6]) For \(d_N =\frac{1}{40 N^3 \lceil \sqrt{N} \rceil }\) and for all compact sets \(\mathcal A \subset \mathbb R ^N\) with reach greater than \(\rho >0\), there exists a \((d_N \rho )\)-cubical set \(\mathcal X \) such that \(\mathcal A \subset \mathcal X \subset \mathcal A ^{\rho }\) and the inclusion maps \(\mathcal A \hookrightarrow \mathcal X \) and \(\mathcal X \hookrightarrow \mathcal A ^{\rho }\) are homotopy equivalences.

Using the above lemma, we derive the existence of cubical sets which are faithful reconstructions of shapes with a positive \(\mu \)-reach.

Lemma 7

There exists a positive constant \(c_N\) depending only upon the ambient dimension \(N\) such that the following property holds: for all real numbers \(x, y\), and \(\mu \in (0,1]\) and all compact sets \(\mathcal A \subset \mathbb R ^N\) satisfying \(r_\mu (\mathcal A ) > y > x > 0\), there exists a \((c_N \mu (y-x))\)-cubical set \(\mathcal X \) such that \(\mathcal A ^x \subset \mathcal X \subset \mathcal A ^y\) and the inclusion maps \(\mathcal A ^x \hookrightarrow \mathcal X \) and \(\mathcal X \hookrightarrow \mathcal A ^y\) are homotopy equivalences. In particular, the cubical set \(\mathcal X \) is a faithful reconstruction of \(\mathcal A \) (see Fig. 3, left).

Fig. 3
figure 3

Left The cubical set (in medium gray) is nested between two offsets (in dark and light gray) of the V-shaped black curve and is a faithful reconstruction of it. Right Two offsets \(\mathcal S ^l\) and \(\mathcal S ^k\) of the sample

Proof

The proof consists in extending Lemma 6 to the situation where compact sets have a positive \(\mu \)-reach with the constant \(c_N = \frac{d_N}{2}\). The key ingredient in the proof is a result in [11] which says that if we dilate a shape with a positive \(\mu \)-reach and then erode it again, we can adjust the parameters of the dilation and erosion in such a way that the resulting shape has a positive reach. Precisely, given a set \(\mathcal Y \subset \mathbb R ^N\), we denote, respectively, by \(\overline{\mathcal{Y }}\) and \(\mathcal Y ^\mathbf{c }\) the closure and the complement of \(\mathcal Y \). For any compact set \(\mathcal Y \subset \mathbb R ^N\) and any real number \(\rho >0\), let \(\mathcal Y ^{-\rho } = \overline{\left(( \mathcal Y ^\mathbf c )^\rho \right)^\mathbf c }\) and consider the set \(\mathcal B = (\mathcal A ^y)^{-\mu (y - x)}\). We know from [11] that the reach of \(\mathcal B \) is greater than or equal to \(\mu (y - x)\) and the inclusion maps corresponding to the sequence

$$\begin{aligned} \mathcal A ^{x} \;\subset \; \mathcal B \;\subset \; \mathcal A ^y \end{aligned}$$

are homotopy equivalences. We can now apply Lemma 6 to the set \(\mathcal B \) whose reach is greater than \(\rho = \frac{\mu (y - x)}{2}\). This gives the existence of a \(\left( c_N \mu (y-x) \right)\)-cubical set \(\mathcal X \) such that:

$$\begin{aligned} \mathcal B \;\subset \; \mathcal X \;\subset \; \mathcal B ^\rho \end{aligned}$$

and the maps corresponding to inclusions are homotopy equivalences. Using \(\mathcal B ^\rho = ((\mathcal A ^y)^{-2\rho })^\rho \subset \mathcal A ^y\), we get the sequence of inclusions

$$\begin{aligned} \mathcal A ^x \;\subset \; \mathcal X \;\subset \; \mathcal A ^y. \end{aligned}$$

in which the inclusion map \(\mathcal A ^x \hookrightarrow \mathcal X \) is a homotopy equivalence. By Lemma 2, \(\mathcal X \) is a faithful reconstruction of \(\mathcal A \).\(\square \)

Unfortunately, the shape is only known through a finite set of points that sample it. Nonetheless, next lemma states that we can deduce from the mere knowledge of the sample a faithful reconstruction of the underlying shape which is a cubical set. Recall that \(V_\varepsilon (\mathcal Y )\) denotes the union of \(\varepsilon \)-voxels that intersect the set \(\mathcal Y \subset \mathbb R ^N\).

Lemma 8

Let \(\alpha , \, \eta >0\) and \(\mu \in (0,1]\) be real numbers and let \(\mathcal A \) and \(\mathcal S \) be compact subsets of \(\mathbb R ^N\) such that \(d_H(\mathcal S ,\mathcal A ) < \alpha \). Then for:

$$\begin{aligned} \varepsilon = \tfrac{\eta }{4 \sqrt{N} + \frac{2}{c_N \mu }}, \quad \quad l= \tfrac{\eta }{2} + \alpha , \quad \quad k= \eta + 3\alpha - \varepsilon \sqrt{N}, \end{aligned}$$

we have the sequence of inclusions:

$$\begin{aligned} \mathcal A ^{\frac{\eta }{2}} \;\subset \; V_\varepsilon (\mathcal S ^{l}) \;\subset \; \mathcal A ^{\frac{3\eta }{4} + 2\alpha } \;\subset \; V_\varepsilon (\mathcal S ^{k}) \;\subset \; \mathcal A ^{\eta + 4 \alpha }. \end{aligned}$$

Furthermore, if we assume \(d_H(\mathcal S ,\mathcal A ) < \alpha < \frac{1}{4} \left(r_\mu (\mathcal A ) - \eta \right)\), there exists an \(\varepsilon \)-cubical set \(\mathcal X \) such that:

$$\begin{aligned} \mathcal A ^{\frac{\eta }{2}} \;\subset \; V_\varepsilon (\mathcal S ^{l}) \;\subset \; \mathcal X \;\subset \; V_\varepsilon (\mathcal S ^{k}) \;\subset \; \mathcal A ^{\eta + 4\alpha } \end{aligned}$$

and the inclusion maps \(\mathcal A ^{\frac{\eta }{2}} \hookrightarrow \mathcal X \) and \(\mathcal X \hookrightarrow \mathcal A ^{4\alpha + \eta }\) are homotopy equivalences. In particular, \(\mathcal X \) is a faithful reconstruction of \(\mathcal A \).

Proof

Note that for all compact sets \(\mathcal Y \subset \mathbb R ^N\), we have \(\mathcal Y \subset V_\varepsilon (\mathcal Y ) \subset \mathcal Y ^{\varepsilon \sqrt{N}}\). It follows that for all \(t \ge 0\), we have the following sequence of inclusions:

$$\begin{aligned} \mathcal A ^{t} \;\subset \; \mathcal S ^{t + \alpha } \;\subset \; V_\varepsilon (\mathcal S ^{t + \alpha }) \;\subset \; \mathcal S ^{t + \alpha + \varepsilon \sqrt{N}} \;\subset \; \mathcal A ^{t + 2\alpha + \varepsilon \sqrt{N}}. \end{aligned}$$

Applying this sequence twice, once for \(t = \frac{\eta }{2}\) and once for \(t = \eta + 2\alpha - \varepsilon \sqrt{N}\), we get that

$$\begin{aligned} \mathcal A ^{\frac{\eta }{2}} \subset V_\varepsilon (\mathcal S ^{\frac{\eta }{2} + \alpha }) \subset \mathcal A ^{\frac{\eta }{2} + 2\alpha + \varepsilon \sqrt{N}} \subset \mathcal A ^{\eta + 2\alpha - \varepsilon \sqrt{N}} \subset V_\varepsilon (\mathcal S ^{\eta + 3\alpha - \varepsilon \sqrt{N}}) \subset \mathcal A ^{\eta + 4 \alpha }. \end{aligned}$$

The value \(\varepsilon \) has been chosen precisely such that the parameters of the two offsets of \(\mathcal A \) in the middle differ by \(\frac{\varepsilon }{c_N \mu }\). Specifically, writing \(x = \frac{\eta }{2} + 2\alpha + \varepsilon \sqrt{N}\) and \(y = \eta + 2\alpha - \varepsilon \sqrt{N}\), we have \(y - x = \frac{\varepsilon }{c_N \mu }\). Hence, applying Lemma 7 to \(\mathcal A \), we get the existence of an \(\varepsilon \)-cubical set \(\mathcal X \) such that \(\mathcal A ^x \subset \mathcal X \subset \mathcal A ^y\) and the maps corresponding to the inclusions are homotopy equivalences. The lemma follows.\(\square \)

4.2 Homological Simplification

Almost all pieces are in place to write a reconstruction algorithm. Given as input a sample \(\mathcal S \) of a shape \(\mathcal A \), Lemma 8 suggests to enumerate all cubical sets nested between the two cubical sets \(\mathcal L = V_\varepsilon (\mathcal S ^{l})\) and \(\mathcal K = V_\varepsilon (\mathcal S ^{k})\) and stop as soon as we find a faithful homological reconstruction (see Fig. 4). Yet, we still need to discuss how to recognize that a cubical set \(\mathcal X \) nested between cubical sets \(\mathcal L \) and \(\mathcal K \) is actually a faithful homological reconstruction of shape \(\mathcal A \). For this, we will suppose that simplicial complexes \(L \subset X \subset K\) triangulate cubical sets \(\mathcal L \subset \mathcal X \subset \mathcal K \) and characterizes \(\mathcal X = |X|\) using the notion of homological simplification introduced below.

Fig. 4
figure 4

Top Boundaries of \(\mathcal L = V_\varepsilon (\mathcal S ^{l})\) and \(\mathcal K = V_\varepsilon (\mathcal S ^{k})\) are depicted in dark and light gray. Bottom The cubical set \(\mathcal X \) in medium gray is nested between \(\mathcal L \) and \(\mathcal K \) and is a faithful homological reconstruction of \(\mathcal A \)

Definition 4

(Homological simplification) Let \(L \subset K\) be two simplicial complexes. The simplicial complex \(X\) is said to be a homological simplification of the pair \((K,L)\) if \(L\subset X \subset K\) and the maps \(j_*:\mathbf H _p (L) \rightarrow \mathbf H _p (X)\) and \(i_*:\mathbf H _p (X) \rightarrow \mathbf H _p (K)\) induced by inclusions are, respectively, surjective and injective for all integers \(p \ge 0\).

A useful observation is that since we are working with coefficients in \(F\) and homology groups are finite-dimensional vector spaces, \(X\) is a homological simplification of the pair \((K,L)\) if and only if \(X\) realizes the persistent homology of \(L\) into \(K\).

This is a consequence of the following lemma:

Lemma 9

For any sequence of finite-dimensional vector spaces \(U \rightarrow V \rightarrow W\), the map \(U \rightarrow V\) is surjective and the map \(V \rightarrow W\) is injective if and only if \(\mathrm {Rank} ({U \rightarrow W}) = \dim (V)\).

Proof

Indeed, if \(j: U \rightarrow V\) is surjective and \(i: V \rightarrow W\) is injective then

$$\begin{aligned} \mathrm {Rank} ({i\circ j}) = \dim (i\circ j(U)) = \dim ( i(V) ) = \dim (V). \end{aligned}$$

Conversely, note that

$$\begin{aligned} \dim (V) \ge \mathrm {Rank} ({i}) \ge \mathrm {Rank} ({i \circ j}), \\ \dim (V) \ge \mathrm {Rank} ({j}) \ge \mathrm {Rank} ({i \circ j}). \end{aligned}$$

Thus, if \(\dim (V) = \mathrm {Rank} ({i \circ j})\), then \(\dim (V) = \mathrm {Rank} ({i}) = \mathrm {Rank} ({j})\) and so \(i\) is injective and \(j\) surjective.\(\square \)

The next lemma follows immediately.

Lemma 10

Consider a sequence of simplicial complexes \(L \subset X \subset K\). The simplicial complex \(X\) is a homological simplification of the pair \((K,L)\) if and only if \(\mathbf H _p(X)\) is isomorphic to the image of the homomorphism \(\mathbf H _p(L) \rightarrow \mathbf H _p(K)\) induced by the inclusion \(L \subset K\), for all integers \(p \ge 0\).

Lemma 11

Let \(x_1, x_2, x_3\) be three real numbers and \(\mathcal A \) a compact subset of \(\mathbb R ^N\) such that \(0< x_1 < x_2 < x_3 < \mathrm {wfs} (\mathcal A )\). Let \(L \subset K\) be two simplicial complexes such that:

$$\begin{aligned} \mathcal A ^{x_1} \subset |L| \subset \mathcal A ^{x_2} \subset |K| \subset \mathcal A ^{x_3}. \end{aligned}$$

Suppose \(X\) is a simplicial complex such that \(L \subset X \subset K\). Then \(X\) is a homological simplification of the pair \((K,L)\) if and only if \(|X|\) is a faithful homological reconstruction of \(\mathcal A \).

Proof

First observe that for any diagram of vector spaces \(\mathbf{A}^{1} \rightarrow \mathbf{L }\rightarrow \mathbf{A}^{2} \rightarrow \mathbf{K }\rightarrow \mathbf{A}^{3}\) where the maps \(\mathbf{A}^{1} \rightarrow \mathbf{A}^{2} \rightarrow \mathbf{A}^{3}\) are isomorphisms, we have \(\mathrm {Rank} ({\mathbf{L }\rightarrow \mathbf{K }}) = \dim (\mathbf{A}^{i})\) for all \(i \in \{1,2,3\}\). Indeed, \(\mathbf{A}^{1} \rightarrow \mathbf{A}^{2}\) bijective implies that \(\mathbf{L }\rightarrow \mathbf{A}^{2}\) surjective and \(\mathbf{A}^{2} \rightarrow \mathbf{A}^{3}\) bijective implies that \(\mathbf{A}^{2} \rightarrow \mathbf{K }\) injective. We conclude by applying Lemma 9 to the diagram \(\mathbf{L }\rightarrow \mathbf{A}^{2} \rightarrow \mathbf{K }\). Consider now the diagram of vector spaces

figure a4

  in which \(\mathbf{A}^{i}_p = \mathbf H _p\left(\mathcal A ^{x_i}\right)\), \(\mathbf{L }_p = \mathbf H _p \left( |L| \right)\), \(\mathbf{K }_p = \mathbf H _p \left( |K| \right)\), \(\mathbf{X }_p = \mathbf H _p \left( |X| \right)\), and the arrows represent inclusion maps. We prove the lemma by establishing equivalences between the following five statements:

  1. (i)

    \(X\) is a homological simplification of the pair \((K,L)\);

  2. (ii)

    \(\mathbf{L }_p \rightarrow \mathbf{X }_p\) is surjective and \(\mathbf{X }_p \rightarrow \mathbf{K }_p\) is injective for all \(p \ge 0\);

  3. (iii)

    \(\dim (\mathbf{X }_p) = \mathrm {Rank} ({\mathbf{L }_p \rightarrow \mathbf{K }_p}) = \dim (\mathbf{A}^{i}_p)\) for all \(i \in \{1,2,3\}\) and all \(p \ge 0\);

  4. (iv)

    all maps \(\mathbf{A}^{1}_p \rightarrow \mathbf{X }_p \rightarrow \mathbf{A}^{3}_p\) are isomorphisms for all \(p \ge 0\);

  5. (v)

    \(|X|\) is a faithful homological reconstruction.

By definition of a homological simplification, (i) is equivalent to (ii). By Lemma 9, (ii) is equivalent to (iii). To prove (iii) \(\implies \) (iv), we just need to observe that \(\mathbf{A}^{1}_p \rightarrow \mathbf{A}^{3}_p\) is a bijection. The reverse implication is obvious. By definition of a faithful homological reconstruction and using the observation at the end of Sect. 3.1, (iv) is equivalent to (v).\(\square \)

4.3 First Naive Reconstruction Algorithm

We are now ready to describe our first reconstruction algorithm NAIVE_1. Its pseudocode is given in Table 2, left. Recall that \(V_\varepsilon (\mathcal Y )\) designates the union of \(\varepsilon \)-voxels that intersect the subset \(\mathcal Y \subset \mathbb R ^N\). Given as input the 4-tuple \((\mathcal S ,\alpha ,\eta ,\mu )\), the algorithm proceeds as follows. It chooses a voxel size \(\varepsilon \), two offset parameters \(l\) and \(k\) (see Table 2 for the exact values of \(\varepsilon \), \(l\) and \(k\)) and derives from the sample \(\mathcal S \) two \(\varepsilon \)-cubical sets \(\mathcal L = V_\varepsilon (\mathcal S ^l)\) and \(\mathcal K = V_\varepsilon (\mathcal S ^k)\), obtained by collecting all \(\varepsilon \)-voxels intersecting respectively \(\mathcal S ^l\) and \(\mathcal S ^k\) (see Figs. 3 and 4). For all cubical sets \(\mathcal X \) containing \(\mathcal L \) and contained in \(\mathcal K \), the algorithm then considers three nested simplicial complexes \(L \subset X \subset K\) triangulating the three cubical sets \(\mathcal L \subset \mathcal X \subset \mathcal K \) in a way that is consistent with the grid. It then returns the underlying space \(\mathcal X \) of \(X\) if the simplicial complex \(X\) is a homological simplification of the pair \((K,L)\) (see definition above). If no homological simplification \(X\) is found between \(L\) and \(K\), the algorithm returns the empty set.

Table 2 Naive reconstruction algorithms

Theorem 12

Let \(\mathcal S \subset \mathbb R ^N\), \(\alpha >0\), \(\mu \in (0,1]\), and \(\eta >0\). Assuming the precondition \(W(\mathcal S ,\alpha ,\eta ) \ne \emptyset \) on the input, the algorithm NAIVE_1 outputs either the empty set or a faithful homological reconstruction of all shapes in \(W(\mathcal S ,\alpha ,\eta )\). If furthermore we assume the stronger precondition \(W(\mathcal S ,\alpha ,\eta ,\mu ) \ne \emptyset \) on the input, the algorithm NAIVE_1 does not return the empty set.

Proof

The correctness of the algorithm NAIVE_1 relies on the lemmas stated in the previous sections. Let \(\mathcal A \in W(\mathcal S ,\alpha ,\eta )\). Equivalently, \(d_H(\mathcal S ,\mathcal A ) < \alpha \) and \(\eta + 4 \alpha < \mathrm {wfs} (\mathcal A )\). By Lemma 8, we thus have the sequence of inclusions:

$$\begin{aligned} \mathcal A ^{\frac{\eta }{2}} \;\subset \; |L| \;\subset \; \mathcal A ^{\frac{3\eta }{4} + 2\alpha } \;\subset \; |K| \;\subset \; \mathcal A ^{\eta + 4 \alpha }, \end{aligned}$$

with \(\eta + 4 \alpha < \mathrm {wfs} (\mathcal A )\). Lemma 11 then implies that if \(X\) is a homological simplification of the pair \((K,L)\), its underlying space \(\mathcal X =|X|\) is a faithful homological reconstruction of \(\mathcal A \). Furthermore, if \(\mathcal A \in W(\mathcal S ,\alpha ,\eta ,\mu )\) or equivalently if \(d_H(\mathcal S ,\mathcal A ) < \alpha < \frac{1}{4} \left(r_\mu (\mathcal A ) - \eta \right)\), Lemmas 8 and 11 guarantee that the algorithm returns a faithful homological simplification of \(\mathcal A \) (and not \(\emptyset \)).\(\square \)

Let us bound the time complexity of a more efficient version of the algorithm in which voxels are not decomposed into simplices. Let \(D\) be the diameter of \(\mathcal S \) and set \(D^{\prime } = D+ 2(\eta + 3\alpha )\). It is not difficult to check that this simpler algorithm has time complexity

$$\begin{aligned} O \big ( 2^{|K|} |K|^3 \big ) = O \big ( 2^{\big (\tfrac{D^{\prime }}{\varepsilon }\big )^N} \big ( \tfrac{D^{\prime }}{\varepsilon } \big )^{3N} \big ). \end{aligned}$$

Indeed, the size of \(K\) is \(O((D^{\prime }/\varepsilon )^N)\). Checking if \(X\) is a homological simplification of \((K,L)\) takes cubic time the size of \(K\) and the number of cubical sets \(\mathcal X \) between \(\mathcal L \) and \(\mathcal K \) is \(O(2^{|K|})\). If the voxels are decomposed into simplices, the running time increases but remains finite.

4.4 Second Naive Reconstruction Algorithm

We now describe our second reconstruction algorithm NAIVE_2. Its pseudocode is given in Table 2, right. The algorithm takes as input a triplet \((\mathcal S ,\alpha ,\eta )\). Starting with \(\mu =1\), it calls NAIVE_1 with decreasing values of \(\mu \) until NAIVE_1 returns a non-empty set.

Theorem 13

Let \(\mathcal S \subset \mathbb R ^N\), \(\alpha >0\), and \(\eta >0\). Assuming the precondition \(W(\mathcal S ,\alpha ,\eta ) \ne \emptyset \) on the input, the algorithm NAIVE_2 outputs a faithful homological reconstruction of all shapes in \(W(\mathcal S ,\alpha ,\eta )\) after a finite number of iterations.

Proof

The algorithm terminates thanks to the lower semi-continuity of the critical function \(\chi _\mathcal{A }\). Suppose \(W(\mathcal S ,\alpha ,\eta ) \ne \emptyset \) and let \(\mathcal A \in W(\mathcal S ,\alpha ,\eta )\), i.e., such that \(d_H(\mathcal S ,\mathcal A ) < \alpha < \frac{1}{4} ( \mathrm {wfs} (\mathcal A ) - \eta )\). Because \(\chi _\mathcal A \) is lower semi-continuous, it attains its minimum \(\mu ^{\prime }>0\) over the interval \([\frac{\eta }{8},4\alpha +\frac{7\eta }{8}]\). Setting \(\mathcal A ^{\prime } = \mathcal A ^{\frac{\eta }{8}}\), \(\alpha ^{\prime } = \alpha + \frac{\eta }{8}\) and \(\eta ^{\prime } = \frac{\eta }{4}\), we have \(r_{\mu ^{\prime }}(\mathcal A ^{\prime }) > 4\alpha + \frac{3\eta }{4} = 4 \alpha ^{\prime } + \eta ^{\prime }\) (see Fig. 5 for an explanation) and, therefore,

$$\begin{aligned} d_H(\mathcal S ,\mathcal A ^{\prime }) \le d_H(\mathcal S ,\mathcal A ) + d_H(\mathcal A ,\mathcal A ^{\prime }) < \alpha + \tfrac{\eta }{8} = \alpha ^{\prime } < \tfrac{1}{4} \left( r_{\mu ^{\prime }}(\mathcal A ^{\prime }) - \eta ^{\prime }\right). \end{aligned}$$

It follows that for all \(0 < \mu \le \mu ^{\prime }\) we have \(\mathcal A ^{\prime } \in W(\mathcal S ,\alpha ^{\prime },\eta ^{\prime },\mu ) \ne \emptyset \) because \(r_{\mu ^{\prime }}(\mathcal A ^{\prime }) \le r_{\mu }(\mathcal A ^{\prime })\). Thus, at some point, the algorithm NAIVE_1 will be called with input \((\mathcal S ,\alpha ^{\prime },\eta ^{\prime },\mu )\) satisfying \(W(\mathcal S ,\alpha ^{\prime },\eta ^{\prime },\mu )\ne \emptyset \) and by Theorem 12 will return a non-empty set to the algorithm NAIVE_2. When this happens, the result is a faithful reconstruction of every shape in \(W(\mathcal S ,\alpha ^{\prime },\eta ^{\prime })\) and in particular of \(\mathcal A \) since \(d_H(\mathcal S ,\mathcal A ) < \alpha ^{\prime } < \frac{1}{4} ( \mathrm {wfs} (\mathcal A ) - \eta ^{\prime })\) as can be easily checked.\(\square \)

Note that algorithm NAIVE_1 can be considered as an approximation of an optimal reconstruction algorithm. Even though the algorithm terminates, its time complexity is unbounded.

Fig. 5
figure 5

Performing an \(r\)-offset translates the critical function to the left by \(r\) [10]. Thus, \(\chi _\mathcal A (\rho ) \ge \mu ^{\prime }\) on \([r,R]\) implies \(r_{\mu ^{\prime }}(\mathcal A ^r) > R- r\)

5 Homological Simplification is NP-complete

In this section, we focus on the problem of computing a homological simplification and prove that this problem is NP-complete, at least when \(F = \mathbb Z _2\). We denote the pth homology group of \(K\) by \(\mathbf H _p(K)\) and work with coefficients in the field \(\mathbb Z _2\) of integers modulo \(2\). A simplicial pair \((K,L)\) consists of a (finite) simplicial complex \(K\) and a subcomplex \(L\subset K\). When clear from the context, we will simply speak of the pair \((K,L)\) and omit “simplicial.” We say that the pair \((K,L)\) is p-dimensional if the simplicial complex \(K\) has dimension \(p\).

Definition 5

(Homological simplification problem) The homological simplification problem takes as input a simplicial pair \((K,L)\) and asks whether there exists a simplicial complex \(X\) which is a homological simplification of the pair \((K,L)\).

The size of the problem is the number of simplices in \(K\). We are now ready to state our main theorem:

Theorem 14

The homological simplification problem of two-dimensional simplicial pairs is NP-complete.

Proof

To check that a candidate \(X\) is a homological simplification of the \(p\)-dimensional pair \((K,L)\), it is enough to compute the dimension of the \(p\)th homology group of \(X\) and compare it to the rank of the persistent \(p\)th homology group of \(K\) into \(L\), for all \(p\). Since all computations can be done in time cubic in the number of simplices in \(K\), we deduce that the homological simplification problem of \(p\)-dimensional simplicial pairs is in NP. In Sect. 5.1, we prove that this problem is NP-hard for \(p=2\) by reducing 3SAT to it in polynomial time. Figure 6 summarizes the reduction.\(\square \)

Fig. 6
figure 6

Diagram of the reduction

5.1 Reduction from 3SAT

5.1.1 3SAT

A Boolean formula \(E\) is in 3-conjunctive normal form, or 3CNF, if it is a conjunction (AND) of \(n\) clauses \(c_1, c_2, \ldots , c_n\), each of which is a disjunction (OR) of three literals, each literal being a Boolean variable or its negation [15]. Specifically, \(E = \bigwedge _{1 \le i \le n} c_i\) and each clause \(c_i\) has the form

$$\begin{aligned} c_i = \big (e^1_i v_{j^1_i } \big ) \vee \big (e^2_i v_{j^2_i } \big ) \vee \big (e^3_i v_{j^3_i } \big ), \end{aligned}$$

where \(j^k_i \in \{1,\ldots ,m\}\), \(v_{j^k_i}\) is a Boolean variable and \(e^k_i \in \{ \mathbf 1 ,\mathbf \lnot \} \) is either the identity symbol \(\mathbf 1 \) or the negation symbol \(\mathbf \lnot \), for \(1 \le k \le 3\). The 3SAT problem takes as input a 3CNF formula \(E\) and determines whether one can assign a value \(\mathtt TRUE \) or \(\mathtt FALSE \) to each variable of \(E\) such that \(E\) evaluates to \(\mathtt TRUE \). An assignment of variables which makes \(E\) evaluates to \(\mathtt TRUE \) is called a satisfying assignment. Since the number \(m\) of variables used in formula \(E\) is at most three times the number \(n\) of clauses, i.e., \(m\le 3 n\), we let \(n\) be the size of the 3SAT problem. 3SAT is known to be NP-complete.

5.1.2 Reduction Algorithm

We describe a reduction algorithm that transforms in linear time any instance \(E\) of the 3SAT problem into an instance \((K,L)\) of the homological simplification problem in such a way that \((K,L)\) has a homological simplification if and only if \(E\) has a satisfying assignment. Given a 3CNF formula \(E\) of \(n\) clauses \(c_1, \ldots , c_n\) and \(m\) variables \(v_1, \ldots , v_m\), we construct a two-dimensional simplicial pair \((K,L)\) as follows; see Figs. 7 and 8. The simplicial complex \(L\) consists of

  • a vertex \(A\);

  • two vertices \(B_i\) and \(C_i\) and three edges \(AB_i\), \(B_iC_i\) and \(C_iA\) for each clause \(c_i\);

  • two vertices \(V_j\) and \(W_j\) and the edge \(V_jW_j\) for each variable \(v_j\).

Fig. 7
figure 7

Simplicial complex \(L\) output by the reduction of a formula with five clauses and six variables and triangles in \(K\) created by clause \(c_1 = v_2 \vee \mathbf \lnot v_3 \vee \mathbf \lnot v_5\)

Fig. 8
figure 8

Pair \((K,L)\) produced by the reduction of formula \((v_1 \vee \mathbf \lnot v_2 \vee \mathbf \lnot v_3) \wedge (v_1 \vee v_2 \vee v_4)\). \(L\) consists of the vertices and bold edges

Besides simplices in \(L\), the simplicial complex \(K\) contains three triangles per literal and two edges per variable. Specifically, if \(e_i^k = \mathbf 1 \), we add the three triangles \(AB_iV_{j_i^k}\), \(B_iC_iV_{j_i^k}\) and \(C_iAV_{j_i^k}\) and their edges. If \(e_i^k = \mathbf \lnot \), we add the three triangles \(AB_iW_{j_i^k}\), \(B_iC_iW_{j_i^k}\) and \(C_iAW_{j_i^k}\) and their edges. Moreover, we add edges \(AV_j\) and \(AW_j\) for all \(j \in \{1, \ldots , m\}\). Observe that the size of \(K\) is only a constant factor larger than the size of \(E\) and its construction requires linear time in \(n\).

Let \(f_* : \mathbf H _p(L) \rightarrow \mathbf H _p(K)\) be the homomorphism induced by the inclusion \(L \subset K\). Since \(K\) is connected, we have \(f_*(\mathbf H _0(L)) = \mathbb Z _2\). Furthermore, \(f_*(\mathbf H _1(L)) = 0\) since a base of the 1-cycles in \(L\) is given by the \(n\) cycles \(\sigma _i = AB_i + B_iC_i + C_iA\) and \(\sigma _i\) is homologous to 0 in \(K\) for each \(i \in \{1, \ldots , n\}\). Last, \(f_*(\mathbf H _2(L)) = 0\) since \(L\) contains no 2-simplices. By Lemma 10, we obtain that \(X\) is a homological simplification of the pair \((K,L)\) if and only if \(\mathbf H _0(X) = \mathbb Z _2\), \(\mathbf H _1(X) = 0\) and \(\mathbf H _2(X) = 0\). Keeping this in mind, we establish the following lemma, in which \((K,L)\) designates the pair output by our reduction algorithm when applied to formula \(E\).

Lemma 15

The pair \((K,L)\) has a homological simplification if and only if the formula \(E\) has a satisfying assignment. Furthermore, given a homological simplification of the pair \((K,L)\), computing a satisfying assignment for \(E\) takes linear time.

Proof

Suppose the pair \((K,L)\) has a homological simplification \(X\) and let us prove that \(E\) has a satisfying assignment. First, we claim that \(X\) cannot contain both edges \(AV_j\) and \(AW_j\), for \(1 \le j \le m\). Indeed, if both edges \(AV_j\) and \(AW_j\) were in \(X\), we could consider the cycle \(\tau = A V_j + V_j W_j + W_j A\). Since the edge \(V_j W_j\) bounds no triangle in \(K\), the cycle \(\tau \) cannot be homologous to \(0\) in \(X\), contradicting \(\mathbf H _1(X) = 0\).

The claim allows us to assign to each variable \(v_j\) either the value \(\mathtt TRUE \) if the edge \(AV_j\) belongs to \(X\) or the value \(\mathtt FALSE \) if the edge \(AW_j\) belongs to \(X\). If none of the edges \(AV_j\) and \(AW_j\) belong to \(X\), then we assign to \(v_j\) an arbitrary value in \( \{ \mathtt TRUE ,\mathtt FALSE \}\); see Fig. 9. Note that the computation of this assignment can be done in linear time. We now check that this assignment of boolean values to the variables \(v_j\) is a satisfying assignment, in other words we show that all clauses \(c_i\) are satisfied for \(1 \le i \le n\).

Fig. 9
figure 9

A homological simplification of the pair \((K,L)\) drawn in Fig. 8 and output by the reduction of formula \(E=(v_1 \vee \mathbf \lnot v_2 \vee \mathbf \lnot v_3) \wedge (v_1 \vee v_2 \vee v_4)\). Corresponding satisfying assignments for \(E\)

Since \(\mathbf H _1(X)=0\), the 1-cycle \(A B_i + B_i C_i + C_i A\) is a boundary in \(X\). This implies that at least one triangle of \(X\) contains \(A B_i\) on its boundary. By construction, \(AB_i\) belongs to exactly three triangles in \(K\), namely the triangles \(A B_i Y_i^k\) for \(1 \le k \le 3\) where \(Y_i^k\) designates \(V_{j_i^k}\) if \(e_i^k = \mathbf 1 \) and \(W_{j_i^k}\) if \(e_i^k = \mathbf \lnot \). It follows that one of the three triangles \(A B_i Y_i^k\) must belong to \(X\) and, in turn, at least one of the three edges \(A Y_i^k\) for \(1 \le k \le 3\) is in \(X\). This implies that one of the three literals \(e_i^kv_{j_i^k}\) in clause \(c_i\) evaluates to \(\mathtt TRUE \) and hence \(c_i\) is satisfied.

Conversely, suppose variables \(v_1, \ldots , v_m\) have been assigned values that cause \(E\) to evaluate to \(\mathtt TRUE \) and let us prove that the pair \((K,L)\) has a homological simplification \(X\). We construct \(X\) starting from \(L\) and adding some simplices of \(K\) as follows; see Fig. 10. We begin by adding the edge \(AV_j\) if \(v_j = \mathtt TRUE \) and the edge \(AW_j\) if \(v_j = \mathtt FALSE \), for all \(j \in \{1,\ldots ,m\}\). Since values of \(v_1, \ldots , v_m\) are a satisfying assignment, we can choose one literal \(e_iv_{j_i}\) in each clause \(c_i\) that is true. Let \(Y_i = V_{j_i}\) if \(e_i = \mathbf 1 \) and \(Y_i = W_{j_i}\) if \(e_i = \mathbf \lnot \). Note that by construction, the edge \(AY_i\) is already in \(X\). We then add the three triangles \(AB_iY_i\), \(B_iC_iY_i\) and \(C_iAY_i\) to \(X\), for all \(i \in \{1,\ldots ,n\}\).

Fig. 10
figure 10

Satisfying assignment for formula \(E=(v_1 \vee \mathbf \lnot v_2 \vee \mathbf \lnot v_3) \wedge (v_1 \vee v_2 \vee v_4)\) and corresponding homological simplification of \((K,L)\)

Let us check that \(X\) is indeed a solution to the homological simplification problem, i.e., \(\mathbf H _0(X) = \mathbb Z _2\), \(\mathbf H _1(X) = 0\) and \(\mathbf H _2(X) = 0\). For this, we check that \(X\) is contractible by collapsing \(X\) to \(A\), using a sequence of elementary collapses. First, observe that exactly one of the two vertices \(V_j\) or \(W_j\) belongs to no other simplices than the edge \(V_jW_j\). For instance, if \(v_j = \mathtt TRUE \), then by construction \(AV_j \in X\) and \(AW_j \not \in X\). Thus, \(W_j\) belongs to no other simplices than \(V_jW_j\) and we can collapse the edge \(V_jW_j\) to the vertex \(V_j\) by removing the pair of simplices \((W_j,V_jW_j)\). Similarly, if \(v_j = \mathtt FALSE \), we collapse the edge \(V_jW_j\) to the vertex \(W_j\). For all \(i \in \{1,\ldots ,n\}\), we apply five elementary collapses, first removing the three triangles \(AB_iY_i\), \(B_iC_iY_i\) and \(C_iAY_i\) and their edges \(AB_i\), \(B_iC_i\) and \(C_iA\), then removing the edges \(B_iY_i\) and \(C_iY_i\) and their vertices \(B_i\) and \(C_i\). Last, we collapse every edge \(AY_i\) for \(1 \le i \le n\) to the vertex \(A\).\(\square \)

6 Discussion

In this paper, we presented an algorithm for reconstructing a shape under a very weak sampling condition, but at the expense of computing the homological simplification of a simplicial pair, which we proved is NP-hard. Our work raises several questions and research tracks.

Open Questions. Is there a version of Lemma 7 in which the voxel size does not depend on \(\mu \)? Is the homological simplification problem in the same class of complexity if we constraint \(K\) to be a subcomplex of a triangulation of the sphere \(\mathbb S ^3\)?

Optimistic Research Track. If a polynomial time optimal reconstruction algorithm exists, it should take advantage of the embedding in Euclidean space or at least lead to a class of simplification problems sufficiently constrained to avoid constructions similar to ours.

Pessimistic Research Track. Is it possible to encode 3-SAT as the homological simplification of a pair \((K_{3\alpha }(\mathcal S ),K_\alpha (\mathcal S ))\), where \((\mathcal S ,\alpha )\) satisfies the weak sampling condition? Or, as the homological simplification of a pair of cubical complexes defined by offsets of the sample? If yes, in which minimal dimension?